Class ReplaceTarget<T extends JobParameters>

All Implemented Interfaces:
io.github.douira.glsl_transformer.GLSLParserListener, LifecycleUser<T>, PartialParseTreeListener, ParseTreeListener
Direct Known Subclasses:
TerminalReplaceTarget

public abstract class ReplaceTarget<T extends JobParameters> extends HandlerTargetImpl<T>
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

    Constructors
    Modifier
    Constructor
    Description
    protected
    Creates a new replace target with no search string.
     
    Creates a new replace target with a given search string
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract TreeMember
    Returns the node to insert replacing the node found with the search string.
    void
    Handles the containing node and token that the string was found in.

    Methods inherited from class io.github.douira.glsl_transformer.core.target.HandlerTargetImpl

    getNeedle

    Methods inherited from class io.github.douira.glsl_transformer.core.target.HandlerTarget

    canWalk, setPlanner

    Methods 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, visitTerminal

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.github.douira.glsl_transformer.transform.LifecycleUser

    getJobParameters, getLexer, getParser, getRootNode, init, initOnce, resetState

    Methods inherited from interface org.antlr.v4.runtime.tree.ParseTreeListener

    enterEveryRule, exitEveryRule, visitErrorNode, visitTerminal

    Methods inherited from interface io.github.douira.glsl_transformer.traversal.PartialParseTreeListener

    isDeepEnough, isFinished
  • Constructor Details

    • ReplaceTarget

      public ReplaceTarget(String needle)
      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. The HandlerTargetImpl.getNeedle() method should be overwritten if this constructor is used.
      See Also:
  • Method Details

    • getReplacement

      protected abstract TreeMember getReplacement(TreeMember node, String match)
      Returns the node to insert replacing the node found with the search string. The replacement can be cancelled by returning null.
      Parameters:
      node - The node found to contain the search string
      match - The entire content of the node that matches the search string
      Returns:
      The new node to replace the found node with
    • handleResult

      public void handleResult(TreeMember node, String match)
      Description copied from class: HandlerTarget
      Handles the containing node and token that the string was found in.
      Specified by:
      handleResult in class HandlerTarget<T extends JobParameters>
      Parameters:
      node - The node that contains the token
      match - The token text that contains the needle