Class ReplaceTarget<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.core.target.HandlerTarget<T>
io.github.douira.glsl_transformer.core.target.HandlerTargetImpl<T>
io.github.douira.glsl_transformer.core.target.ReplaceTarget<T>
- All Implemented Interfaces:
io.github.douira.glsl_transformer.GLSLParserListener,LifecycleUser<T>,PartialParseTreeListener,ParseTreeListener
- Direct Known Subclasses:
TerminalReplaceTarget
A replacement target searches for a search string and uses a method to
generate a tree member to replace it in the tree. If something more
than node replacement should be done, implement a custom
HandlerTargetImpl subclass.-
Nested Class Summary
Nested classes/interfaces inherited from class io.github.douira.glsl_transformer.transform.TransformationPhase
TransformationPhase.InjectionPoint -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a new replace target with no search string.ReplaceTarget(String needle) Creates a new replace target with a given search string -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract TreeMembergetReplacement(TreeMember node, String match) Returns the node to insert replacing the node found with the search string.voidhandleResult(TreeMember node, String match) Handles the containing node and token that the string was found in.Methods inherited from class io.github.douira.glsl_transformer.core.target.HandlerTargetImpl
getNeedleMethods inherited from class io.github.douira.glsl_transformer.core.target.HandlerTarget
canWalk, setPlannerMethods inherited from class io.github.douira.glsl_transformer.transform.TransformationPhase
checkBeforeWalk, compilePath, compilePattern, createLocalRoot, findAndMatch, getPlanner, getSiblings, injectDefine, injectExternalDeclaration, injectExternalDeclarations, injectNode, injectNodes, injectNodes, isActive, isInitialized, removeNode, replaceNode, replaceNode, runAfterWalk, setInitialized, 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, visitErrorNode, visitTerminalMethods 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, visitErrorNode, visitTerminalMethods inherited from interface io.github.douira.glsl_transformer.traversal.PartialParseTreeListener
isDeepEnough, isFinished
-
Constructor Details
-
ReplaceTarget
Creates a new replace target with a given search string- Parameters:
needle- The search string
-
ReplaceTarget
protected ReplaceTarget()Creates a new replace target with no search string. TheHandlerTargetImpl.getNeedle()method should be overwritten if this constructor is used.- See Also:
-
-
Method Details
-
getReplacement
Returns the node to insert replacing the node found with the search string. The replacement can be cancelled by returningnull.- Parameters:
node- The node found to contain the search stringmatch- The entire content of the node that matches the search string- Returns:
- The new node to replace the found node with
-
handleResult
Description copied from class:HandlerTargetHandles the containing node and token that the string was found in.- Specified by:
handleResultin classHandlerTarget<T extends JobParameters>- Parameters:
node- The node that contains the tokenmatch- The token text that contains the needle
-