Class HtmlFoldParser
java.lang.Object
org.fife.ui.rsyntaxtextarea.folding.HtmlFoldParser
- All Implemented Interfaces:
FoldParser
Fold parser for HTML 5, PHP and JSP. For HTML, we currently don't fold
everything possible, just the "big" stuff. For PHP, we only fold
the "big" HTML stuff and PHP regions, not code blocks in the actual PHP.
For JSP we only fold the "big" HTML stuff and JSP blocks, not anything in
the actual Java code.
- Version:
- 1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
A simple wrapper for the token denoting the closing of a tag (i.e. -
Field Summary
FieldsModifier and TypeFieldDescriptionThe set of tags we allow to be folded.private static final char[]
private static final char[]
private static final char[]
private static final char[]
private static final char[][]
private static final char[][]
private final int
The language we're folding.static final int
Constant denoting we're folding HTML.static final int
Constant denoting we're folding JSP.static final int
Constant denoting we're folding PHP.private static final char[]
private static final char[]
private static final char[]
private static final char[]
private static final char[]
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetFolds
(RSyntaxTextArea textArea) Returns a list of all folds in the text area.private int
getTagCloseInfo
(Token tagNameToken, RSyntaxTextArea textArea, int line, HtmlFoldParser.TagCloseInfo info) Grabs the token representing the closing of a tag (i.e.private static boolean
isEndOfLastFold
(Stack<String> tagNameStack, Token tagNameToken) Returns whether a closing tag ("</...>
") with a specific name is the closing tag of our current fold region.private static boolean
isFoldableTag
(Token tagNameToken) Returns whether a tag is one we allow as a foldable region.private static void
removeFold
(Fold fold, List<Fold> folds) If this fold has a parent fold, this method removes it from its parent.
-
Field Details
-
LANGUAGE_HTML
public static final int LANGUAGE_HTMLConstant denoting we're folding HTML.- See Also:
-
LANGUAGE_PHP
public static final int LANGUAGE_PHPConstant denoting we're folding PHP.- See Also:
-
LANGUAGE_JSP
public static final int LANGUAGE_JSPConstant denoting we're folding JSP.- See Also:
-
language
private final int languageThe language we're folding. -
FOLDABLE_TAGS
The set of tags we allow to be folded. These are tags that must have explicit close tags in both HTML 4 and HTML 5. -
MARKUP_CLOSING_TAG_START
private static final char[] MARKUP_CLOSING_TAG_START -
MLC_START
private static final char[] MLC_START -
MLC_END
private static final char[] MLC_END -
PHP_START
private static final char[] PHP_START -
PHP_END
private static final char[] PHP_END -
JSP_START
private static final char[] JSP_START -
JSP_END
private static final char[] JSP_END -
LANG_START
private static final char[][] LANG_START -
LANG_END
private static final char[][] LANG_END -
JSP_COMMENT_START
private static final char[] JSP_COMMENT_START -
JSP_COMMENT_END
private static final char[] JSP_COMMENT_END
-
-
Constructor Details
-
HtmlFoldParser
public HtmlFoldParser(int language) Constructor.- Parameters:
language
- The language to fold, such asLANGUAGE_PHP
.
-
-
Method Details
-
getFolds
Description copied from interface:FoldParser
Returns a list of all folds in the text area.- Specified by:
getFolds
in interfaceFoldParser
- Parameters:
textArea
- The text area whose contents should be analyzed.- Returns:
- The list of folds. If this method returns
null
, it is treated as if no folds were found.
-
getTagCloseInfo
private int getTagCloseInfo(Token tagNameToken, RSyntaxTextArea textArea, int line, HtmlFoldParser.TagCloseInfo info) Grabs the token representing the closing of a tag (i.e. ">
" or "/>
"). This should only be called after a tag name has been parsed, to ensure the "closing" of other tags is not identified.- Parameters:
tagNameToken
- The token denoting the name of the tag.textArea
- The text area whose contents are being parsed.line
- The line we're currently on.info
- On return, information about the closing of the tag is returned in this object.- Returns:
- The line number of the closing tag token.
-
isEndOfLastFold
Returns whether a closing tag ("</...>
") with a specific name is the closing tag of our current fold region.- Parameters:
tagNameStack
- The stack of fold regions.tagNameToken
- The tag name of the most recently parsed closing tag.- Returns:
- Whether it's the end of the current fold region.
-
isFoldableTag
Returns whether a tag is one we allow as a foldable region.- Parameters:
tagNameToken
- The tag's name token. This may benull
.- Returns:
- Whether this tag can be a foldable region.
-
removeFold
If this fold has a parent fold, this method removes it from its parent. Otherwise, it's assumed to be the most recent (top-level) fold in thefolds
list, and is removed from that.- Parameters:
fold
- The fold to remove.folds
- The list of top-level folds.
-