Class SearchTerminalsImpl<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>
io.github.douira.glsl_transformer.core.SearchTerminalsImpl<T>
- All Implemented Interfaces:
io.github.douira.glsl_transformer.GLSLParserListener,LifecycleUser<T>,PartialParseTreeListener,ParseTreeListener
- Direct Known Subclasses:
SearchTerminalsDynamic
This implementation of the search terminals transformation phase uses static
fields to return the targets and the terminal token type.
-
Nested Class Summary
Nested classes/interfaces inherited from class io.github.douira.glsl_transformer.transform.TransformationPhase
TransformationPhase.InjectionPoint -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Collection<HandlerTarget<T>>The list of targets to process for each targeted context.Fields inherited from class io.github.douira.glsl_transformer.core.SearchTerminals
ANY_TYPE, IDENTIFIER -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new empty identifier search with a hash set.SearchTerminalsImpl(int terminalTokenType) Creates a new target search phase with only the terminal token type given.SearchTerminalsImpl(int terminalTokenType, HandlerTarget<T> target) Creates a new target search phase with only a single target.SearchTerminalsImpl(int terminalTokenType, Collection<HandlerTarget<T>> targets) Creates a new target search phase with the given targets.SearchTerminalsImpl(HandlerTarget<T> target) Creates a new identifier search phase with only a single target.SearchTerminalsImpl(Collection<HandlerTarget<T>> targets) Creates a new identifier search phase with with given targets. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddReplacement(String needle, String newContent, Function<io.github.douira.glsl_transformer.GLSLParser, ExtendedContext> parseMethod) Adds a replacement target that replaces matching terminal nodes with new nodes parsed from the given string using a specified parser method.voidaddReplacementExpression(String needle, String expressionContent) Adds a replacement target that replaces matching terminal nodes with new expression nodes parsed from the given string.voidaddReplacementTerminal(String needle, String terminalContent) Adds a replacement target that replaces matching terminal nodes with new unparsed string nodes.voidaddTarget(HandlerTarget<T> target) Adds a target for processing.Returns the collection of targets to search for.protected intReturns the terminal token type to match the target's needles against.voidsetTerminalTokenType(int terminalTokenType) Sets the terminal token type.static <T extends JobParameters>
SearchTerminals<T>withReplacement(String needle, String newContent, Function<io.github.douira.glsl_transformer.GLSLParser, ExtendedContext> parseMethod) Creates a new identifier replacement transformation with a replacement target that replaces matching terminal nodes with new nodes parsed from the given string using a specified parser method.static <T extends JobParameters>
SearchTerminals<T>withReplacementExpression(String needle, String expressionContent) Creates a new identifier replacement transformation with a replacement target that replaces matching terminal nodes with new expression nodes parsed from the given string.static <T extends JobParameters>
SearchTerminals<T>withReplacementTerminal(String needle, String terminalContent) Creates a new identifier replacement transformation with a replacement target that replaces matching terminal nodes with new unparsed string nodes.Methods inherited from class io.github.douira.glsl_transformer.core.SearchTerminals
allowInexactMatches, findNeedle, visitTerminalMethods 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
-
targets
The list of targets to process for each targeted context.
-
-
Constructor Details
-
SearchTerminalsImpl
Creates a new target search phase with the given targets.- Parameters:
terminalTokenType- The type of the tokens to search intargets- The targets to search for
-
SearchTerminalsImpl
Creates a new target search phase with only a single target.- Parameters:
terminalTokenType- The type of the token to search intarget- The target to search for
-
SearchTerminalsImpl
public SearchTerminalsImpl(int terminalTokenType) Creates a new target search phase with only the terminal token type given.- Parameters:
terminalTokenType- The type of the token to search in
-
SearchTerminalsImpl
Creates a new identifier search phase with with given targets.- Parameters:
targets- The targets to search for in identifiers
-
SearchTerminalsImpl
Creates a new identifier search phase with only a single target.- Parameters:
target- The target to search for in identifiers
-
SearchTerminalsImpl
public SearchTerminalsImpl()Creates a new empty identifier search with a hash set.
-
-
Method Details
-
getTargets
Description copied from class:SearchTerminalsReturns the collection of targets to search for. This method should be efficient as it's called for every visited terminal node.- Specified by:
getTargetsin classSearchTerminals<T extends JobParameters>- Returns:
- The targets to search for
-
getTerminalTokenType
protected int getTerminalTokenType()Description copied from class:SearchTerminalsReturns the terminal token type to match the target's needles against. The available tokens are staticintfields onGLSLLexer.- Overrides:
getTerminalTokenTypein classSearchTerminals<T extends JobParameters>- Returns:
- The terminal token type
-
setTerminalTokenType
public void setTerminalTokenType(int terminalTokenType) Sets the terminal token type. UseSearchTerminals.IDENTIFIERto search for identifiers.- Parameters:
terminalTokenType- The terminal token type
-
addTarget
Adds a target for processing.- Parameters:
target- The target to add to the collection of targets
-
addReplacement
public void addReplacement(String needle, String newContent, Function<io.github.douira.glsl_transformer.GLSLParser, ExtendedContext> parseMethod) Adds a replacement target that replaces matching terminal nodes with new nodes parsed from the given string using a specified parser method.- Parameters:
needle- The needle (search string)newContent- The new content to parse into a nodeparseMethod- The parser method to create the new node with
-
addReplacementExpression
Adds a replacement target that replaces matching terminal nodes with new expression nodes parsed from the given string.- Parameters:
needle- The needle (search string)expressionContent- The new content to parse into an expression
-
addReplacementTerminal
Adds a replacement target that replaces matching terminal nodes with new unparsed string nodes.- Parameters:
needle- The needle (search string)terminalContent- The new terminal content to insert as a string node
-
withReplacement
public static <T extends JobParameters> SearchTerminals<T> withReplacement(String needle, String newContent, Function<io.github.douira.glsl_transformer.GLSLParser, ExtendedContext> parseMethod) Creates a new identifier replacement transformation with a replacement target that replaces matching terminal nodes with new nodes parsed from the given string using a specified parser method.- Type Parameters:
T- The job parameter type- Parameters:
needle- The needle (search string)newContent- The new content to parse into a nodeparseMethod- The parser method to create the new node with- Returns:
- The configured identifier replacement transformation
- See Also:
-
withReplacementExpression
public static <T extends JobParameters> SearchTerminals<T> withReplacementExpression(String needle, String expressionContent) Creates a new identifier replacement transformation with a replacement target that replaces matching terminal nodes with new expression nodes parsed from the given string.- Type Parameters:
T- The job parameter type- Parameters:
needle- The needle (search string)expressionContent- The new content to parse into an expression- Returns:
- The configured identifier replacement transformation
-
withReplacementTerminal
public static <T extends JobParameters> SearchTerminals<T> withReplacementTerminal(String needle, String terminalContent) Creates a new identifier replacement transformation with a replacement target that replaces matching terminal nodes with new unparsed string nodes.- Type Parameters:
T- The job parameter type- Parameters:
needle- The needle (search string)terminalContent- The new terminal content to insert as a string node- Returns:
- The configured identifier replacement transformation
-