Class CompositeLexerContextCache
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.grammar.CompositeLexerContextCache
-
public final class CompositeLexerContextCache extends Object
This class is used to keep track of the lexer context to help us determine when to switch lexer modes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
CompositeLexerContextCache.StringTemplateContext
A class to represent the context of a string template.
-
Field Summary
Fields Modifier and Type Field Description private org.antlr.v4.runtime.Lexer
lexer
The lexer to use.private Deque<CompositeLexerContextCache.StringTemplateContext>
stringTemplateContextStack
Stack for tracking string template contexts.
-
Constructor Summary
Constructors Constructor Description CompositeLexerContextCache(org.antlr.v4.runtime.Lexer lexer)
Creates a new CompositeLexerContextCache instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
enterTemplateContext(int mode)
Enter a string template context.void
exitTemplateContext()
Exit a string template context.private boolean
isInStringTemplateContext()
Check if we are in a string template context.void
updateLeftCurlyBraceContext()
Update the left curly brace context if we are in a string template.void
updateRightCurlyBraceContext()
Update the right curly brace context if we are in a string template.
-
-
-
Field Detail
-
stringTemplateContextStack
private final Deque<CompositeLexerContextCache.StringTemplateContext> stringTemplateContextStack
Stack for tracking string template contexts.
-
lexer
private final org.antlr.v4.runtime.Lexer lexer
The lexer to use.
-
-
Constructor Detail
-
CompositeLexerContextCache
public CompositeLexerContextCache(org.antlr.v4.runtime.Lexer lexer)
Creates a new CompositeLexerContextCache instance.- Parameters:
lexer
- the lexer to use
-
-
Method Detail
-
enterTemplateContext
public void enterTemplateContext(int mode)
Enter a string template context.- Parameters:
mode
- the lexer mode to enter
-
exitTemplateContext
public void exitTemplateContext()
Exit a string template context.
-
updateLeftCurlyBraceContext
public void updateLeftCurlyBraceContext()
Update the left curly brace context if we are in a string template.
-
updateRightCurlyBraceContext
public void updateRightCurlyBraceContext()
Update the right curly brace context if we are in a string template.
-
isInStringTemplateContext
private boolean isInStringTemplateContext()
Check if we are in a string template context.- Returns:
- true if we are in a string template context
-
-