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 AmbiguousAccess : {@link Access} ::= <span class="component">&lt;ID:String&gt;</span>;
015     * @ast node
016     * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/java.ast:35
017     */
018    public class AmbiguousAccess extends Access 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 AmbiguousAccess clone() throws CloneNotSupportedException {
034        AmbiguousAccess node = (AmbiguousAccess)super.clone();
035        node.in$Circle(false);
036        node.is$Final(false);
037        return node;
038      }
039    /**
040     * @apilevel internal
041     */
042      @SuppressWarnings({"unchecked", "cast"})
043    public AmbiguousAccess copy() {
044      
045      try {
046        AmbiguousAccess node = (AmbiguousAccess) clone();
047        node.parent = null;
048        if(children != null)
049          node.children = (ASTNode[]) children.clone();
050        
051        return node;
052      } catch (CloneNotSupportedException e) {
053        throw new Error("Error: clone not supported for " + getClass().getName());
054      }
055      
056    }/**
057     * Create a deep copy of the AST subtree at this node.
058     * The copy is dangling, i.e. has no parent.
059     * @return dangling copy of the subtree at this node
060     * @apilevel low-level
061     */
062      @SuppressWarnings({"unchecked", "cast"})
063    public AmbiguousAccess fullCopy() {
064      
065      AmbiguousAccess tree = (AmbiguousAccess) copy();
066      if (children != null) {
067        for (int i = 0; i < children.length; ++i) {
068          
069          ASTNode child = (ASTNode) children[i];
070          if(child != null) {
071            child = child.fullCopy();
072            tree.setChild(child, i);
073          }
074        }
075      }
076      return tree;
077      
078    }  /**
079       * @ast method 
080       * @aspect NameCheck
081       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/NameCheck.jrag:56
082       */
083      public void nameCheck() {
084        error("ambiguous name " + name());
085      }
086      /**
087       * @ast method 
088       * @aspect NodeConstructors
089       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/NodeConstructors.jrag:33
090       */
091      public AmbiguousAccess(String name, int start, int end) {
092        this(name);
093        this.start = this.IDstart = start;
094        this.end = this.IDend = end;
095      }
096      /**
097       * @ast method 
098       * 
099       */
100      public AmbiguousAccess() {
101        super();
102    
103    
104      }
105      /**
106       * Initializes the child array to the correct size.
107       * Initializes List and Opt nta children.
108       * @apilevel internal
109       * @ast method
110       * @ast method 
111       * 
112       */
113      public void init$Children() {
114      }
115      /**
116       * @ast method 
117       * 
118       */
119      public AmbiguousAccess(String p0) {
120        setID(p0);
121      }
122      /**
123       * @ast method 
124       * 
125       */
126      public AmbiguousAccess(beaver.Symbol p0) {
127        setID(p0);
128      }
129      /**
130       * @apilevel low-level
131       * @ast method 
132       * 
133       */
134      protected int numChildren() {
135        return 0;
136      }
137      /**
138       * @apilevel internal
139       * @ast method 
140       * 
141       */
142      public boolean mayHaveRewrite() {
143        return true;
144      }
145      /**
146       * Replaces the lexeme ID.
147       * @param value The new value for the lexeme ID.
148       * @apilevel high-level
149       * @ast method 
150       * 
151       */
152      public void setID(String value) {
153        tokenString_ID = value;
154      }
155      /**
156       * @apilevel internal
157       * @ast method 
158       * 
159       */
160      
161      /**
162       * @apilevel internal
163       */
164      protected String tokenString_ID;
165      /**
166       * @ast method 
167       * 
168       */
169      
170      public int IDstart;
171      /**
172       * @ast method 
173       * 
174       */
175      
176      public int IDend;
177      /**
178       * JastAdd-internal setter for lexeme ID using the Beaver parser.
179       * @apilevel internal
180       * @ast method 
181       * 
182       */
183      public void setID(beaver.Symbol symbol) {
184        if(symbol.value != null && !(symbol.value instanceof String))
185          throw new UnsupportedOperationException("setID is only valid for String lexemes");
186        tokenString_ID = (String)symbol.value;
187        IDstart = symbol.getStart();
188        IDend = symbol.getEnd();
189      }
190      /**
191       * Retrieves the value for the lexeme ID.
192       * @return The value for the lexeme ID.
193       * @apilevel high-level
194       * @ast method 
195       * 
196       */
197      public String getID() {
198        return tokenString_ID != null ? tokenString_ID : "";
199      }
200      /**
201       * @attribute syn
202       * @aspect TypeScopePropagation
203       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/LookupType.jrag:430
204       */
205      public SimpleSet qualifiedLookupType(String name) {
206        ASTNode$State state = state();
207        try {  return SimpleSet.emptySet;  }
208        finally {
209        }
210      }
211      /**
212       * @attribute syn
213       * @aspect VariableScope
214       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/LookupVariable.jrag:148
215       */
216      public SimpleSet qualifiedLookupVariable(String name) {
217        ASTNode$State state = state();
218        try {  return SimpleSet.emptySet;  }
219        finally {
220        }
221      }
222      /**
223       * @attribute syn
224       * @aspect PrettyPrint
225       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/PrettyPrint.jadd:800
226       */
227      public String dumpString() {
228        ASTNode$State state = state();
229        try {  return getClass().getName() + " [" + getID() + "]";  }
230        finally {
231        }
232      }
233      /**
234       * @attribute syn
235       * @aspect Names
236       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/QualifiedNames.jrag:16
237       */
238      public String name() {
239        ASTNode$State state = state();
240        try {  return getID();  }
241        finally {
242        }
243      }
244      /**
245       * @attribute syn
246       * @aspect SyntacticClassification
247       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/SyntacticClassification.jrag:56
248       */
249      public NameType predNameType() {
250        ASTNode$State state = state();
251        try {  return NameType.AMBIGUOUS_NAME;  }
252        finally {
253        }
254      }
255      /**
256       * @apilevel internal
257       */
258      public ASTNode rewriteTo() {
259        // Declared in /home/jesper/svn/JastAddJ/Java1.4Frontend/ResolveAmbiguousNames.jrag at line 194
260        if(!duringSyntacticClassification()) {
261          state().duringNameResolution++;
262          ASTNode result = rewriteRule0();
263          state().duringNameResolution--;
264          return result;
265        }
266    
267        return super.rewriteTo();
268      }
269      /**
270       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/ResolveAmbiguousNames.jrag:194
271       * @apilevel internal
272       */  private Access rewriteRule0() {
273    {
274          if(!lookupVariable(name()).isEmpty()) {
275            return new VarAccess(name(), start(), end());
276          }
277          else if(!lookupType(name()).isEmpty()) {
278            return new TypeAccess(name(), start(), end());
279          }
280          else {
281            return new PackageAccess(name(), start(), end());
282          }
283        }  }
284    }