Class AbstractJFlexCTokenMaker
java.lang.Object
org.fife.ui.rsyntaxtextarea.TokenMakerBase
org.fife.ui.rsyntaxtextarea.AbstractJFlexTokenMaker
org.fife.ui.rsyntaxtextarea.AbstractJFlexCTokenMaker
- All Implemented Interfaces:
TokenMaker
- Direct Known Subclasses:
ActionScriptTokenMaker, CPlusPlusTokenMaker, CSharpTokenMaker, CSSTokenMaker, CTokenMaker, DartTokenMaker, DTokenMaker, GoTokenMaker, GroovyTokenMaker, JavaScriptTokenMaker, JavaTokenMaker, JsonTokenMaker, KotlinTokenMaker, NSISTokenMaker, PerlTokenMaker, ProtoTokenMaker, RustTokenMaker, ScalaTokenMaker, TclTokenMaker, TypeScriptTokenMaker
Base class for JFlex-based token makers using C-style syntax. This class
knows how to:
- Auto-indent after opening braces and parens
- Automatically close multi-line and documentation comments
- Version:
- 1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classAction that knows how to special-case inserting a newline in a multi-line comment for languages like C and Java. -
Field Summary
FieldsFields inherited from class AbstractJFlexTokenMaker
offsetShift, s, startFields inherited from class TokenMakerBase
currentToken, firstToken, previousToken -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ActionCreates and returns the action to use when the user inserts a newline.booleangetCurlyBracesDenoteCodeBlocks(int languageIndex) Returnstruealways as C-style languages use curly braces to denote code blocks.Returns an action to handle "insert break" key presses (i.e.booleangetMarkOccurrencesOfTokenType(int type) Returns whether tokens of the specified type should have "mark occurrences" enabled for the current programming language.booleanThe default implementation returnsfalsealways.private booleanReturns whether a given token is an internal token type that represents an MLC or documentation comment continuing on to the next line.Methods inherited from class AbstractJFlexTokenMaker
yybegin, yybegin, yyclose, yytextMethods inherited from class TokenMakerBase
addNullToken, addToken, addToken, addToken, createOccurrenceMarker, getClosestStandardTokenTypeForInternalType, getLanguageIndex, getLastTokenTypeOnLine, getLineCommentStartAndEnd, getNoTokensIdentifiedYet, getOccurrenceMarker, isIdentifierChar, isMarkupLanguage, resetTokenList, setLanguageIndexMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface TokenMaker
getTokenList
-
Field Details
-
INSERT_BREAK_ACTION
-
MLC_PATTERN
-
-
Constructor Details
-
AbstractJFlexCTokenMaker
protected AbstractJFlexCTokenMaker()
-
-
Method Details
-
createInsertBreakAction
Creates and returns the action to use when the user inserts a newline. The default implementation intelligently closes multi-line comments. Subclasses can override.- Returns:
- The action.
- See Also:
-
getCurlyBracesDenoteCodeBlocks
public boolean getCurlyBracesDenoteCodeBlocks(int languageIndex) Returnstruealways as C-style languages use curly braces to denote code blocks.- Specified by:
getCurlyBracesDenoteCodeBlocksin interfaceTokenMaker- Overrides:
getCurlyBracesDenoteCodeBlocksin classTokenMakerBase- Parameters:
languageIndex- The language index at the offset in question. Since someTokenMakers effectively have nested languages (such as JavaScript in HTML), this parameter tells theTokenMakerwhat sub-language to look at.- Returns:
truealways.
-
getInsertBreakAction
Returns an action to handle "insert break" key presses (i.e. Enter). An action is returned that handles newlines differently in multi-line comments.- Specified by:
getInsertBreakActionin interfaceTokenMaker- Overrides:
getInsertBreakActionin classTokenMakerBase- Returns:
- The action.
-
getMarkOccurrencesOfTokenType
public boolean getMarkOccurrencesOfTokenType(int type) Description copied from class:TokenMakerBaseReturns whether tokens of the specified type should have "mark occurrences" enabled for the current programming language. The default implementation returns true if type isTokenTypes.IDENTIFIER. Subclasses can override this method to support other token types, such asTokenTypes.VARIABLE.- Specified by:
getMarkOccurrencesOfTokenTypein interfaceTokenMaker- Overrides:
getMarkOccurrencesOfTokenTypein classTokenMakerBase- Parameters:
type- The token type.- Returns:
- Whether tokens of this type should have "mark occurrences" enabled.
-
getShouldIndentNextLineAfter
Description copied from class:TokenMakerBaseThe default implementation returnsfalsealways. Languages that wish to better support auto-indentation can override this method.- Specified by:
getShouldIndentNextLineAfterin interfaceTokenMaker- Overrides:
getShouldIndentNextLineAfterin classTokenMakerBase- Parameters:
t- The token the previous line ends with.- Returns:
- Whether the next line should be indented.
-
isInternalEolTokenForMLCs
Returns whether a given token is an internal token type that represents an MLC or documentation comment continuing on to the next line. This is done by languages such as JavaScript that are a little more verbose than necessary so that their code can be copy-and-pasted into otherTokenMakers that use them as nested languages (such as HTML, JSP, etc.).- Parameters:
t- The token to check. This cannot benull.- Returns:
- Whether the token is an internal token representing the end of a line for an MLC/doc comment continuing on to the next line.
-