001    /* This file was generated with JastAdd2 (http://jastadd.org) version R20130213 */
002    package AST;
003    
004    import java.util.HashSet;
005    import java.io.File;
006    import java.util.*;
007    import beaver.*;
008    import java.util.ArrayList;
009    import java.util.zip.*;
010    import java.io.*;
011    import java.io.FileNotFoundException;
012    import java.util.Collection;
013    /**
014     * @production ParMethodAccess : {@link MethodAccess} ::= <span class="component">TypeArgument:{@link Access}*</span>;
015     * @ast node
016     * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericMethods.ast:13
017     */
018    public class ParMethodAccess extends MethodAccess implements Cloneable {
019      /**
020       * @apilevel low-level
021       */
022      public void flushCache() {
023      }
024      /**
025       * @apilevel internal
026       */
027      public void flushCollectionCache() {
028      }
029      /**
030       * @apilevel internal
031       */
032      @SuppressWarnings({"unchecked", "cast"})
033      public ParMethodAccess clone() throws CloneNotSupportedException {
034        ParMethodAccess node = (ParMethodAccess)super.clone();
035        node.typeArguments_MethodDecl_values = null;
036        node.in$Circle(false);
037        node.is$Final(false);
038        return node;
039      }
040    /**
041     * @apilevel internal
042     */
043      @SuppressWarnings({"unchecked", "cast"})
044    public ParMethodAccess copy() {
045      
046      try {
047        ParMethodAccess node = (ParMethodAccess) clone();
048        node.parent = null;
049        if(children != null)
050          node.children = (ASTNode[]) children.clone();
051        
052        return node;
053      } catch (CloneNotSupportedException e) {
054        throw new Error("Error: clone not supported for " + getClass().getName());
055      }
056      
057    }/**
058     * Create a deep copy of the AST subtree at this node.
059     * The copy is dangling, i.e. has no parent.
060     * @return dangling copy of the subtree at this node
061     * @apilevel low-level
062     */
063      @SuppressWarnings({"unchecked", "cast"})
064    public ParMethodAccess fullCopy() {
065      
066      ParMethodAccess tree = (ParMethodAccess) copy();
067      if (children != null) {
068        for (int i = 0; i < children.length; ++i) {
069          
070          ASTNode child = (ASTNode) children[i];
071          if(child != null) {
072            child = child.fullCopy();
073            tree.setChild(child, i);
074          }
075        }
076      }
077      return tree;
078      
079    }  /**
080       * @ast method 
081       * @aspect GenericMethods
082       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericMethods.jrag:11
083       */
084      public void typeCheck() {
085        super.typeCheck();
086        if(!decl().hostType().isUnknown()) {
087          if(!(decl() instanceof ParMethodDecl))
088            error("can not have type parameters on a non generic method");
089          else {
090            ParMethodDecl m = (ParMethodDecl)decl();
091            if(!(m instanceof RawMethodDecl) && m.numTypeParameter() != getNumTypeArgument())
092              error("generic method " + m.signature() + " requires " + m.numTypeParameter() + " type arguments");
093            else {
094            }
095          }
096        }
097      }
098      /**
099       * @ast method 
100       * @aspect GenericMethodsPrettyPrint
101       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericMethods.jrag:179
102       */
103      public void toString(StringBuffer s) {
104        s.append("<");
105        for(int i = 0; i < getNumTypeArgument(); i++) {
106          if(i != 0) s.append(", ");
107          getTypeArgument(i).toString(s);
108        }
109        s.append(">");
110        super.toString(s);
111      }
112      /**
113       * @ast method 
114       * 
115       */
116      public ParMethodAccess() {
117        super();
118    
119    
120      }
121      /**
122       * Initializes the child array to the correct size.
123       * Initializes List and Opt nta children.
124       * @apilevel internal
125       * @ast method
126       * @ast method 
127       * 
128       */
129      public void init$Children() {
130        children = new ASTNode[2];
131        setChild(new List(), 0);
132        setChild(new List(), 1);
133      }
134      /**
135       * @ast method 
136       * 
137       */
138      public ParMethodAccess(String p0, List<Expr> p1, List<Access> p2) {
139        setID(p0);
140        setChild(p1, 0);
141        setChild(p2, 1);
142      }
143      /**
144       * @ast method 
145       * 
146       */
147      public ParMethodAccess(beaver.Symbol p0, List<Expr> p1, List<Access> p2) {
148        setID(p0);
149        setChild(p1, 0);
150        setChild(p2, 1);
151      }
152      /**
153       * @apilevel low-level
154       * @ast method 
155       * 
156       */
157      protected int numChildren() {
158        return 2;
159      }
160      /**
161       * @apilevel internal
162       * @ast method 
163       * 
164       */
165      public boolean mayHaveRewrite() {
166        return false;
167      }
168      /**
169       * Replaces the lexeme ID.
170       * @param value The new value for the lexeme ID.
171       * @apilevel high-level
172       * @ast method 
173       * 
174       */
175      public void setID(String value) {
176        tokenString_ID = value;
177      }
178      /**
179       * JastAdd-internal setter for lexeme ID using the Beaver parser.
180       * @apilevel internal
181       * @ast method 
182       * 
183       */
184      public void setID(beaver.Symbol symbol) {
185        if(symbol.value != null && !(symbol.value instanceof String))
186          throw new UnsupportedOperationException("setID is only valid for String lexemes");
187        tokenString_ID = (String)symbol.value;
188        IDstart = symbol.getStart();
189        IDend = symbol.getEnd();
190      }
191      /**
192       * Retrieves the value for the lexeme ID.
193       * @return The value for the lexeme ID.
194       * @apilevel high-level
195       * @ast method 
196       * 
197       */
198      public String getID() {
199        return tokenString_ID != null ? tokenString_ID : "";
200      }
201      /**
202       * Replaces the Arg list.
203       * @param list The new list node to be used as the Arg list.
204       * @apilevel high-level
205       * @ast method 
206       * 
207       */
208      public void setArgList(List<Expr> list) {
209        setChild(list, 0);
210      }
211      /**
212       * Retrieves the number of children in the Arg list.
213       * @return Number of children in the Arg list.
214       * @apilevel high-level
215       * @ast method 
216       * 
217       */
218      public int getNumArg() {
219        return getArgList().getNumChild();
220      }
221      /**
222       * Retrieves the number of children in the Arg list.
223       * Calling this method will not trigger rewrites..
224       * @return Number of children in the Arg list.
225       * @apilevel low-level
226       * @ast method 
227       * 
228       */
229      public int getNumArgNoTransform() {
230        return getArgListNoTransform().getNumChildNoTransform();
231      }
232      /**
233       * Retrieves the element at index {@code i} in the Arg list..
234       * @param i Index of the element to return.
235       * @return The element at position {@code i} in the Arg list.
236       * @apilevel high-level
237       * @ast method 
238       * 
239       */
240      @SuppressWarnings({"unchecked", "cast"})
241      public Expr getArg(int i) {
242        return (Expr)getArgList().getChild(i);
243      }
244      /**
245       * Append an element to the Arg list.
246       * @param node The element to append to the Arg list.
247       * @apilevel high-level
248       * @ast method 
249       * 
250       */
251      public void addArg(Expr node) {
252        List<Expr> list = (parent == null || state == null) ? getArgListNoTransform() : getArgList();
253        list.addChild(node);
254      }
255      /**
256       * @apilevel low-level
257       * @ast method 
258       * 
259       */
260      public void addArgNoTransform(Expr node) {
261        List<Expr> list = getArgListNoTransform();
262        list.addChild(node);
263      }
264      /**
265       * Replaces the Arg list element at index {@code i} with the new node {@code node}.
266       * @param node The new node to replace the old list element.
267       * @param i The list index of the node to be replaced.
268       * @apilevel high-level
269       * @ast method 
270       * 
271       */
272      public void setArg(Expr node, int i) {
273        List<Expr> list = getArgList();
274        list.setChild(node, i);
275      }
276      /**
277       * Retrieves the Arg list.
278       * @return The node representing the Arg list.
279       * @apilevel high-level
280       * @ast method 
281       * 
282       */
283      public List<Expr> getArgs() {
284        return getArgList();
285      }
286      /**
287       * Retrieves the Arg list.
288       * <p><em>This method does not invoke AST transformations.</em></p>
289       * @return The node representing the Arg list.
290       * @apilevel low-level
291       * @ast method 
292       * 
293       */
294      public List<Expr> getArgsNoTransform() {
295        return getArgListNoTransform();
296      }
297      /**
298       * Retrieves the Arg list.
299       * @return The node representing the Arg list.
300       * @apilevel high-level
301       * @ast method 
302       * 
303       */
304      @SuppressWarnings({"unchecked", "cast"})
305      public List<Expr> getArgList() {
306        List<Expr> list = (List<Expr>)getChild(0);
307        list.getNumChild();
308        return list;
309      }
310      /**
311       * Retrieves the Arg list.
312       * <p><em>This method does not invoke AST transformations.</em></p>
313       * @return The node representing the Arg list.
314       * @apilevel low-level
315       * @ast method 
316       * 
317       */
318      @SuppressWarnings({"unchecked", "cast"})
319      public List<Expr> getArgListNoTransform() {
320        return (List<Expr>)getChildNoTransform(0);
321      }
322      /**
323       * Replaces the TypeArgument list.
324       * @param list The new list node to be used as the TypeArgument list.
325       * @apilevel high-level
326       * @ast method 
327       * 
328       */
329      public void setTypeArgumentList(List<Access> list) {
330        setChild(list, 1);
331      }
332      /**
333       * Retrieves the number of children in the TypeArgument list.
334       * @return Number of children in the TypeArgument list.
335       * @apilevel high-level
336       * @ast method 
337       * 
338       */
339      public int getNumTypeArgument() {
340        return getTypeArgumentList().getNumChild();
341      }
342      /**
343       * Retrieves the number of children in the TypeArgument list.
344       * Calling this method will not trigger rewrites..
345       * @return Number of children in the TypeArgument list.
346       * @apilevel low-level
347       * @ast method 
348       * 
349       */
350      public int getNumTypeArgumentNoTransform() {
351        return getTypeArgumentListNoTransform().getNumChildNoTransform();
352      }
353      /**
354       * Retrieves the element at index {@code i} in the TypeArgument list..
355       * @param i Index of the element to return.
356       * @return The element at position {@code i} in the TypeArgument list.
357       * @apilevel high-level
358       * @ast method 
359       * 
360       */
361      @SuppressWarnings({"unchecked", "cast"})
362      public Access getTypeArgument(int i) {
363        return (Access)getTypeArgumentList().getChild(i);
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       * @ast method 
370       * 
371       */
372      public void addTypeArgument(Access node) {
373        List<Access> list = (parent == null || state == null) ? getTypeArgumentListNoTransform() : getTypeArgumentList();
374        list.addChild(node);
375      }
376      /**
377       * @apilevel low-level
378       * @ast method 
379       * 
380       */
381      public void addTypeArgumentNoTransform(Access node) {
382        List<Access> list = getTypeArgumentListNoTransform();
383        list.addChild(node);
384      }
385      /**
386       * Replaces the TypeArgument list element at index {@code i} with the new node {@code node}.
387       * @param node The new node to replace the old list element.
388       * @param i The list index of the node to be replaced.
389       * @apilevel high-level
390       * @ast method 
391       * 
392       */
393      public void setTypeArgument(Access node, int i) {
394        List<Access> list = getTypeArgumentList();
395        list.setChild(node, i);
396      }
397      /**
398       * Retrieves the TypeArgument list.
399       * @return The node representing the TypeArgument list.
400       * @apilevel high-level
401       * @ast method 
402       * 
403       */
404      public List<Access> getTypeArguments() {
405        return getTypeArgumentList();
406      }
407      /**
408       * Retrieves the TypeArgument list.
409       * <p><em>This method does not invoke AST transformations.</em></p>
410       * @return The node representing the TypeArgument list.
411       * @apilevel low-level
412       * @ast method 
413       * 
414       */
415      public List<Access> getTypeArgumentsNoTransform() {
416        return getTypeArgumentListNoTransform();
417      }
418      /**
419       * Retrieves the TypeArgument list.
420       * @return The node representing the TypeArgument list.
421       * @apilevel high-level
422       * @ast method 
423       * 
424       */
425      @SuppressWarnings({"unchecked", "cast"})
426      public List<Access> getTypeArgumentList() {
427        List<Access> list = (List<Access>)getChild(1);
428        list.getNumChild();
429        return list;
430      }
431      /**
432       * Retrieves the TypeArgument list.
433       * <p><em>This method does not invoke AST transformations.</em></p>
434       * @return The node representing the TypeArgument list.
435       * @apilevel low-level
436       * @ast method 
437       * 
438       */
439      @SuppressWarnings({"unchecked", "cast"})
440      public List<Access> getTypeArgumentListNoTransform() {
441        return (List<Access>)getChildNoTransform(1);
442      }
443      protected java.util.Map typeArguments_MethodDecl_values;
444      /**
445       * @attribute syn
446       * @aspect MethodSignature15
447       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/MethodSignature.jrag:311
448       */
449      @SuppressWarnings({"unchecked", "cast"})
450      public ArrayList typeArguments(MethodDecl m) {
451        Object _parameters = m;
452        if(typeArguments_MethodDecl_values == null) typeArguments_MethodDecl_values = new java.util.HashMap(4);
453        if(typeArguments_MethodDecl_values.containsKey(_parameters)) {
454          return (ArrayList)typeArguments_MethodDecl_values.get(_parameters);
455        }
456          ASTNode$State state = state();
457      int num = state.boundariesCrossed;
458      boolean isFinal = this.is$Final();
459        ArrayList typeArguments_MethodDecl_value = typeArguments_compute(m);
460      if(isFinal && num == state().boundariesCrossed){ typeArguments_MethodDecl_values.put(_parameters, typeArguments_MethodDecl_value); }
461            return typeArguments_MethodDecl_value;
462      }
463      /**
464       * @apilevel internal
465       */
466      private ArrayList typeArguments_compute(MethodDecl m) {
467        ArrayList typeArguments = new ArrayList();
468        for(int i = 0; i < getNumTypeArgument(); i++)
469          typeArguments.add(getTypeArgument(i).type());
470        return typeArguments;
471      }
472      /**
473       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericMethods.jrag:142
474       * @apilevel internal
475       */
476      public NameType Define_NameType_nameType(ASTNode caller, ASTNode child) {
477        if(caller == getTypeArgumentListNoTransform())  {
478        int childIndex = caller.getIndexOfChild(child);
479        return NameType.TYPE_NAME;
480      }
481        else {      return super.Define_NameType_nameType(caller, child);
482        }
483      }
484      /**
485       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericMethods.jrag:143
486       * @apilevel internal
487       */
488      public SimpleSet Define_SimpleSet_lookupType(ASTNode caller, ASTNode child, String name) {
489        if(caller == getTypeArgumentListNoTransform())  {
490        int childIndex = caller.getIndexOfChild(child);
491        return unqualifiedScope().lookupType(name);
492      }
493        else {      return super.Define_SimpleSet_lookupType(caller, child, name);
494        }
495      }
496      /**
497       * @apilevel internal
498       */
499      public ASTNode rewriteTo() {
500        return super.rewriteTo();
501      }
502    }