001    /* This file was generated with JastAdd2 (http://jastadd.org) version 2.1.13-12-g880e696 */
002    package org.extendj.ast;
003    
004    import java.util.HashSet;
005    import java.io.File;
006    import java.util.Set;
007    import java.util.Collections;
008    import java.util.Collection;
009    import java.util.ArrayList;
010    import beaver.*;
011    import java.util.*;
012    import java.io.ByteArrayOutputStream;
013    import java.io.PrintStream;
014    import java.lang.reflect.InvocationTargetException;
015    import java.lang.reflect.Method;
016    import org.jastadd.util.*;
017    import java.util.zip.*;
018    import java.io.*;
019    import org.jastadd.util.PrettyPrintable;
020    import org.jastadd.util.PrettyPrinter;
021    import java.io.FileNotFoundException;
022    import java.io.BufferedInputStream;
023    import java.io.DataInputStream;
024    /**
025     * @ast node
026     * @declaredat /home/jesper/git/extendj/java8/grammar/MethodReference.ast:8
027     * @production ParMethodReferenceAccess : {@link ParMethodAccess};
028    
029     */
030    public class ParMethodReferenceAccess extends ParMethodAccess implements Cloneable {
031      /**
032       * @aspect Synthetics
033       * @declaredat /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:386
034       */
035      private FunctionDescriptor targetDescriptor;
036      /**
037       * @aspect Synthetics
038       * @declaredat /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:387
039       */
040      public ParMethodReferenceAccess(String name,
041          List<Expr> args, List<Access> typeArgs, FunctionDescriptor f) {
042        super(name, args, typeArgs);
043        this.targetDescriptor = f;
044      }
045      /**
046       * @declaredat ASTNode:1
047       */
048      public ParMethodReferenceAccess() {
049        super();
050      }
051      /**
052       * Initializes the child array to the correct size.
053       * Initializes List and Opt nta children.
054       * @apilevel internal
055       * @ast method
056       * @declaredat ASTNode:10
057       */
058      public void init$Children() {
059        children = new ASTNode[2];
060        setChild(new List(), 0);
061        setChild(new List(), 1);
062      }
063      /**
064       * @declaredat ASTNode:15
065       */
066      public ParMethodReferenceAccess(String p0, List<Expr> p1, List<Access> p2) {
067        setID(p0);
068        setChild(p1, 0);
069        setChild(p2, 1);
070      }
071      /**
072       * @declaredat ASTNode:20
073       */
074      public ParMethodReferenceAccess(beaver.Symbol p0, List<Expr> p1, List<Access> p2) {
075        setID(p0);
076        setChild(p1, 0);
077        setChild(p2, 1);
078      }
079      /**
080       * @apilevel low-level
081       * @declaredat ASTNode:28
082       */
083      protected int numChildren() {
084        return 2;
085      }
086      /**
087       * @apilevel internal
088       * @declaredat ASTNode:34
089       */
090      public boolean mayHaveRewrite() {
091        return false;
092      }
093      /**
094       * @apilevel internal
095       * @declaredat ASTNode:40
096       */
097      public void flushAttrCache() {
098        super.flushAttrCache();
099        assignConvertedType_reset();
100      }
101      /**
102       * @apilevel internal
103       * @declaredat ASTNode:47
104       */
105      public void flushCollectionCache() {
106        super.flushCollectionCache();
107      }
108      /**
109       * @apilevel internal
110       * @declaredat ASTNode:53
111       */
112      public void flushRewriteCache() {
113        super.flushRewriteCache();
114      }
115      /**
116       * @apilevel internal
117       * @declaredat ASTNode:59
118       */
119      public ParMethodReferenceAccess clone() throws CloneNotSupportedException {
120        ParMethodReferenceAccess node = (ParMethodReferenceAccess) super.clone();
121        return node;
122      }
123      /**
124       * @apilevel internal
125       * @declaredat ASTNode:66
126       */
127      public ParMethodReferenceAccess copy() {
128        try {
129          ParMethodReferenceAccess node = (ParMethodReferenceAccess) clone();
130          node.parent = null;
131          if (children != null) {
132            node.children = (ASTNode[]) children.clone();
133          }
134          return node;
135        } catch (CloneNotSupportedException e) {
136          throw new Error("Error: clone not supported for " + getClass().getName());
137        }
138      }
139      /**
140       * Create a deep copy of the AST subtree at this node.
141       * The copy is dangling, i.e. has no parent.
142       * @return dangling copy of the subtree at this node
143       * @apilevel low-level
144       * @deprecated Please use treeCopy or treeCopyNoTransform instead
145       * @declaredat ASTNode:85
146       */
147      @Deprecated
148      public ParMethodReferenceAccess fullCopy() {
149        return treeCopyNoTransform();
150      }
151      /**
152       * Create a deep copy of the AST subtree at this node.
153       * The copy is dangling, i.e. has no parent.
154       * @return dangling copy of the subtree at this node
155       * @apilevel low-level
156       * @declaredat ASTNode:95
157       */
158      public ParMethodReferenceAccess treeCopyNoTransform() {
159        ParMethodReferenceAccess tree = (ParMethodReferenceAccess) copy();
160        if (children != null) {
161          for (int i = 0; i < children.length; ++i) {
162            ASTNode child = (ASTNode) children[i];
163            if (child != null) {
164              child = child.treeCopyNoTransform();
165              tree.setChild(child, i);
166            }
167          }
168        }
169        return tree;
170      }
171      /**
172       * Create a deep copy of the AST subtree at this node.
173       * The subtree of this node is traversed to trigger rewrites before copy.
174       * The copy is dangling, i.e. has no parent.
175       * @return dangling copy of the subtree at this node
176       * @apilevel low-level
177       * @declaredat ASTNode:115
178       */
179      public ParMethodReferenceAccess treeCopy() {
180        doFullTraversal();
181        return treeCopyNoTransform();
182      }
183      /**
184       * @apilevel internal
185       * @declaredat ASTNode:122
186       */
187      protected boolean is$Equal(ASTNode node) {
188        return super.is$Equal(node) && (tokenString_ID == ((ParMethodReferenceAccess)node).tokenString_ID);    
189      }
190      /**
191       * Replaces the lexeme ID.
192       * @param value The new value for the lexeme ID.
193       * @apilevel high-level
194       */
195      public void setID(String value) {
196        tokenString_ID = value;
197      }
198      /**
199       * JastAdd-internal setter for lexeme ID using the Beaver parser.
200       * @param symbol Symbol containing the new value for the lexeme ID
201       * @apilevel internal
202       */
203      public void setID(beaver.Symbol symbol) {
204        if (symbol.value != null && !(symbol.value instanceof String))
205        throw new UnsupportedOperationException("setID is only valid for String lexemes");
206        tokenString_ID = (String)symbol.value;
207        IDstart = symbol.getStart();
208        IDend = symbol.getEnd();
209      }
210      /**
211       * Retrieves the value for the lexeme ID.
212       * @return The value for the lexeme ID.
213       * @apilevel high-level
214       */
215      @ASTNodeAnnotation.Token(name="ID")
216      public String getID() {
217        return tokenString_ID != null ? tokenString_ID : "";
218      }
219      /**
220       * Replaces the Arg list.
221       * @param list The new list node to be used as the Arg list.
222       * @apilevel high-level
223       */
224      public void setArgList(List<Expr> list) {
225        setChild(list, 0);
226      }
227      /**
228       * Retrieves the number of children in the Arg list.
229       * @return Number of children in the Arg list.
230       * @apilevel high-level
231       */
232      public int getNumArg() {
233        return getArgList().getNumChild();
234      }
235      /**
236       * Retrieves the number of children in the Arg list.
237       * Calling this method will not trigger rewrites.
238       * @return Number of children in the Arg list.
239       * @apilevel low-level
240       */
241      public int getNumArgNoTransform() {
242        return getArgListNoTransform().getNumChildNoTransform();
243      }
244      /**
245       * Retrieves the element at index {@code i} in the Arg list.
246       * @param i Index of the element to return.
247       * @return The element at position {@code i} in the Arg list.
248       * @apilevel high-level
249       */
250      public Expr getArg(int i) {
251        return (Expr) getArgList().getChild(i);
252      }
253      /**
254       * Check whether the Arg list has any children.
255       * @return {@code true} if it has at least one child, {@code false} otherwise.
256       * @apilevel high-level
257       */
258      public boolean hasArg() {
259        return getArgList().getNumChild() != 0;
260      }
261      /**
262       * Append an element to the Arg list.
263       * @param node The element to append to the Arg list.
264       * @apilevel high-level
265       */
266      public void addArg(Expr node) {
267        List<Expr> list = (parent == null) ? getArgListNoTransform() : getArgList();
268        list.addChild(node);
269      }
270      /**
271       * @apilevel low-level
272       */
273      public void addArgNoTransform(Expr node) {
274        List<Expr> list = getArgListNoTransform();
275        list.addChild(node);
276      }
277      /**
278       * Replaces the Arg list element at index {@code i} with the new node {@code node}.
279       * @param node The new node to replace the old list element.
280       * @param i The list index of the node to be replaced.
281       * @apilevel high-level
282       */
283      public void setArg(Expr node, int i) {
284        List<Expr> list = getArgList();
285        list.setChild(node, i);
286      }
287      /**
288       * Retrieves the Arg list.
289       * @return The node representing the Arg list.
290       * @apilevel high-level
291       */
292      @ASTNodeAnnotation.ListChild(name="Arg")
293      public List<Expr> getArgList() {
294        List<Expr> list = (List<Expr>) getChild(0);
295        return list;
296      }
297      /**
298       * Retrieves the Arg list.
299       * <p><em>This method does not invoke AST transformations.</em></p>
300       * @return The node representing the Arg list.
301       * @apilevel low-level
302       */
303      public List<Expr> getArgListNoTransform() {
304        return (List<Expr>) getChildNoTransform(0);
305      }
306      /**
307       * Retrieves the Arg list.
308       * @return The node representing the Arg list.
309       * @apilevel high-level
310       */
311      public List<Expr> getArgs() {
312        return getArgList();
313      }
314      /**
315       * Retrieves the Arg list.
316       * <p><em>This method does not invoke AST transformations.</em></p>
317       * @return The node representing the Arg list.
318       * @apilevel low-level
319       */
320      public List<Expr> getArgsNoTransform() {
321        return getArgListNoTransform();
322      }
323      /**
324       * Replaces the TypeArgument list.
325       * @param list The new list node to be used as the TypeArgument list.
326       * @apilevel high-level
327       */
328      public void setTypeArgumentList(List<Access> list) {
329        setChild(list, 1);
330      }
331      /**
332       * Retrieves the number of children in the TypeArgument list.
333       * @return Number of children in the TypeArgument list.
334       * @apilevel high-level
335       */
336      public int getNumTypeArgument() {
337        return getTypeArgumentList().getNumChild();
338      }
339      /**
340       * Retrieves the number of children in the TypeArgument list.
341       * Calling this method will not trigger rewrites.
342       * @return Number of children in the TypeArgument list.
343       * @apilevel low-level
344       */
345      public int getNumTypeArgumentNoTransform() {
346        return getTypeArgumentListNoTransform().getNumChildNoTransform();
347      }
348      /**
349       * Retrieves the element at index {@code i} in the TypeArgument list.
350       * @param i Index of the element to return.
351       * @return The element at position {@code i} in the TypeArgument list.
352       * @apilevel high-level
353       */
354      public Access getTypeArgument(int i) {
355        return (Access) getTypeArgumentList().getChild(i);
356      }
357      /**
358       * Check whether the TypeArgument list has any children.
359       * @return {@code true} if it has at least one child, {@code false} otherwise.
360       * @apilevel high-level
361       */
362      public boolean hasTypeArgument() {
363        return getTypeArgumentList().getNumChild() != 0;
364      }
365      /**
366       * Append an element to the TypeArgument list.
367       * @param node The element to append to the TypeArgument list.
368       * @apilevel high-level
369       */
370      public void addTypeArgument(Access node) {
371        List<Access> list = (parent == null) ? getTypeArgumentListNoTransform() : getTypeArgumentList();
372        list.addChild(node);
373      }
374      /**
375       * @apilevel low-level
376       */
377      public void addTypeArgumentNoTransform(Access node) {
378        List<Access> list = getTypeArgumentListNoTransform();
379        list.addChild(node);
380      }
381      /**
382       * Replaces the TypeArgument list element at index {@code i} with the new node {@code node}.
383       * @param node The new node to replace the old list element.
384       * @param i The list index of the node to be replaced.
385       * @apilevel high-level
386       */
387      public void setTypeArgument(Access node, int i) {
388        List<Access> list = getTypeArgumentList();
389        list.setChild(node, i);
390      }
391      /**
392       * Retrieves the TypeArgument list.
393       * @return The node representing the TypeArgument list.
394       * @apilevel high-level
395       */
396      @ASTNodeAnnotation.ListChild(name="TypeArgument")
397      public List<Access> getTypeArgumentList() {
398        List<Access> list = (List<Access>) getChild(1);
399        return list;
400      }
401      /**
402       * Retrieves the TypeArgument list.
403       * <p><em>This method does not invoke AST transformations.</em></p>
404       * @return The node representing the TypeArgument list.
405       * @apilevel low-level
406       */
407      public List<Access> getTypeArgumentListNoTransform() {
408        return (List<Access>) getChildNoTransform(1);
409      }
410      /**
411       * Retrieves the TypeArgument list.
412       * @return The node representing the TypeArgument list.
413       * @apilevel high-level
414       */
415      public List<Access> getTypeArguments() {
416        return getTypeArgumentList();
417      }
418      /**
419       * Retrieves the TypeArgument list.
420       * <p><em>This method does not invoke AST transformations.</em></p>
421       * @return The node representing the TypeArgument list.
422       * @apilevel low-level
423       */
424      public List<Access> getTypeArgumentsNoTransform() {
425        return getTypeArgumentListNoTransform();
426      }
427      /**
428       * @apilevel internal
429       */
430      protected boolean assignConvertedType_computed = false;
431      /**
432       * @apilevel internal
433       */
434      protected TypeDecl assignConvertedType_value;
435      /**
436       * @apilevel internal
437       */
438      private void assignConvertedType_reset() {
439        assignConvertedType_computed = false;
440        assignConvertedType_value = null;
441      }
442      /**
443       * @attribute syn
444       * @aspect TargetType
445       * @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:177
446       */
447      @ASTNodeAnnotation.Attribute
448      public TypeDecl assignConvertedType() {
449        ASTNode$State state = state();
450        if (assignConvertedType_computed) {
451          return assignConvertedType_value;
452        }
453        boolean intermediate = state.INTERMEDIATE_VALUE;
454        state.INTERMEDIATE_VALUE = false;
455        int num = state.boundariesCrossed;
456        boolean isFinal = this.is$Final();
457        assignConvertedType_value = targetDescriptor.method.type();
458        if (isFinal && num == state().boundariesCrossed) {
459          assignConvertedType_computed = true;
460        } else {
461        }
462        state.INTERMEDIATE_VALUE |= intermediate;
463    
464        return assignConvertedType_value;
465      }
466      /**
467       * @apilevel internal
468       */
469      public ASTNode rewriteTo() {
470        return super.rewriteTo();
471      }
472    }