Class ExtendedContext

java.lang.Object
org.antlr.v4.runtime.RuleContext
org.antlr.v4.runtime.ParserRuleContext
io.github.douira.glsl_transformer.generic.ExtendedContext
All Implemented Interfaces:
org.antlr.v4.runtime.tree.ParseTree, org.antlr.v4.runtime.tree.RuleNode, org.antlr.v4.runtime.tree.SyntaxTree, org.antlr.v4.runtime.tree.Tree
Direct Known Subclasses:
GLSLParser.AdditiveExpressionContext, GLSLParser.AndExpressionContext, GLSLParser.ArraySpecifierContext, GLSLParser.AssignmentExpressionContext, GLSLParser.AssignmentOperatorContext, GLSLParser.AttributeContext, GLSLParser.BuiltinTypeSpecifierFixedContext, GLSLParser.BuiltinTypeSpecifierParseableContext, GLSLParser.CallParameterListContext, GLSLParser.CaseLabelContext, GLSLParser.CompoundStatementContext, GLSLParser.ConditionalExpressionContext, GLSLParser.ConditionContext, GLSLParser.ConstantExpressionContext, GLSLParser.DeclarationContext, GLSLParser.DeclarationMemberContext, GLSLParser.DeclarationMemberListContext, GLSLParser.DeclarationStatementContext, GLSLParser.DemoteStatementContext, GLSLParser.DoWhileStatementContext, GLSLParser.EmptyStatementContext, GLSLParser.EqualityExpressionContext, GLSLParser.ExclusiveOrExpressionContext, GLSLParser.ExpressionContext, GLSLParser.ExpressionStatementContext, GLSLParser.ExtensionStateContext, GLSLParser.ExtensionStatementContext, GLSLParser.ExternalDeclarationContext, GLSLParser.ForStatementContext, GLSLParser.FullySpecifiedTypeContext, GLSLParser.FunctionCallContext, GLSLParser.FunctionDefinitionContext, GLSLParser.FunctionHeaderContext, GLSLParser.FunctionIdentifierContext, GLSLParser.FunctionParameterListContext, GLSLParser.FunctionPrototypeContext, GLSLParser.InclusiveOrExpressionContext, GLSLParser.InitDeclaratorListContext, GLSLParser.InitializerContext, GLSLParser.InterpolationQualifierContext, GLSLParser.InvariantQualifierContext, GLSLParser.JumpStatementContext, GLSLParser.LayoutDefaultsContext, GLSLParser.LayoutModesContext, GLSLParser.LayoutQualifierContext, GLSLParser.LayoutQualifierIdContext, GLSLParser.LogicalAndExpressionContext, GLSLParser.LogicalOrExpressionContext, GLSLParser.LogicalXorExpressionContext, GLSLParser.MethodCallContext, GLSLParser.MultiplicativeExpressionContext, GLSLParser.ParameterDeclarationContext, GLSLParser.ParameterDeclaratorContext, GLSLParser.PostfixExpressionContext, GLSLParser.PragmaStatementContext, GLSLParser.PreciseQualifierContext, GLSLParser.PrecisionQualifierContext, GLSLParser.PrimaryExpressionContext, GLSLParser.RelationalExpressionContext, GLSLParser.SelectionStatementContext, GLSLParser.ShiftExpressionContext, GLSLParser.SimpleStatementContext, GLSLParser.SingleAttributeContext, GLSLParser.StatementContext, GLSLParser.StorageQualifierContext, GLSLParser.StructDeclarationContext, GLSLParser.StructDeclarationListContext, GLSLParser.StructDeclaratorContext, GLSLParser.StructDeclaratorListContext, GLSLParser.StructSpecifierContext, GLSLParser.SwitchStatementContext, GLSLParser.TranslationUnitContext, GLSLParser.TypeNameListContext, GLSLParser.TypeQualifierContext, GLSLParser.TypeSpecifierContext, GLSLParser.TypeSpecifierNonarrayContext, GLSLParser.UnaryExpressionContext, GLSLParser.UnaryOperatorContext, GLSLParser.VariableIdentifierContext, GLSLParser.VersionStatementContext, GLSLParser.WhileStatementContext

public class ExtendedContext extends org.antlr.v4.runtime.ParserRuleContext
Implements custom behavior in parse rule contexts. This class is used as the super class for all contexts in the parser. This class is not meant to be constructed manually but is the base class which ANTLR extends in the generated parser code. The token indexes of the token intervals of new nodes have nothing to do with the token indexes of existing nodes. Therefore, new nodes are registered as local roots that have their own token index domain and a set of intervals in which non-hidden tokens should not be printed. Local root nodes store information about which nodes in their subtree have been removed. The printer then uses this to not print any non-hidden tokens contained within any local root's omission set.
  • Field Summary

    Fields inherited from class org.antlr.v4.runtime.ParserRuleContext

    children, exception, start, stop

    Fields inherited from class org.antlr.v4.runtime.RuleContext

    EMPTY, invokingState, parent
  • Constructor Summary

    Constructors
    Constructor
    Description
    ExtendedContext(org.antlr.v4.runtime.ParserRuleContext parent, int invokingStateNumber)
    Creates a new extended parser rule context.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addChild(int index, org.antlr.v4.runtime.tree.ParseTree node)
    Adds a child to the list of children with at the given index.
    void
    Marks editing on the whole tree as finished.
    int
    getChildIndexLike(Class<? extends org.antlr.v4.runtime.tree.ParseTree> ctxType)
    Finds the index of the first contained child that matches the given type.
    org.antlr.v4.runtime.misc.Interval
    Gets the source interval for this local root that includes the whole token stream with unparsed tokens before and after the parsed tokens that this node encompasses.
    org.antlr.v4.runtime.misc.Interval
    Gets the source interval for this node that covers the largest space.
    The omission set is present if this node is a local root.
    Override to make type more specific
    org.antlr.v4.runtime.BufferedTokenStream
    The token stream is present if this node is a local root.
    boolean
    Checks if this node is a local root.
    boolean
    Checks if this node is the global root.
    void
    makeLocalRoot(org.antlr.v4.runtime.BufferedTokenStream tokenStream)
    Registers this node as a new local root node together with its corresponding token stream.
    void
    Marks the tokens encompassed by this node as omitted.
    void
    Sets the parent and copies the root reference from the parent.

    Methods inherited from class org.antlr.v4.runtime.ParserRuleContext

    addAnyChild, addChild, addChild, addChild, addErrorNode, addErrorNode, copyFrom, enterRule, exitRule, getChild, getChild, getChildCount, getRuleContext, getRuleContexts, getSourceInterval, getStart, getStop, getToken, getTokens, removeLastChild, toInfoString

    Methods inherited from class org.antlr.v4.runtime.RuleContext

    accept, depth, getAltNumber, getPayload, getRuleContext, getRuleIndex, getText, isEmpty, setAltNumber, setParent, toString, toString, toString, toString, toString, toStringTree, toStringTree, toStringTree

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ExtendedContext

      public ExtendedContext(org.antlr.v4.runtime.ParserRuleContext parent, int invokingStateNumber)
      Creates a new extended parser rule context. This is required for the generated parse code to be valid.
      Parameters:
      parent - The parent node
      invokingStateNumber - The invoking state number
  • Method Details

    • getParent

      public ExtendedContext getParent()
      Override to make type more specific
      Specified by:
      getParent in interface org.antlr.v4.runtime.tree.ParseTree
      Specified by:
      getParent in interface org.antlr.v4.runtime.tree.Tree
      Overrides:
      getParent in class org.antlr.v4.runtime.ParserRuleContext
    • setParent

      public void setParent(ExtendedContext parent)
      Sets the parent and copies the root reference from the parent. This requires the parent to have been set up before the child.
      Parameters:
      parent - The paren to set on this node
    • makeLocalRoot

      public void makeLocalRoot(org.antlr.v4.runtime.BufferedTokenStream tokenStream)
      Registers this node as a new local root node together with its corresponding token stream. This means it has its own omission set and token interval space. The token interval of omitted nodes are added to the omission set of the closest local root ancestor.
      Parameters:
      tokenStream - The token stream from which this node was parsed
    • isLocalRoot

      public boolean isLocalRoot()
      Checks if this node is a local root.
      Returns:
      true if the node is a local root
    • isRoot

      public boolean isRoot()
      Checks if this node is the global root.
      Returns:
      true if this node is the global root
      Implementation Note:
      This is faster to check than finding the local root, taking it's root and checking if it's the same.
    • omitTokens

      public void omitTokens()
      Marks the tokens encompassed by this node as omitted. Non-hidden tokens will not be printed if they are withing the token source token interval of this node. Other nodes will however, still be printed in order to preserve whitespace.
    • finishEditingTree

      public void finishEditingTree()
      Marks editing on the whole tree as finished. This modifies the root node's readonly state. After this point no further modifications should be made.
    • getOmissionSet

      public CachingIntervalSet getOmissionSet()
      The omission set is present if this node is a local root. Then it contains the token intervals that should be omitted by the printer when printing this local root's subtree. The omission set is set to be readonly if the tree has been set to readonly.
      Returns:
      This local root's token stream if this node is a local root, null otherwise
    • getTokenStream

      public org.antlr.v4.runtime.BufferedTokenStream getTokenStream()
      The token stream is present if this node is a local root. Then it's the token stream that was used to construct this local root's subtree.
      Returns:
      The token stream for this local root if this node is a local root, null otherwise
    • getFullSourceInterval

      public org.antlr.v4.runtime.misc.Interval getFullSourceInterval()
      Gets the source interval for this local root that includes the whole token stream with unparsed tokens before and after the parsed tokens that this node encompasses.
      Returns:
      The full source interval of the contained token stream if this node is a local root, null otherwise.
    • getLargestSourceInterval

      public org.antlr.v4.runtime.misc.Interval getLargestSourceInterval()
      Gets the source interval for this node that covers the largest space. For local roots this is the full source interval covering all tokens in the token stream. For all other nodes it's the regular source interval covering only the tokens parsed for this node.
      Returns:
      The largest source interval, never null.
    • getChildIndexLike

      public int getChildIndexLike(Class<? extends org.antlr.v4.runtime.tree.ParseTree> ctxType)
      Finds the index of the first contained child that matches the given type.
      Parameters:
      ctxType - The child type to look for
      Returns:
      The index of the first child with the given index. If no child with that type was found, the length of the child array is returned as the "last" index.
    • addChild

      public void addChild(int index, org.antlr.v4.runtime.tree.ParseTree node)
      Adds a child to the list of children with at the given index.
      Parameters:
      index - The index to add the node at
      node - The node to add