Package org.fife.ui.rsyntaxtextarea
Class HtmlOccurrenceMarker
- java.lang.Object
-
- org.fife.ui.rsyntaxtextarea.HtmlOccurrenceMarker
-
- All Implemented Interfaces:
OccurrenceMarker
public class HtmlOccurrenceMarker extends java.lang.Object implements OccurrenceMarker
Marks occurrences of the current token for HTML. Tags that require a closing tag have their "opposite" tag closed.- Version:
- 1.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
HtmlOccurrenceMarker.Entry
Used internally when searching backward for a matching "open" tag.
-
Field Summary
Fields Modifier and Type Field Description private static char[]
CLOSE_TAG_START
private static char[]
TAG_SELF_CLOSE
private static java.util.Set<java.lang.String>
TAGS_REQUIRING_CLOSING
-
Constructor Summary
Constructors Constructor Description HtmlOccurrenceMarker()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.util.Set<java.lang.String>
getRequiredClosingTags()
Returns the set of HTML tags that require a closing tag.static Token
getTagNameTokenForCaretOffset(RSyntaxTextArea textArea, OccurrenceMarker occurrenceMarker)
If the caret is inside a tag, this method returns the token representing the tag name; otherwise,null
is returned.Token
getTokenToMark(RSyntaxTextArea textArea)
Returns the token to mark occurrences, of, provided it matches the criteria put forth byOccurrenceMarker.isValidType(RSyntaxTextArea, Token)
.boolean
isValidType(RSyntaxTextArea textArea, Token t)
Returns whether the specified token is a type that we can do a "mark occurrences" of.void
markOccurrences(RSyntaxDocument doc, Token t, RSyntaxTextAreaHighlighter h, SmartHighlightPainter p)
Called when occurrences of a token should be marked.
-
-
-
Method Detail
-
getRequiredClosingTags
public static java.util.Set<java.lang.String> getRequiredClosingTags()
Returns the set of HTML tags that require a closing tag.- Returns:
- The set of HTML tags that require a closing tag.
-
getTagNameTokenForCaretOffset
public static Token getTagNameTokenForCaretOffset(RSyntaxTextArea textArea, OccurrenceMarker occurrenceMarker)
If the caret is inside a tag, this method returns the token representing the tag name; otherwise,null
is returned.Currently, this method only checks for tag names on the same line as the caret, for simplicity. In the future it could check prior lines until the tag name is found.
- Parameters:
textArea
- The text area.occurrenceMarker
- The occurrence marker.- Returns:
- The token to mark occurrences of. Note that, if the specified occurrence marker identifies tokens other than tag names, these other element types may be returned.
-
getTokenToMark
public Token getTokenToMark(RSyntaxTextArea textArea)
Description copied from interface:OccurrenceMarker
Returns the token to mark occurrences, of, provided it matches the criteria put forth byOccurrenceMarker.isValidType(RSyntaxTextArea, Token)
. For most languages, this method should return the token at the caret position.- Specified by:
getTokenToMark
in interfaceOccurrenceMarker
- Parameters:
textArea
- The text area.- Returns:
- The token to (possibly) mark occurrences of, or
null
if none.
-
isValidType
public boolean isValidType(RSyntaxTextArea textArea, Token t)
Description copied from interface:OccurrenceMarker
Returns whether the specified token is a type that we can do a "mark occurrences" of. Typically, this will delegate toRSyntaxTextArea.getMarkOccurrencesOfTokenType(int)
.- Specified by:
isValidType
in interfaceOccurrenceMarker
- Parameters:
textArea
- The text area.t
- The token.- Returns:
- Whether we should mark all occurrences of this token.
-
markOccurrences
public void markOccurrences(RSyntaxDocument doc, Token t, RSyntaxTextAreaHighlighter h, SmartHighlightPainter p)
Description copied from interface:OccurrenceMarker
Called when occurrences of a token should be marked.- Specified by:
markOccurrences
in interfaceOccurrenceMarker
- Parameters:
doc
- The document.t
- The document whose relevant occurrences should be marked.h
- The highlighter to add the highlights to.p
- The painter for the highlights.
-
-