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 WildcardsCompilationUnit : {@link CompilationUnit};
015     * @ast node
016     * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.ast:49
017     */
018    public class WildcardsCompilationUnit extends CompilationUnit 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 WildcardsCompilationUnit clone() throws CloneNotSupportedException {
034        WildcardsCompilationUnit node = (WildcardsCompilationUnit)super.clone();
035        node.typeWildcard_computed = false;
036        node.typeWildcard_value = null;
037        node.lookupWildcardExtends_TypeDecl_values = null;
038        node.lookupWildcardExtends_TypeDecl_list = null;    node.lookupWildcardSuper_TypeDecl_values = null;
039        node.lookupWildcardSuper_TypeDecl_list = null;    node.lookupLUBType_Collection_values = null;
040        node.lookupLUBType_Collection_list = null;    node.lookupGLBType_ArrayList_values = null;
041        node.lookupGLBType_ArrayList_list = null;    node.in$Circle(false);
042        node.is$Final(false);
043        return node;
044      }
045    /**
046     * @apilevel internal
047     */
048      @SuppressWarnings({"unchecked", "cast"})
049    public WildcardsCompilationUnit copy() {
050      
051      try {
052        WildcardsCompilationUnit node = (WildcardsCompilationUnit) clone();
053        node.parent = null;
054        if(children != null)
055          node.children = (ASTNode[]) children.clone();
056        
057        return node;
058      } catch (CloneNotSupportedException e) {
059        throw new Error("Error: clone not supported for " + getClass().getName());
060      }
061      
062    }/**
063     * Create a deep copy of the AST subtree at this node.
064     * The copy is dangling, i.e. has no parent.
065     * @return dangling copy of the subtree at this node
066     * @apilevel low-level
067     */
068      @SuppressWarnings({"unchecked", "cast"})
069    public WildcardsCompilationUnit fullCopy() {
070      
071      WildcardsCompilationUnit tree = (WildcardsCompilationUnit) copy();
072      if (children != null) {
073        for (int i = 0; i < children.length; ++i) {
074          
075          ASTNode child = (ASTNode) children[i];
076          if(child != null) {
077            child = child.fullCopy();
078            tree.setChild(child, i);
079          }
080        }
081      }
082      return tree;
083      
084    }  /**
085       * @ast method 
086       * @aspect LookupParTypeDecl
087       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:1414
088       */
089      public static LUBType createLUBType(Collection bounds) {
090        List boundList = new List();
091        StringBuffer name = new StringBuffer();
092        for(Iterator iter = bounds.iterator(); iter.hasNext(); ) {
093          TypeDecl typeDecl = (TypeDecl)iter.next();
094          boundList.add(typeDecl.createBoundAccess());
095          name.append("& " + typeDecl.typeName());
096        }
097        LUBType decl = new LUBType(
098          new Modifiers(new List().add(new Modifier("public"))),
099          name.toString(),
100          new List(),
101          boundList
102        );
103        return decl;
104      }
105      /**
106       * @ast method 
107       * 
108       */
109      public WildcardsCompilationUnit() {
110        super();
111    
112    
113      }
114      /**
115       * Initializes the child array to the correct size.
116       * Initializes List and Opt nta children.
117       * @apilevel internal
118       * @ast method
119       * @ast method 
120       * 
121       */
122      public void init$Children() {
123        children = new ASTNode[2];
124        setChild(new List(), 0);
125        setChild(new List(), 1);
126      }
127      /**
128       * @ast method 
129       * 
130       */
131      public WildcardsCompilationUnit(java.lang.String p0, List<ImportDecl> p1, List<TypeDecl> p2) {
132        setPackageDecl(p0);
133        setChild(p1, 0);
134        setChild(p2, 1);
135      }
136      /**
137       * @ast method 
138       * 
139       */
140      public WildcardsCompilationUnit(beaver.Symbol p0, List<ImportDecl> p1, List<TypeDecl> p2) {
141        setPackageDecl(p0);
142        setChild(p1, 0);
143        setChild(p2, 1);
144      }
145      /**
146       * @apilevel low-level
147       * @ast method 
148       * 
149       */
150      protected int numChildren() {
151        return 2;
152      }
153      /**
154       * @apilevel internal
155       * @ast method 
156       * 
157       */
158      public boolean mayHaveRewrite() {
159        return false;
160      }
161      /**
162       * Replaces the lexeme PackageDecl.
163       * @param value The new value for the lexeme PackageDecl.
164       * @apilevel high-level
165       * @ast method 
166       * 
167       */
168      public void setPackageDecl(java.lang.String value) {
169        tokenjava_lang_String_PackageDecl = value;
170      }
171      /**
172       * JastAdd-internal setter for lexeme PackageDecl using the Beaver parser.
173       * @apilevel internal
174       * @ast method 
175       * 
176       */
177      public void setPackageDecl(beaver.Symbol symbol) {
178        if(symbol.value != null && !(symbol.value instanceof String))
179          throw new UnsupportedOperationException("setPackageDecl is only valid for String lexemes");
180        tokenjava_lang_String_PackageDecl = (String)symbol.value;
181        PackageDeclstart = symbol.getStart();
182        PackageDeclend = symbol.getEnd();
183      }
184      /**
185       * Retrieves the value for the lexeme PackageDecl.
186       * @return The value for the lexeme PackageDecl.
187       * @apilevel high-level
188       * @ast method 
189       * 
190       */
191      public java.lang.String getPackageDecl() {
192        return tokenjava_lang_String_PackageDecl != null ? tokenjava_lang_String_PackageDecl : "";
193      }
194      /**
195       * Replaces the ImportDecl list.
196       * @param list The new list node to be used as the ImportDecl list.
197       * @apilevel high-level
198       * @ast method 
199       * 
200       */
201      public void setImportDeclList(List<ImportDecl> list) {
202        setChild(list, 0);
203      }
204      /**
205       * Retrieves the number of children in the ImportDecl list.
206       * @return Number of children in the ImportDecl list.
207       * @apilevel high-level
208       * @ast method 
209       * 
210       */
211      public int getNumImportDecl() {
212        return getImportDeclList().getNumChild();
213      }
214      /**
215       * Retrieves the number of children in the ImportDecl list.
216       * Calling this method will not trigger rewrites..
217       * @return Number of children in the ImportDecl list.
218       * @apilevel low-level
219       * @ast method 
220       * 
221       */
222      public int getNumImportDeclNoTransform() {
223        return getImportDeclListNoTransform().getNumChildNoTransform();
224      }
225      /**
226       * Retrieves the element at index {@code i} in the ImportDecl list..
227       * @param i Index of the element to return.
228       * @return The element at position {@code i} in the ImportDecl list.
229       * @apilevel high-level
230       * @ast method 
231       * 
232       */
233      @SuppressWarnings({"unchecked", "cast"})
234      public ImportDecl getImportDecl(int i) {
235        return (ImportDecl)getImportDeclList().getChild(i);
236      }
237      /**
238       * Append an element to the ImportDecl list.
239       * @param node The element to append to the ImportDecl list.
240       * @apilevel high-level
241       * @ast method 
242       * 
243       */
244      public void addImportDecl(ImportDecl node) {
245        List<ImportDecl> list = (parent == null || state == null) ? getImportDeclListNoTransform() : getImportDeclList();
246        list.addChild(node);
247      }
248      /**
249       * @apilevel low-level
250       * @ast method 
251       * 
252       */
253      public void addImportDeclNoTransform(ImportDecl node) {
254        List<ImportDecl> list = getImportDeclListNoTransform();
255        list.addChild(node);
256      }
257      /**
258       * Replaces the ImportDecl list element at index {@code i} with the new node {@code node}.
259       * @param node The new node to replace the old list element.
260       * @param i The list index of the node to be replaced.
261       * @apilevel high-level
262       * @ast method 
263       * 
264       */
265      public void setImportDecl(ImportDecl node, int i) {
266        List<ImportDecl> list = getImportDeclList();
267        list.setChild(node, i);
268      }
269      /**
270       * Retrieves the ImportDecl list.
271       * @return The node representing the ImportDecl list.
272       * @apilevel high-level
273       * @ast method 
274       * 
275       */
276      public List<ImportDecl> getImportDecls() {
277        return getImportDeclList();
278      }
279      /**
280       * Retrieves the ImportDecl list.
281       * <p><em>This method does not invoke AST transformations.</em></p>
282       * @return The node representing the ImportDecl list.
283       * @apilevel low-level
284       * @ast method 
285       * 
286       */
287      public List<ImportDecl> getImportDeclsNoTransform() {
288        return getImportDeclListNoTransform();
289      }
290      /**
291       * Retrieves the ImportDecl list.
292       * @return The node representing the ImportDecl list.
293       * @apilevel high-level
294       * @ast method 
295       * 
296       */
297      @SuppressWarnings({"unchecked", "cast"})
298      public List<ImportDecl> getImportDeclList() {
299        List<ImportDecl> list = (List<ImportDecl>)getChild(0);
300        list.getNumChild();
301        return list;
302      }
303      /**
304       * Retrieves the ImportDecl list.
305       * <p><em>This method does not invoke AST transformations.</em></p>
306       * @return The node representing the ImportDecl list.
307       * @apilevel low-level
308       * @ast method 
309       * 
310       */
311      @SuppressWarnings({"unchecked", "cast"})
312      public List<ImportDecl> getImportDeclListNoTransform() {
313        return (List<ImportDecl>)getChildNoTransform(0);
314      }
315      /**
316       * Replaces the TypeDecl list.
317       * @param list The new list node to be used as the TypeDecl list.
318       * @apilevel high-level
319       * @ast method 
320       * 
321       */
322      public void setTypeDeclList(List<TypeDecl> list) {
323        setChild(list, 1);
324      }
325      /**
326       * Retrieves the number of children in the TypeDecl list.
327       * @return Number of children in the TypeDecl list.
328       * @apilevel high-level
329       * @ast method 
330       * 
331       */
332      public int getNumTypeDecl() {
333        return getTypeDeclList().getNumChild();
334      }
335      /**
336       * Retrieves the number of children in the TypeDecl list.
337       * Calling this method will not trigger rewrites..
338       * @return Number of children in the TypeDecl list.
339       * @apilevel low-level
340       * @ast method 
341       * 
342       */
343      public int getNumTypeDeclNoTransform() {
344        return getTypeDeclListNoTransform().getNumChildNoTransform();
345      }
346      /**
347       * Retrieves the element at index {@code i} in the TypeDecl list..
348       * @param i Index of the element to return.
349       * @return The element at position {@code i} in the TypeDecl list.
350       * @apilevel high-level
351       * @ast method 
352       * 
353       */
354      @SuppressWarnings({"unchecked", "cast"})
355      public TypeDecl getTypeDecl(int i) {
356        return (TypeDecl)getTypeDeclList().getChild(i);
357      }
358      /**
359       * Append an element to the TypeDecl list.
360       * @param node The element to append to the TypeDecl list.
361       * @apilevel high-level
362       * @ast method 
363       * 
364       */
365      public void addTypeDecl(TypeDecl node) {
366        List<TypeDecl> list = (parent == null || state == null) ? getTypeDeclListNoTransform() : getTypeDeclList();
367        list.addChild(node);
368      }
369      /**
370       * @apilevel low-level
371       * @ast method 
372       * 
373       */
374      public void addTypeDeclNoTransform(TypeDecl node) {
375        List<TypeDecl> list = getTypeDeclListNoTransform();
376        list.addChild(node);
377      }
378      /**
379       * Replaces the TypeDecl list element at index {@code i} with the new node {@code node}.
380       * @param node The new node to replace the old list element.
381       * @param i The list index of the node to be replaced.
382       * @apilevel high-level
383       * @ast method 
384       * 
385       */
386      public void setTypeDecl(TypeDecl node, int i) {
387        List<TypeDecl> list = getTypeDeclList();
388        list.setChild(node, i);
389      }
390      /**
391       * Retrieves the TypeDecl list.
392       * @return The node representing the TypeDecl list.
393       * @apilevel high-level
394       * @ast method 
395       * 
396       */
397      public List<TypeDecl> getTypeDecls() {
398        return getTypeDeclList();
399      }
400      /**
401       * Retrieves the TypeDecl list.
402       * <p><em>This method does not invoke AST transformations.</em></p>
403       * @return The node representing the TypeDecl list.
404       * @apilevel low-level
405       * @ast method 
406       * 
407       */
408      public List<TypeDecl> getTypeDeclsNoTransform() {
409        return getTypeDeclListNoTransform();
410      }
411      /**
412       * Retrieves the TypeDecl list.
413       * @return The node representing the TypeDecl list.
414       * @apilevel high-level
415       * @ast method 
416       * 
417       */
418      @SuppressWarnings({"unchecked", "cast"})
419      public List<TypeDecl> getTypeDeclList() {
420        List<TypeDecl> list = (List<TypeDecl>)getChild(1);
421        list.getNumChild();
422        return list;
423      }
424      /**
425       * Retrieves the TypeDecl list.
426       * <p><em>This method does not invoke AST transformations.</em></p>
427       * @return The node representing the TypeDecl list.
428       * @apilevel low-level
429       * @ast method 
430       * 
431       */
432      @SuppressWarnings({"unchecked", "cast"})
433      public List<TypeDecl> getTypeDeclListNoTransform() {
434        return (List<TypeDecl>)getChildNoTransform(1);
435      }
436      /**
437       * @apilevel internal
438       */
439      protected boolean typeWildcard_computed = false;
440      /**
441       * @apilevel internal
442       */
443      protected TypeDecl typeWildcard_value;
444      /**
445       * @attribute syn
446       * @aspect LookupParTypeDecl
447       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:1376
448       */
449      @SuppressWarnings({"unchecked", "cast"})
450      public TypeDecl typeWildcard() {
451        if(typeWildcard_computed) {
452          return typeWildcard_value;
453        }
454          ASTNode$State state = state();
455      int num = state.boundariesCrossed;
456      boolean isFinal = this.is$Final();
457        typeWildcard_value = typeWildcard_compute();
458        typeWildcard_value.setParent(this);
459        typeWildcard_value.is$Final = true;
460      if(true){ typeWildcard_computed = true; }
461            return typeWildcard_value;
462      }
463      /**
464       * @apilevel internal
465       */
466      private TypeDecl typeWildcard_compute() {
467        TypeDecl decl = new WildcardType(
468          new Modifiers(new List().add(new Modifier("public"))),
469          "?",
470          new List()
471        );
472        return decl;
473      }
474      /**
475       * @apilevel internal
476       */
477      protected java.util.Map lookupWildcardExtends_TypeDecl_values;
478      /**
479       * @apilevel internal
480       */
481      protected List lookupWildcardExtends_TypeDecl_list;
482      /**
483       * @attribute syn
484       * @aspect LookupParTypeDecl
485       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:1387
486       */
487      @SuppressWarnings({"unchecked", "cast"})
488      public TypeDecl lookupWildcardExtends(TypeDecl bound) {
489        Object _parameters = bound;
490        if(lookupWildcardExtends_TypeDecl_values == null) lookupWildcardExtends_TypeDecl_values = new java.util.HashMap(4);
491        if(lookupWildcardExtends_TypeDecl_values.containsKey(_parameters)) {
492          return (TypeDecl)lookupWildcardExtends_TypeDecl_values.get(_parameters);
493        }
494          ASTNode$State state = state();
495      int num = state.boundariesCrossed;
496      boolean isFinal = this.is$Final();
497        TypeDecl lookupWildcardExtends_TypeDecl_value = lookupWildcardExtends_compute(bound);
498        if(lookupWildcardExtends_TypeDecl_list == null) {
499          lookupWildcardExtends_TypeDecl_list = new List();
500          lookupWildcardExtends_TypeDecl_list.is$Final = true;
501          lookupWildcardExtends_TypeDecl_list.setParent(this);
502        }
503        lookupWildcardExtends_TypeDecl_list.add(lookupWildcardExtends_TypeDecl_value);
504        if(lookupWildcardExtends_TypeDecl_value != null) {
505          lookupWildcardExtends_TypeDecl_value = (TypeDecl)lookupWildcardExtends_TypeDecl_list.getChild(lookupWildcardExtends_TypeDecl_list.numChildren-1);
506          lookupWildcardExtends_TypeDecl_value.is$Final = true;
507        }
508      if(true){ lookupWildcardExtends_TypeDecl_values.put(_parameters, lookupWildcardExtends_TypeDecl_value); }
509            return lookupWildcardExtends_TypeDecl_value;
510      }
511      /**
512       * @apilevel internal
513       */
514      private TypeDecl lookupWildcardExtends_compute(TypeDecl bound) {
515        TypeDecl decl = new WildcardExtendsType(
516          new Modifiers(new List().add(new Modifier("public"))),
517          "? extends " + bound.fullName(),
518          new List(),
519          bound.createBoundAccess()
520        );
521        return decl;
522      }
523      /**
524       * @apilevel internal
525       */
526      protected java.util.Map lookupWildcardSuper_TypeDecl_values;
527      /**
528       * @apilevel internal
529       */
530      protected List lookupWildcardSuper_TypeDecl_list;
531      /**
532       * @attribute syn
533       * @aspect LookupParTypeDecl
534       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:1400
535       */
536      @SuppressWarnings({"unchecked", "cast"})
537      public TypeDecl lookupWildcardSuper(TypeDecl bound) {
538        Object _parameters = bound;
539        if(lookupWildcardSuper_TypeDecl_values == null) lookupWildcardSuper_TypeDecl_values = new java.util.HashMap(4);
540        if(lookupWildcardSuper_TypeDecl_values.containsKey(_parameters)) {
541          return (TypeDecl)lookupWildcardSuper_TypeDecl_values.get(_parameters);
542        }
543          ASTNode$State state = state();
544      int num = state.boundariesCrossed;
545      boolean isFinal = this.is$Final();
546        TypeDecl lookupWildcardSuper_TypeDecl_value = lookupWildcardSuper_compute(bound);
547        if(lookupWildcardSuper_TypeDecl_list == null) {
548          lookupWildcardSuper_TypeDecl_list = new List();
549          lookupWildcardSuper_TypeDecl_list.is$Final = true;
550          lookupWildcardSuper_TypeDecl_list.setParent(this);
551        }
552        lookupWildcardSuper_TypeDecl_list.add(lookupWildcardSuper_TypeDecl_value);
553        if(lookupWildcardSuper_TypeDecl_value != null) {
554          lookupWildcardSuper_TypeDecl_value = (TypeDecl)lookupWildcardSuper_TypeDecl_list.getChild(lookupWildcardSuper_TypeDecl_list.numChildren-1);
555          lookupWildcardSuper_TypeDecl_value.is$Final = true;
556        }
557      if(true){ lookupWildcardSuper_TypeDecl_values.put(_parameters, lookupWildcardSuper_TypeDecl_value); }
558            return lookupWildcardSuper_TypeDecl_value;
559      }
560      /**
561       * @apilevel internal
562       */
563      private TypeDecl lookupWildcardSuper_compute(TypeDecl bound) {
564        TypeDecl decl = new WildcardSuperType(
565          new Modifiers(new List().add(new Modifier("public"))),
566          "? super " + bound.fullName(),
567          new List(),
568          bound.createBoundAccess()
569        );
570        return decl;
571      }
572      /**
573       * @apilevel internal
574       */
575      protected java.util.Map lookupLUBType_Collection_values;
576      /**
577       * @apilevel internal
578       */
579      protected List lookupLUBType_Collection_list;
580      /**
581       * @attribute syn
582       * @aspect LookupParTypeDecl
583       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:1413
584       */
585      @SuppressWarnings({"unchecked", "cast"})
586      public LUBType lookupLUBType(Collection bounds) {
587        Object _parameters = bounds;
588        if(lookupLUBType_Collection_values == null) lookupLUBType_Collection_values = new java.util.HashMap(4);
589        if(lookupLUBType_Collection_values.containsKey(_parameters)) {
590          return (LUBType)lookupLUBType_Collection_values.get(_parameters);
591        }
592          ASTNode$State state = state();
593      int num = state.boundariesCrossed;
594      boolean isFinal = this.is$Final();
595        LUBType lookupLUBType_Collection_value = lookupLUBType_compute(bounds);
596        if(lookupLUBType_Collection_list == null) {
597          lookupLUBType_Collection_list = new List();
598          lookupLUBType_Collection_list.is$Final = true;
599          lookupLUBType_Collection_list.setParent(this);
600        }
601        lookupLUBType_Collection_list.add(lookupLUBType_Collection_value);
602        if(lookupLUBType_Collection_value != null) {
603          lookupLUBType_Collection_value = (LUBType)lookupLUBType_Collection_list.getChild(lookupLUBType_Collection_list.numChildren-1);
604          lookupLUBType_Collection_value.is$Final = true;
605        }
606      if(true){ lookupLUBType_Collection_values.put(_parameters, lookupLUBType_Collection_value); }
607            return lookupLUBType_Collection_value;
608      }
609      /**
610       * @apilevel internal
611       */
612      private LUBType lookupLUBType_compute(Collection bounds) {  return createLUBType(bounds);  }
613      /**
614       * @apilevel internal
615       */
616      protected java.util.Map lookupGLBType_ArrayList_values;
617      /**
618       * @apilevel internal
619       */
620      protected List lookupGLBType_ArrayList_list;
621      /**
622       * @attribute syn
623       * @aspect LookupParTypeDecl
624       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:1452
625       */
626      @SuppressWarnings({"unchecked", "cast"})
627      public GLBType lookupGLBType(ArrayList bounds) {
628        Object _parameters = bounds;
629        if(lookupGLBType_ArrayList_values == null) lookupGLBType_ArrayList_values = new java.util.HashMap(4);
630        if(lookupGLBType_ArrayList_values.containsKey(_parameters)) {
631          return (GLBType)lookupGLBType_ArrayList_values.get(_parameters);
632        }
633          ASTNode$State state = state();
634      int num = state.boundariesCrossed;
635      boolean isFinal = this.is$Final();
636        GLBType lookupGLBType_ArrayList_value = lookupGLBType_compute(bounds);
637        if(lookupGLBType_ArrayList_list == null) {
638          lookupGLBType_ArrayList_list = new List();
639          lookupGLBType_ArrayList_list.is$Final = true;
640          lookupGLBType_ArrayList_list.setParent(this);
641        }
642        lookupGLBType_ArrayList_list.add(lookupGLBType_ArrayList_value);
643        if(lookupGLBType_ArrayList_value != null) {
644          lookupGLBType_ArrayList_value = (GLBType)lookupGLBType_ArrayList_list.getChild(lookupGLBType_ArrayList_list.numChildren-1);
645          lookupGLBType_ArrayList_value.is$Final = true;
646        }
647      if(true){ lookupGLBType_ArrayList_values.put(_parameters, lookupGLBType_ArrayList_value); }
648            return lookupGLBType_ArrayList_value;
649      }
650      /**
651       * @apilevel internal
652       */
653      private GLBType lookupGLBType_compute(ArrayList bounds) {
654        List boundList = new List();
655        StringBuffer name = new StringBuffer();
656        for(Iterator iter = bounds.iterator(); iter.hasNext(); ) {
657          TypeDecl typeDecl = (TypeDecl)iter.next();
658          boundList.add(typeDecl.createBoundAccess());
659          name.append("& " + typeDecl.typeName());
660        }
661        GLBType decl = new GLBType(
662          new Modifiers(new List().add(new Modifier("public"))),
663          name.toString(),
664          new List(),
665          boundList
666        );
667        return decl;
668      }
669      /**
670       * @apilevel internal
671       */
672      public ASTNode rewriteTo() {
673        return super.rewriteTo();
674      }
675    }