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/java5/grammar/GenericMethods.ast:19
027     * @production ParClassInstanceExpr : {@link ClassInstanceExpr} ::= <span class="component">TypeArgument:{@link Access}*</span>;
028    
029     */
030    public class ParClassInstanceExpr extends ClassInstanceExpr implements Cloneable {
031      /**
032       * @aspect GenericMethodsPrettyPrint
033       * @declaredat /home/jesper/git/extendj/java5/frontend/GenericMethods.jrag:251
034       */
035      public void prettyPrint(PrettyPrinter out) {
036        out.print("<");
037        for (int i = 0; i < getNumTypeArgument(); i++) {
038          if (i != 0) {
039            out.print(", ");
040          }
041          out.print(getTypeArgument(i));
042        }
043        out.print(">");
044        super.prettyPrint(out);
045      }
046      /**
047       * @declaredat ASTNode:1
048       */
049      public ParClassInstanceExpr() {
050        super();
051      }
052      /**
053       * Initializes the child array to the correct size.
054       * Initializes List and Opt nta children.
055       * @apilevel internal
056       * @ast method
057       * @declaredat ASTNode:10
058       */
059      public void init$Children() {
060        children = new ASTNode[4];
061        setChild(new List(), 1);
062        setChild(new Opt(), 2);
063        setChild(new List(), 3);
064      }
065      /**
066       * @declaredat ASTNode:16
067       */
068      public ParClassInstanceExpr(Access p0, List<Expr> p1, Opt<TypeDecl> p2, List<Access> p3) {
069        setChild(p0, 0);
070        setChild(p1, 1);
071        setChild(p2, 2);
072        setChild(p3, 3);
073      }
074      /**
075       * @apilevel low-level
076       * @declaredat ASTNode:25
077       */
078      protected int numChildren() {
079        return 4;
080      }
081      /**
082       * @apilevel internal
083       * @declaredat ASTNode:31
084       */
085      public boolean mayHaveRewrite() {
086        return false;
087      }
088      /**
089       * @apilevel internal
090       * @declaredat ASTNode:37
091       */
092      public void flushAttrCache() {
093        super.flushAttrCache();
094      }
095      /**
096       * @apilevel internal
097       * @declaredat ASTNode:43
098       */
099      public void flushCollectionCache() {
100        super.flushCollectionCache();
101      }
102      /**
103       * @apilevel internal
104       * @declaredat ASTNode:49
105       */
106      public void flushRewriteCache() {
107        super.flushRewriteCache();
108      }
109      /**
110       * @apilevel internal
111       * @declaredat ASTNode:55
112       */
113      public ParClassInstanceExpr clone() throws CloneNotSupportedException {
114        ParClassInstanceExpr node = (ParClassInstanceExpr) super.clone();
115        return node;
116      }
117      /**
118       * @apilevel internal
119       * @declaredat ASTNode:62
120       */
121      public ParClassInstanceExpr copy() {
122        try {
123          ParClassInstanceExpr node = (ParClassInstanceExpr) clone();
124          node.parent = null;
125          if (children != null) {
126            node.children = (ASTNode[]) children.clone();
127          }
128          return node;
129        } catch (CloneNotSupportedException e) {
130          throw new Error("Error: clone not supported for " + getClass().getName());
131        }
132      }
133      /**
134       * Create a deep copy of the AST subtree at this node.
135       * The copy is dangling, i.e. has no parent.
136       * @return dangling copy of the subtree at this node
137       * @apilevel low-level
138       * @deprecated Please use treeCopy or treeCopyNoTransform instead
139       * @declaredat ASTNode:81
140       */
141      @Deprecated
142      public ParClassInstanceExpr fullCopy() {
143        return treeCopyNoTransform();
144      }
145      /**
146       * Create a deep copy of the AST subtree at this node.
147       * The copy is dangling, i.e. has no parent.
148       * @return dangling copy of the subtree at this node
149       * @apilevel low-level
150       * @declaredat ASTNode:91
151       */
152      public ParClassInstanceExpr treeCopyNoTransform() {
153        ParClassInstanceExpr tree = (ParClassInstanceExpr) copy();
154        if (children != null) {
155          for (int i = 0; i < children.length; ++i) {
156            ASTNode child = (ASTNode) children[i];
157            if (child != null) {
158              child = child.treeCopyNoTransform();
159              tree.setChild(child, i);
160            }
161          }
162        }
163        return tree;
164      }
165      /**
166       * Create a deep copy of the AST subtree at this node.
167       * The subtree of this node is traversed to trigger rewrites before copy.
168       * The copy is dangling, i.e. has no parent.
169       * @return dangling copy of the subtree at this node
170       * @apilevel low-level
171       * @declaredat ASTNode:111
172       */
173      public ParClassInstanceExpr treeCopy() {
174        doFullTraversal();
175        return treeCopyNoTransform();
176      }
177      /**
178       * @apilevel internal
179       * @declaredat ASTNode:118
180       */
181      protected boolean is$Equal(ASTNode node) {
182        return super.is$Equal(node);    
183      }
184      /**
185       * Replaces the Access child.
186       * @param node The new node to replace the Access child.
187       * @apilevel high-level
188       */
189      public void setAccess(Access node) {
190        setChild(node, 0);
191      }
192      /**
193       * Retrieves the Access child.
194       * @return The current node used as the Access child.
195       * @apilevel high-level
196       */
197      @ASTNodeAnnotation.Child(name="Access")
198      public Access getAccess() {
199        return (Access) getChild(0);
200      }
201      /**
202       * Retrieves the Access child.
203       * <p><em>This method does not invoke AST transformations.</em></p>
204       * @return The current node used as the Access child.
205       * @apilevel low-level
206       */
207      public Access getAccessNoTransform() {
208        return (Access) getChildNoTransform(0);
209      }
210      /**
211       * Replaces the Arg list.
212       * @param list The new list node to be used as the Arg list.
213       * @apilevel high-level
214       */
215      public void setArgList(List<Expr> list) {
216        setChild(list, 1);
217      }
218      /**
219       * Retrieves the number of children in the Arg list.
220       * @return Number of children in the Arg list.
221       * @apilevel high-level
222       */
223      public int getNumArg() {
224        return getArgList().getNumChild();
225      }
226      /**
227       * Retrieves the number of children in the Arg list.
228       * Calling this method will not trigger rewrites.
229       * @return Number of children in the Arg list.
230       * @apilevel low-level
231       */
232      public int getNumArgNoTransform() {
233        return getArgListNoTransform().getNumChildNoTransform();
234      }
235      /**
236       * Retrieves the element at index {@code i} in the Arg list.
237       * @param i Index of the element to return.
238       * @return The element at position {@code i} in the Arg list.
239       * @apilevel high-level
240       */
241      public Expr getArg(int i) {
242        return (Expr) getArgList().getChild(i);
243      }
244      /**
245       * Check whether the Arg list has any children.
246       * @return {@code true} if it has at least one child, {@code false} otherwise.
247       * @apilevel high-level
248       */
249      public boolean hasArg() {
250        return getArgList().getNumChild() != 0;
251      }
252      /**
253       * Append an element to the Arg list.
254       * @param node The element to append to the Arg list.
255       * @apilevel high-level
256       */
257      public void addArg(Expr node) {
258        List<Expr> list = (parent == null) ? getArgListNoTransform() : getArgList();
259        list.addChild(node);
260      }
261      /**
262       * @apilevel low-level
263       */
264      public void addArgNoTransform(Expr node) {
265        List<Expr> list = getArgListNoTransform();
266        list.addChild(node);
267      }
268      /**
269       * Replaces the Arg list element at index {@code i} with the new node {@code node}.
270       * @param node The new node to replace the old list element.
271       * @param i The list index of the node to be replaced.
272       * @apilevel high-level
273       */
274      public void setArg(Expr node, int i) {
275        List<Expr> list = getArgList();
276        list.setChild(node, i);
277      }
278      /**
279       * Retrieves the Arg list.
280       * @return The node representing the Arg list.
281       * @apilevel high-level
282       */
283      @ASTNodeAnnotation.ListChild(name="Arg")
284      public List<Expr> getArgList() {
285        List<Expr> list = (List<Expr>) getChild(1);
286        return list;
287      }
288      /**
289       * Retrieves the Arg list.
290       * <p><em>This method does not invoke AST transformations.</em></p>
291       * @return The node representing the Arg list.
292       * @apilevel low-level
293       */
294      public List<Expr> getArgListNoTransform() {
295        return (List<Expr>) getChildNoTransform(1);
296      }
297      /**
298       * Retrieves the Arg list.
299       * @return The node representing the Arg list.
300       * @apilevel high-level
301       */
302      public List<Expr> getArgs() {
303        return getArgList();
304      }
305      /**
306       * Retrieves the Arg list.
307       * <p><em>This method does not invoke AST transformations.</em></p>
308       * @return The node representing the Arg list.
309       * @apilevel low-level
310       */
311      public List<Expr> getArgsNoTransform() {
312        return getArgListNoTransform();
313      }
314      /**
315       * Replaces the optional node for the TypeDecl child. This is the <code>Opt</code>
316       * node containing the child TypeDecl, not the actual child!
317       * @param opt The new node to be used as the optional node for the TypeDecl child.
318       * @apilevel low-level
319       */
320      public void setTypeDeclOpt(Opt<TypeDecl> opt) {
321        setChild(opt, 2);
322      }
323      /**
324       * Replaces the (optional) TypeDecl child.
325       * @param node The new node to be used as the TypeDecl child.
326       * @apilevel high-level
327       */
328      public void setTypeDecl(TypeDecl node) {
329        getTypeDeclOpt().setChild(node, 0);
330      }
331      /**
332       * Check whether the optional TypeDecl child exists.
333       * @return {@code true} if the optional TypeDecl child exists, {@code false} if it does not.
334       * @apilevel high-level
335       */
336      public boolean hasTypeDecl() {
337        return getTypeDeclOpt().getNumChild() != 0;
338      }
339      /**
340       * Retrieves the (optional) TypeDecl child.
341       * @return The TypeDecl child, if it exists. Returns {@code null} otherwise.
342       * @apilevel low-level
343       */
344      public TypeDecl getTypeDecl() {
345        return (TypeDecl) getTypeDeclOpt().getChild(0);
346      }
347      /**
348       * Retrieves the optional node for the TypeDecl child. This is the <code>Opt</code> node containing the child TypeDecl, not the actual child!
349       * @return The optional node for child the TypeDecl child.
350       * @apilevel low-level
351       */
352      @ASTNodeAnnotation.OptChild(name="TypeDecl")
353      public Opt<TypeDecl> getTypeDeclOpt() {
354        return (Opt<TypeDecl>) getChild(2);
355      }
356      /**
357       * Retrieves the optional node for child TypeDecl. This is the <code>Opt</code> node containing the child TypeDecl, not the actual child!
358       * <p><em>This method does not invoke AST transformations.</em></p>
359       * @return The optional node for child TypeDecl.
360       * @apilevel low-level
361       */
362      public Opt<TypeDecl> getTypeDeclOptNoTransform() {
363        return (Opt<TypeDecl>) getChildNoTransform(2);
364      }
365      /**
366       * Replaces the TypeArgument list.
367       * @param list The new list node to be used as the TypeArgument list.
368       * @apilevel high-level
369       */
370      public void setTypeArgumentList(List<Access> list) {
371        setChild(list, 3);
372      }
373      /**
374       * Retrieves the number of children in the TypeArgument list.
375       * @return Number of children in the TypeArgument list.
376       * @apilevel high-level
377       */
378      public int getNumTypeArgument() {
379        return getTypeArgumentList().getNumChild();
380      }
381      /**
382       * Retrieves the number of children in the TypeArgument list.
383       * Calling this method will not trigger rewrites.
384       * @return Number of children in the TypeArgument list.
385       * @apilevel low-level
386       */
387      public int getNumTypeArgumentNoTransform() {
388        return getTypeArgumentListNoTransform().getNumChildNoTransform();
389      }
390      /**
391       * Retrieves the element at index {@code i} in the TypeArgument list.
392       * @param i Index of the element to return.
393       * @return The element at position {@code i} in the TypeArgument list.
394       * @apilevel high-level
395       */
396      public Access getTypeArgument(int i) {
397        return (Access) getTypeArgumentList().getChild(i);
398      }
399      /**
400       * Check whether the TypeArgument list has any children.
401       * @return {@code true} if it has at least one child, {@code false} otherwise.
402       * @apilevel high-level
403       */
404      public boolean hasTypeArgument() {
405        return getTypeArgumentList().getNumChild() != 0;
406      }
407      /**
408       * Append an element to the TypeArgument list.
409       * @param node The element to append to the TypeArgument list.
410       * @apilevel high-level
411       */
412      public void addTypeArgument(Access node) {
413        List<Access> list = (parent == null) ? getTypeArgumentListNoTransform() : getTypeArgumentList();
414        list.addChild(node);
415      }
416      /**
417       * @apilevel low-level
418       */
419      public void addTypeArgumentNoTransform(Access node) {
420        List<Access> list = getTypeArgumentListNoTransform();
421        list.addChild(node);
422      }
423      /**
424       * Replaces the TypeArgument list element at index {@code i} with the new node {@code node}.
425       * @param node The new node to replace the old list element.
426       * @param i The list index of the node to be replaced.
427       * @apilevel high-level
428       */
429      public void setTypeArgument(Access node, int i) {
430        List<Access> list = getTypeArgumentList();
431        list.setChild(node, i);
432      }
433      /**
434       * Retrieves the TypeArgument list.
435       * @return The node representing the TypeArgument list.
436       * @apilevel high-level
437       */
438      @ASTNodeAnnotation.ListChild(name="TypeArgument")
439      public List<Access> getTypeArgumentList() {
440        List<Access> list = (List<Access>) getChild(3);
441        return list;
442      }
443      /**
444       * Retrieves the TypeArgument list.
445       * <p><em>This method does not invoke AST transformations.</em></p>
446       * @return The node representing the TypeArgument list.
447       * @apilevel low-level
448       */
449      public List<Access> getTypeArgumentListNoTransform() {
450        return (List<Access>) getChildNoTransform(3);
451      }
452      /**
453       * Retrieves the TypeArgument list.
454       * @return The node representing the TypeArgument list.
455       * @apilevel high-level
456       */
457      public List<Access> getTypeArguments() {
458        return getTypeArgumentList();
459      }
460      /**
461       * Retrieves the TypeArgument list.
462       * <p><em>This method does not invoke AST transformations.</em></p>
463       * @return The node representing the TypeArgument list.
464       * @apilevel low-level
465       */
466      public List<Access> getTypeArgumentsNoTransform() {
467        return getTypeArgumentListNoTransform();
468      }
469      /**
470       * @declaredat /home/jesper/git/extendj/java4/frontend/SyntacticClassification.jrag:36
471       * @apilevel internal
472       */
473      public NameType Define_nameType(ASTNode caller, ASTNode child) {
474        if (caller == getTypeArgumentListNoTransform()) {
475          // @declaredat /home/jesper/git/extendj/java5/frontend/GenericMethods.jrag:208
476          int childIndex = caller.getIndexOfChild(child);
477          return NameType.TYPE_NAME;
478        }
479        else {
480          return super.Define_nameType(caller, child);
481        }
482      }
483      protected boolean canDefine_nameType(ASTNode caller, ASTNode child) {
484        return true;
485      }
486      /**
487       * @declaredat /home/jesper/git/extendj/java5/frontend/GenericMethods.jrag:197
488       * @apilevel internal
489       */
490      public SimpleSet Define_lookupType(ASTNode caller, ASTNode child, String name) {
491        if (caller == getTypeArgumentListNoTransform()) {
492          // @declaredat /home/jesper/git/extendj/java5/frontend/GenericMethods.jrag:209
493          int childIndex = caller.getIndexOfChild(child);
494          return unqualifiedScope().lookupType(name);
495        }
496        else {
497          return super.Define_lookupType(caller, child, name);
498        }
499      }
500      protected boolean canDefine_lookupType(ASTNode caller, ASTNode child, String name) {
501        return true;
502      }
503      /**
504       * @declaredat /home/jesper/git/extendj/java7/frontend/Diamond.jrag:417
505       * @apilevel internal
506       */
507      public boolean Define_isExplicitGenericConstructorAccess(ASTNode caller, ASTNode child) {
508        if (caller == getAccessNoTransform()) {
509          // @declaredat /home/jesper/git/extendj/java7/frontend/Diamond.jrag:422
510          return true;
511        }
512        else {
513          return getParent().Define_isExplicitGenericConstructorAccess(this, caller);
514        }
515      }
516      protected boolean canDefine_isExplicitGenericConstructorAccess(ASTNode caller, ASTNode child) {
517        return true;
518      }
519      /**
520       * @apilevel internal
521       */
522      public ASTNode rewriteTo() {
523        return super.rewriteTo();
524      }
525    }