public class CurlyFoldParser extends java.lang.Object implements FoldParser
/* ... */
") 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.
限定符和类型 | 字段和说明 |
---|---|
protected static char[] |
C_MLC_END
Ending of a multi-line comment in C, C++, Java, etc.
|
构造器和说明 |
---|
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.
|
限定符和类型 | 方法和说明 |
---|---|
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.
|
protected static final char[] C_MLC_END
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.public boolean getFoldableMultiLineComments()
setFoldableMultiLineComments(boolean)
public java.util.List<Fold> getFolds(RSyntaxTextArea textArea)
getFolds
在接口中 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()