All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.extendj.ast.AmbiguousMethodReference Maven / Gradle / Ivy

/* This file was generated with JastAdd2 (http://jastadd.org) version 2.3.0 */
package org.extendj.ast;
import java.util.ArrayList;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.IOException;
import java.util.Set;
import beaver.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.LinkedHashSet;
import java.util.*;
import org.jastadd.util.PrettyPrintable;
import org.jastadd.util.PrettyPrinter;
import java.util.zip.*;
import java.io.*;
import org.jastadd.util.*;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
/**
 * @ast node
 * @declaredat /home/jesper/git/extendj/java8/grammar/MethodReference.ast:5
 * @astdecl AmbiguousMethodReference : MethodReference ::= AmbiguousName:Access;
 * @production AmbiguousMethodReference : {@link MethodReference} ::= AmbiguousName:{@link Access};

 */
public class AmbiguousMethodReference extends MethodReference implements Cloneable {
  /**
   * @declaredat ASTNode:1
   */
  public AmbiguousMethodReference() {
    super();
  }
  /**
   * Initializes the child array to the correct size.
   * Initializes List and Opt nta children.
   * @apilevel internal
   * @ast method
   * @declaredat ASTNode:10
   */
  public void init$Children() {
    children = new ASTNode[2];
    setChild(new List(), 0);
  }
  /**
   * @declaredat ASTNode:14
   */
  @ASTNodeAnnotation.Constructor(
    name = {"TypeArgument", "ID", "AmbiguousName"},
    type = {"List", "String", "Access"},
    kind = {"List", "Token", "Child"}
  )
  public AmbiguousMethodReference(List p0, String p1, Access p2) {
    setChild(p0, 0);
    setID(p1);
    setChild(p2, 1);
  }
  /**
   * @declaredat ASTNode:24
   */
  public AmbiguousMethodReference(List p0, beaver.Symbol p1, Access p2) {
    setChild(p0, 0);
    setID(p1);
    setChild(p2, 1);
  }
  /** @apilevel low-level 
   * @declaredat ASTNode:30
   */
  protected int numChildren() {
    return 2;
  }
  /**
   * @apilevel internal
   * @declaredat ASTNode:36
   */
  public boolean mayHaveRewrite() {
    return true;
  }
  /** @apilevel internal 
   * @declaredat ASTNode:40
   */
  public void flushAttrCache() {
    super.flushAttrCache();
    rewrittenNode_reset();
    congruentTo_FunctionDescriptor_reset();
    potentiallyApplicableMethods_FunctionDescriptor_reset();
    exactCompileTimeDeclaration_reset();
  }
  /** @apilevel internal 
   * @declaredat ASTNode:48
   */
  public void flushCollectionCache() {
    super.flushCollectionCache();
  }
  /** @apilevel internal 
   * @declaredat ASTNode:52
   */
  public AmbiguousMethodReference clone() throws CloneNotSupportedException {
    AmbiguousMethodReference node = (AmbiguousMethodReference) super.clone();
    return node;
  }
  /** @apilevel internal 
   * @declaredat ASTNode:57
   */
  public AmbiguousMethodReference copy() {
    try {
      AmbiguousMethodReference node = (AmbiguousMethodReference) clone();
      node.parent = null;
      if (children != null) {
        node.children = (ASTNode[]) children.clone();
      }
      return node;
    } catch (CloneNotSupportedException e) {
      throw new Error("Error: clone not supported for " + getClass().getName());
    }
  }
  /**
   * Create a deep copy of the AST subtree at this node.
   * The copy is dangling, i.e. has no parent.
   * @return dangling copy of the subtree at this node
   * @apilevel low-level
   * @deprecated Please use treeCopy or treeCopyNoTransform instead
   * @declaredat ASTNode:76
   */
  @Deprecated
  public AmbiguousMethodReference fullCopy() {
    return treeCopyNoTransform();
  }
  /**
   * Create a deep copy of the AST subtree at this node.
   * The copy is dangling, i.e. has no parent.
   * @return dangling copy of the subtree at this node
   * @apilevel low-level
   * @declaredat ASTNode:86
   */
  public AmbiguousMethodReference treeCopyNoTransform() {
    AmbiguousMethodReference tree = (AmbiguousMethodReference) copy();
    if (children != null) {
      for (int i = 0; i < children.length; ++i) {
        ASTNode child = (ASTNode) children[i];
        if (child != null) {
          child = child.treeCopyNoTransform();
          tree.setChild(child, i);
        }
      }
    }
    return tree;
  }
  /**
   * Create a deep copy of the AST subtree at this node.
   * The subtree of this node is traversed to trigger rewrites before copy.
   * The copy is dangling, i.e. has no parent.
   * @return dangling copy of the subtree at this node
   * @apilevel low-level
   * @declaredat ASTNode:106
   */
  public AmbiguousMethodReference treeCopy() {
    AmbiguousMethodReference tree = (AmbiguousMethodReference) copy();
    if (children != null) {
      for (int i = 0; i < children.length; ++i) {
        ASTNode child = (ASTNode) getChild(i);
        if (child != null) {
          child = child.treeCopy();
          tree.setChild(child, i);
        }
      }
    }
    return tree;
  }
  /** @apilevel internal 
   * @declaredat ASTNode:120
   */
  protected boolean is$Equal(ASTNode node) {
    return super.is$Equal(node) && (tokenString_ID == ((AmbiguousMethodReference) node).tokenString_ID);    
  }
  /**
   * Replaces the TypeArgument list.
   * @param list The new list node to be used as the TypeArgument list.
   * @apilevel high-level
   */
  public void setTypeArgumentList(List list) {
    setChild(list, 0);
  }
  /**
   * Retrieves the number of children in the TypeArgument list.
   * @return Number of children in the TypeArgument list.
   * @apilevel high-level
   */
  public int getNumTypeArgument() {
    return getTypeArgumentList().getNumChild();
  }
  /**
   * Retrieves the number of children in the TypeArgument list.
   * Calling this method will not trigger rewrites.
   * @return Number of children in the TypeArgument list.
   * @apilevel low-level
   */
  public int getNumTypeArgumentNoTransform() {
    return getTypeArgumentListNoTransform().getNumChildNoTransform();
  }
  /**
   * Retrieves the element at index {@code i} in the TypeArgument list.
   * @param i Index of the element to return.
   * @return The element at position {@code i} in the TypeArgument list.
   * @apilevel high-level
   */
  public Access getTypeArgument(int i) {
    return (Access) getTypeArgumentList().getChild(i);
  }
  /**
   * Check whether the TypeArgument list has any children.
   * @return {@code true} if it has at least one child, {@code false} otherwise.
   * @apilevel high-level
   */
  public boolean hasTypeArgument() {
    return getTypeArgumentList().getNumChild() != 0;
  }
  /**
   * Append an element to the TypeArgument list.
   * @param node The element to append to the TypeArgument list.
   * @apilevel high-level
   */
  public void addTypeArgument(Access node) {
    List list = (parent == null) ? getTypeArgumentListNoTransform() : getTypeArgumentList();
    list.addChild(node);
  }
  /** @apilevel low-level 
   */
  public void addTypeArgumentNoTransform(Access node) {
    List list = getTypeArgumentListNoTransform();
    list.addChild(node);
  }
  /**
   * Replaces the TypeArgument list element at index {@code i} with the new node {@code node}.
   * @param node The new node to replace the old list element.
   * @param i The list index of the node to be replaced.
   * @apilevel high-level
   */
  public void setTypeArgument(Access node, int i) {
    List list = getTypeArgumentList();
    list.setChild(node, i);
  }
  /**
   * Retrieves the TypeArgument list.
   * @return The node representing the TypeArgument list.
   * @apilevel high-level
   */
  @ASTNodeAnnotation.ListChild(name="TypeArgument")
  public List getTypeArgumentList() {
    List list = (List) getChild(0);
    return list;
  }
  /**
   * Retrieves the TypeArgument list.
   * 

This method does not invoke AST transformations.

* @return The node representing the TypeArgument list. * @apilevel low-level */ public List getTypeArgumentListNoTransform() { return (List) getChildNoTransform(0); } /** * @return the element at index {@code i} in the TypeArgument list without * triggering rewrites. */ public Access getTypeArgumentNoTransform(int i) { return (Access) getTypeArgumentListNoTransform().getChildNoTransform(i); } /** * Retrieves the TypeArgument list. * @return The node representing the TypeArgument list. * @apilevel high-level */ public List getTypeArguments() { return getTypeArgumentList(); } /** * Retrieves the TypeArgument list. *

This method does not invoke AST transformations.

* @return The node representing the TypeArgument list. * @apilevel low-level */ public List getTypeArgumentsNoTransform() { return getTypeArgumentListNoTransform(); } /** * Replaces the lexeme ID. * @param value The new value for the lexeme ID. * @apilevel high-level */ public void setID(String value) { tokenString_ID = value; } /** * JastAdd-internal setter for lexeme ID using the Beaver parser. * @param symbol Symbol containing the new value for the lexeme ID * @apilevel internal */ public void setID(beaver.Symbol symbol) { if (symbol.value != null && !(symbol.value instanceof String)) throw new UnsupportedOperationException("setID is only valid for String lexemes"); tokenString_ID = (String)symbol.value; IDstart = symbol.getStart(); IDend = symbol.getEnd(); } /** * Retrieves the value for the lexeme ID. * @return The value for the lexeme ID. * @apilevel high-level */ @ASTNodeAnnotation.Token(name="ID") public String getID() { return tokenString_ID != null ? tokenString_ID : ""; } /** * Replaces the AmbiguousName child. * @param node The new node to replace the AmbiguousName child. * @apilevel high-level */ public void setAmbiguousName(Access node) { setChild(node, 1); } /** * Retrieves the AmbiguousName child. * @return The current node used as the AmbiguousName child. * @apilevel high-level */ @ASTNodeAnnotation.Child(name="AmbiguousName") public Access getAmbiguousName() { return (Access) getChild(1); } /** * Retrieves the AmbiguousName child. *

This method does not invoke AST transformations.

* @return The current node used as the AmbiguousName child. * @apilevel low-level */ public Access getAmbiguousNameNoTransform() { return (Access) getChildNoTransform(1); } /** @apilevel internal */ private void congruentTo_FunctionDescriptor_reset() { congruentTo_FunctionDescriptor_computed = null; congruentTo_FunctionDescriptor_values = null; } /** @apilevel internal */ protected java.util.Map congruentTo_FunctionDescriptor_values; /** @apilevel internal */ protected java.util.Map congruentTo_FunctionDescriptor_computed; /** * @attribute syn * @aspect MethodReference * @declaredat /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:239 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="MethodReference", declaredAt="/home/jesper/git/extendj/java8/frontend/MethodReference.jrag:239") public boolean congruentTo(FunctionDescriptor fd) { Object _parameters = fd; if (congruentTo_FunctionDescriptor_computed == null) congruentTo_FunctionDescriptor_computed = new java.util.HashMap(4); if (congruentTo_FunctionDescriptor_values == null) congruentTo_FunctionDescriptor_values = new java.util.HashMap(4); ASTState state = state(); if (congruentTo_FunctionDescriptor_values.containsKey(_parameters) && congruentTo_FunctionDescriptor_computed.containsKey(_parameters) && (congruentTo_FunctionDescriptor_computed.get(_parameters) == ASTState.NON_CYCLE || congruentTo_FunctionDescriptor_computed.get(_parameters) == state().cycle())) { return (Boolean) congruentTo_FunctionDescriptor_values.get(_parameters); } boolean congruentTo_FunctionDescriptor_value = false; if (state().inCircle()) { congruentTo_FunctionDescriptor_values.put(_parameters, congruentTo_FunctionDescriptor_value); congruentTo_FunctionDescriptor_computed.put(_parameters, state().cycle()); } else { congruentTo_FunctionDescriptor_values.put(_parameters, congruentTo_FunctionDescriptor_value); congruentTo_FunctionDescriptor_computed.put(_parameters, ASTState.NON_CYCLE); } return congruentTo_FunctionDescriptor_value; } /** @apilevel internal */ private void potentiallyApplicableMethods_FunctionDescriptor_reset() { potentiallyApplicableMethods_FunctionDescriptor_computed = null; potentiallyApplicableMethods_FunctionDescriptor_values = null; } /** @apilevel internal */ protected java.util.Map potentiallyApplicableMethods_FunctionDescriptor_values; /** @apilevel internal */ protected java.util.Map potentiallyApplicableMethods_FunctionDescriptor_computed; /** * @attribute syn * @aspect MethodReference * @declaredat /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:292 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="MethodReference", declaredAt="/home/jesper/git/extendj/java8/frontend/MethodReference.jrag:292") public java.util.List potentiallyApplicableMethods(FunctionDescriptor fd) { Object _parameters = fd; if (potentiallyApplicableMethods_FunctionDescriptor_computed == null) potentiallyApplicableMethods_FunctionDescriptor_computed = new java.util.HashMap(4); if (potentiallyApplicableMethods_FunctionDescriptor_values == null) potentiallyApplicableMethods_FunctionDescriptor_values = new java.util.HashMap(4); ASTState state = state(); if (potentiallyApplicableMethods_FunctionDescriptor_values.containsKey(_parameters) && potentiallyApplicableMethods_FunctionDescriptor_computed.containsKey(_parameters) && (potentiallyApplicableMethods_FunctionDescriptor_computed.get(_parameters) == ASTState.NON_CYCLE || potentiallyApplicableMethods_FunctionDescriptor_computed.get(_parameters) == state().cycle())) { return (java.util.List) potentiallyApplicableMethods_FunctionDescriptor_values.get(_parameters); } java.util.List potentiallyApplicableMethods_FunctionDescriptor_value = Collections.emptyList(); if (state().inCircle()) { potentiallyApplicableMethods_FunctionDescriptor_values.put(_parameters, potentiallyApplicableMethods_FunctionDescriptor_value); potentiallyApplicableMethods_FunctionDescriptor_computed.put(_parameters, state().cycle()); } else { potentiallyApplicableMethods_FunctionDescriptor_values.put(_parameters, potentiallyApplicableMethods_FunctionDescriptor_value); potentiallyApplicableMethods_FunctionDescriptor_computed.put(_parameters, ASTState.NON_CYCLE); } return potentiallyApplicableMethods_FunctionDescriptor_value; } /** @apilevel internal */ private void exactCompileTimeDeclaration_reset() { exactCompileTimeDeclaration_computed = null; exactCompileTimeDeclaration_value = null; } /** @apilevel internal */ protected ASTState.Cycle exactCompileTimeDeclaration_computed = null; /** @apilevel internal */ protected MethodDecl exactCompileTimeDeclaration_value; /** * @attribute syn * @aspect MethodReference * @declaredat /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:360 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="MethodReference", declaredAt="/home/jesper/git/extendj/java8/frontend/MethodReference.jrag:360") public MethodDecl exactCompileTimeDeclaration() { ASTState state = state(); if (exactCompileTimeDeclaration_computed == ASTState.NON_CYCLE || exactCompileTimeDeclaration_computed == state().cycle()) { return exactCompileTimeDeclaration_value; } exactCompileTimeDeclaration_value = unknownMethod(); if (state().inCircle()) { exactCompileTimeDeclaration_computed = state().cycle(); } else { exactCompileTimeDeclaration_computed = ASTState.NON_CYCLE; } return exactCompileTimeDeclaration_value; } /** * @declaredat /home/jesper/git/extendj/java4/frontend/SyntacticClassification.jrag:36 * @apilevel internal */ public NameType Define_nameType(ASTNode _callerNode, ASTNode _childNode) { if (getAmbiguousNameNoTransform() != null && _callerNode == getAmbiguousName()) { // @declaredat /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:217 return NameType.AMBIGUOUS_NAME; } else { return super.Define_nameType(_callerNode, _childNode); } } /** * @declaredat /home/jesper/git/extendj/java4/frontend/SyntacticClassification.jrag:36 * @apilevel internal * @return {@code true} if this node has an equation for the inherited attribute nameType */ protected boolean canDefine_nameType(ASTNode _callerNode, ASTNode _childNode) { return true; } /** @apilevel internal */ public ASTNode rewriteTo() { // Declared at /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:220 if (!getAmbiguousName().isTypeAccess()) { return rewriteRule0(); } // Declared at /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:230 if (getAmbiguousName().isTypeAccess()) { return rewriteRule1(); } return super.rewriteTo(); } /** * @declaredat /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:220 * @apilevel internal */ private ExprMethodReference rewriteRule0() { { return new ExprMethodReference( (List) getTypeArgumentList().treeCopy(), getID(), (Access) getAmbiguousName().treeCopy()); } } /** * @declaredat /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:230 * @apilevel internal */ private TypeMethodReference rewriteRule1() { { return new TypeMethodReference( (List) getTypeArgumentList(), getID(), (Access) getAmbiguousName()); } } /** @apilevel internal */ public boolean canRewrite() { // Declared at /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:220 if (!getAmbiguousName().isTypeAccess()) { return true; } // Declared at /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:230 if (getAmbiguousName().isTypeAccess()) { return true; } return false; } /** @apilevel internal */ private void rewrittenNode_reset() { rewrittenNode_computed = false; rewrittenNode_initialized = false; rewrittenNode_value = null; rewrittenNode_cycle = null; } /** @apilevel internal */ protected ASTState.Cycle rewrittenNode_cycle = null; /** @apilevel internal */ protected boolean rewrittenNode_computed = false; /** @apilevel internal */ protected ASTNode rewrittenNode_value; /** @apilevel internal */ protected boolean rewrittenNode_initialized = false; @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN, isCircular=true, isNTA=true) @ASTNodeAnnotation.Source(aspect="", declaredAt=":0") public ASTNode rewrittenNode() { if (rewrittenNode_computed) { return rewrittenNode_value; } ASTState state = state(); if (!rewrittenNode_initialized) { rewrittenNode_initialized = true; rewrittenNode_value = this; if (rewrittenNode_value != null) { rewrittenNode_value.setParent(getParent()); } } if (!state.inCircle() || state.calledByLazyAttribute()) { state.enterCircle(); do { rewrittenNode_cycle = state.nextCycle(); ASTNode new_rewrittenNode_value = rewrittenNode_value.rewriteTo(); if (new_rewrittenNode_value != rewrittenNode_value || new_rewrittenNode_value.canRewrite()) { state.setChangeInCycle(); } rewrittenNode_value = new_rewrittenNode_value; if (rewrittenNode_value != null) { rewrittenNode_value.setParent(getParent()); } } while (state.testAndClearChangeInCycle()); rewrittenNode_computed = true; state.leaveCircle(); } else if (rewrittenNode_cycle != state.cycle()) { rewrittenNode_cycle = state.cycle(); ASTNode new_rewrittenNode_value = rewrittenNode_value.rewriteTo(); if (new_rewrittenNode_value != rewrittenNode_value || new_rewrittenNode_value.canRewrite()) { state.setChangeInCycle(); } rewrittenNode_value = new_rewrittenNode_value; if (rewrittenNode_value != null) { rewrittenNode_value.setParent(getParent()); } } else { } return rewrittenNode_value; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy