|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.fife.ui.rsyntaxtextarea.folding.CurlyFoldParser
public class CurlyFoldParser
A basic fold parser that can be used for languages such as C, that use
curly braces to denote code blocks. This parser searches for curly brace
pairs and creates code folds out of them. It can also optionally find
C-style multi-line comments ("/* ... */
") and make them
foldable as well.
This parser knows nothing about language semantics; it uses
RSyntaxTextArea
's syntax highlighting tokens to identify
curly braces. By default, it looks for single-char tokens of type
TokenTypes.SEPARATOR
, with lexemes '{
' or '}
'.
If your TokenMaker
uses a different token type for curly braces, you
should override the isLeftCurly(Token)
and
isRightCurly(Token)
methods with your own definitions. In theory,
you could extend this fold parser to parse languages that use completely
different tokens than curly braces to denote foldable regions by overriding
those two methods.
Note also that this class may impose somewhat of a performance penalty on large source files, since it re-parses the entire document each time folds are reevaluated.
Field Summary | |
---|---|
protected static char[] |
C_MLC_END
Ending of a multi-line comment in C, C++, Java, etc. |
Constructor Summary | |
---|---|
CurlyFoldParser()
Creates a fold parser that identifies foldable regions via curly braces as well as C-style multi-line comments. |
|
CurlyFoldParser(boolean cStyleMultiLineComments,
boolean java)
Constructor. |
Method Summary | |
---|---|
boolean |
getFoldableMultiLineComments()
Returns whether multi-line comments are foldable with this parser. |
java.util.List<Fold> |
getFolds(RSyntaxTextArea textArea)
Returns a list of all folds in the text area. |
boolean |
isLeftCurly(Token t)
Returns whether the token is a left curly brace. |
boolean |
isRightCurly(Token t)
Returns whether the token is a right curly brace. |
void |
setFoldableMultiLineComments(boolean foldable)
Sets whether multi-line comments are foldable with this parser. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final char[] C_MLC_END
Constructor Detail |
---|
public CurlyFoldParser()
public CurlyFoldParser(boolean cStyleMultiLineComments, boolean java)
cStyleMultiLineComments
- Whether to scan for C-style multi-line
comments and make them foldable.java
- Whether this parser is folding Java. This adds extra
parsing rules, such as grouping all import statements into a
fold section.Method Detail |
---|
public boolean getFoldableMultiLineComments()
setFoldableMultiLineComments(boolean)
public java.util.List<Fold> getFolds(RSyntaxTextArea textArea)
getFolds
in interface FoldParser
textArea
- The text area whose contents should be analyzed.
null
,
it is treated as if no folds were found.public boolean isLeftCurly(Token t)
t
- The token.
isRightCurly(Token)
public boolean isRightCurly(Token t)
t
- The token.
isLeftCurly(Token)
public void setFoldableMultiLineComments(boolean foldable)
foldable
- Whether multi-line comments are foldable.getFoldableMultiLineComments()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |