Class EnclosingOperation

java.lang.Object
org.ek9lang.compiler.support.EnclosingOperation
All Implemented Interfaces:
Function<org.antlr.v4.runtime.tree.ParseTree, Optional<org.antlr.v4.runtime.ParserRuleContext>>

public final class EnclosingOperation extends Object implements Function<org.antlr.v4.runtime.tree.ParseTree, Optional<org.antlr.v4.runtime.ParserRuleContext>>
THE "which method or operator is this node directly in?" - the declaration whose code runs when this node runs.

The walk stops, with nothing, at the two places where code runs LATER than the construction or close that contains it: a dynamic function's body and an aggregate's parts (a dynamic class's methods). There this is another object or the construction is over, so the enclosing constructor or close operator is not the one that matters. The constructor rules (EnclosingConstructor) and the close-operator rules (ObjectUsedBeforeConstructedOrError) each had this loop, one stopping at a method and one at an operator (front-end rationalisation C-11); they ask here and apply their own kind test to the declaration.

  • Constructor Details

    • EnclosingOperation

      public EnclosingOperation()
  • Method Details

    • apply

      public Optional<org.antlr.v4.runtime.ParserRuleContext> apply(org.antlr.v4.runtime.tree.ParseTree node)
      The nearest MethodDeclarationContext or OperatorDeclarationContext above the node, or empty when the node is in neither - or in code that runs later (see the class description).
      Specified by:
      apply in interface Function<org.antlr.v4.runtime.tree.ParseTree, Optional<org.antlr.v4.runtime.ParserRuleContext>>