Class SearchTerminals<T extends JobParameters>
java.lang.Object
io.github.douira.glsl_transformer.GLSLParserBaseListener
io.github.douira.glsl_transformer.transform.TransformationPhase<T>
io.github.douira.glsl_transformer.transform.WalkPhase<T>
io.github.douira.glsl_transformer.core.SearchTerminals<T>
- All Implemented Interfaces:
io.github.douira.glsl_transformer.GLSLParserListener,LifecycleUser<T>,PartialParseTreeListener,ParseTreeListener
- Direct Known Subclasses:
SearchTerminalsImpl
This phase finds targets in specified target token types (usually
identifiers) and triggers their handlers. The behavior of the targets can be
customized with the various available target subclasses.
By default, an exact string match of the text in the terminal node and the
needle search string is required. However, this behavior can be configured.
If something other than terminals should be searched, simply extend the walk
phase yourself and do something when it visits the parse context of
interest.
-
Nested Class Summary
Nested classes/interfaces inherited from class io.github.douira.glsl_transformer.transform.TransformationPhase
TransformationPhase.InjectionPoint -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe token type that matches any terminal token.static final intThe identifier token type. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidMakes this search phase not use exact matching.protected booleanfindNeedle(String content, HandlerTarget<T> target) Checks if the given content contains a needle.protected abstract Collection<HandlerTarget<T>>Returns the collection of targets to search for.protected intReturns the terminal token type to match the target's needles against.voidvisitTerminal(TerminalNode node) Methods inherited from class io.github.douira.glsl_transformer.transform.WalkPhase
afterWalk, beforeWalk, canWalk, checkBeforeWalk, isActiveAfterWalk, isActiveAtWalk, isActiveBeforeWalk, runAfterWalkMethods inherited from class io.github.douira.glsl_transformer.transform.TransformationPhase
compilePath, compilePattern, createLocalRoot, findAndMatch, getPlanner, getSiblings, injectDefine, injectExternalDeclaration, injectExternalDeclarations, injectNode, injectNodes, injectNodes, isActive, isInitialized, removeNode, replaceNode, replaceNode, setInitialized, setPlanner, walkFinishedMethods inherited from class io.github.douira.glsl_transformer.GLSLParserBaseListener
enterAdditiveExpression, enterArrayAccessExpression, enterArraySpecifier, enterArraySpecifierSegment, enterAssignmentExpression, enterAtomicUnitType, enterAttribute, enterBitwiseAndExpression, enterBitwiseExclusiveOrExpression, enterBitwiseInclusiveOrExpression, enterBooleanType, enterBooleanVectorType, enterBreakStatement, enterBuiltinType, enterCallParameterList, enterCompoundStatement, enterConditionalExpression, enterContinueStatement, enterDeclarationMember, enterDeclarationStatement, enterDefaultCaseLabel, enterDemoteStatement, enterDiscardStatement, enterDoWhileStatement, enterEmptyDeclaration, enterEmptyStatement, enterEqualityExpression, enterEveryRule, enterExpressionStatement, enterExtensionStatement, enterExternalDeclaration, enterFloatMatrixType, enterFloatType, enterFloatVectorType, enterForStatement, enterFullySpecifiedType, enterFunctionCall, enterFunctionCallExpression, enterFunctionDeclaration, enterFunctionDefinition, enterFunctionHeader, enterFunctionIdentifier, enterFunctionParameterList, enterFunctionPrototype, enterGroupingExpression, enterImageType, enterInitDeclaratorList, enterInitializer, enterIntegerType, enterIntegerVectorType, enterInterfaceBlockDeclaration, enterInterpolationQualifier, enterInvariantQualifier, enterIterationCondition, enterLayoutDefaults, enterLayoutQualifier, enterLiteralExpression, enterLogicalAndExpression, enterLogicalExclusiveOrExpression, enterLogicalInclusiveOrExpression, enterMemberAccessExpression, enterMethodCall, enterMethodCallExpression, enterMultiplicativeExpression, enterNamedLayoutQualifier, enterParameterDeclaration, enterParameterDeclarator, enterPostfixExpression, enterPragmaStatement, enterPreciseQualifier, enterPrecisionDeclaration, enterPrecisionQualifier, enterPrefixExpression, enterReferencedType, enterReferenceExpression, enterRelationalExpression, enterReturnStatement, enterSamplerType, enterSelectionStatement, enterSequenceExpression, enterSharedLayoutQualifier, enterShiftExpression, enterSingleAttribute, enterStatement, enterStorageQualifier, enterStructBody, enterStructDeclarator, enterStructMember, enterStructSpecifier, enterStructSpecifierType, enterSwitchStatement, enterTranslationUnit, enterTypeAndInitDeclaration, enterTypeNameList, enterTypeQualifier, enterTypeSpecifier, enterValuedCaseLabel, enterVariableDeclaration, enterVariableIdentifier, enterVersionStatement, enterVoidType, enterWhileStatement, exitAdditiveExpression, exitArrayAccessExpression, exitArraySpecifier, exitArraySpecifierSegment, exitAssignmentExpression, exitAtomicUnitType, exitAttribute, exitBitwiseAndExpression, exitBitwiseExclusiveOrExpression, exitBitwiseInclusiveOrExpression, exitBooleanType, exitBooleanVectorType, exitBreakStatement, exitBuiltinType, exitCallParameterList, exitCompoundStatement, exitConditionalExpression, exitContinueStatement, exitDeclarationMember, exitDeclarationStatement, exitDefaultCaseLabel, exitDemoteStatement, exitDiscardStatement, exitDoWhileStatement, exitEmptyDeclaration, exitEmptyStatement, exitEqualityExpression, exitEveryRule, exitExpressionStatement, exitExtensionStatement, exitExternalDeclaration, exitFloatMatrixType, exitFloatType, exitFloatVectorType, exitForStatement, exitFullySpecifiedType, exitFunctionCall, exitFunctionCallExpression, exitFunctionDeclaration, exitFunctionDefinition, exitFunctionHeader, exitFunctionIdentifier, exitFunctionParameterList, exitFunctionPrototype, exitGroupingExpression, exitImageType, exitInitDeclaratorList, exitInitializer, exitIntegerType, exitIntegerVectorType, exitInterfaceBlockDeclaration, exitInterpolationQualifier, exitInvariantQualifier, exitIterationCondition, exitLayoutDefaults, exitLayoutQualifier, exitLiteralExpression, exitLogicalAndExpression, exitLogicalExclusiveOrExpression, exitLogicalInclusiveOrExpression, exitMemberAccessExpression, exitMethodCall, exitMethodCallExpression, exitMultiplicativeExpression, exitNamedLayoutQualifier, exitParameterDeclaration, exitParameterDeclarator, exitPostfixExpression, exitPragmaStatement, exitPreciseQualifier, exitPrecisionDeclaration, exitPrecisionQualifier, exitPrefixExpression, exitReferencedType, exitReferenceExpression, exitRelationalExpression, exitReturnStatement, exitSamplerType, exitSelectionStatement, exitSequenceExpression, exitSharedLayoutQualifier, exitShiftExpression, exitSingleAttribute, exitStatement, exitStorageQualifier, exitStructBody, exitStructDeclarator, exitStructMember, exitStructSpecifier, exitStructSpecifierType, exitSwitchStatement, exitTranslationUnit, exitTypeAndInitDeclaration, exitTypeNameList, exitTypeQualifier, exitTypeSpecifier, exitValuedCaseLabel, exitVariableDeclaration, exitVariableIdentifier, exitVersionStatement, exitVoidType, exitWhileStatement, visitErrorNodeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.github.douira.glsl_transformer.transform.LifecycleUser
getJobParameters, getLexer, getParser, getRootNode, init, initOnce, resetStateMethods inherited from interface org.antlr.v4.runtime.tree.ParseTreeListener
enterEveryRule, exitEveryRule, visitErrorNodeMethods inherited from interface io.github.douira.glsl_transformer.traversal.PartialParseTreeListener
isDeepEnough, isFinished
-
Field Details
-
IDENTIFIER
public static final int IDENTIFIERThe identifier token type.- See Also:
-
ANY_TYPE
public static final int ANY_TYPEThe token type that matches any terminal token.- See Also:
-
-
Constructor Details
-
SearchTerminals
public SearchTerminals()
-
-
Method Details
-
getTargets
Returns the collection of targets to search for. This method should be efficient as it's called for every visited terminal node.- Returns:
- The targets to search for
-
getTerminalTokenType
protected int getTerminalTokenType()Returns the terminal token type to match the target's needles against. The available tokens are staticintfields onGLSLLexer.- Returns:
- The terminal token type
-
visitTerminal
- Specified by:
visitTerminalin interfaceParseTreeListener- Overrides:
visitTerminalin classio.github.douira.glsl_transformer.GLSLParserBaseListener
-
allowInexactMatches
public void allowInexactMatches()Makes this search phase not use exact matching. -
findNeedle
Checks if the given content contains a needle. This should be overwritten if the matching should be done differently, like using regex or case-insensitive matching.- Parameters:
content- The content to search intarget- The target being searched for- Returns:
- If the target was found in the content
-