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     * 7.5.3 A single-static-import declaration imports all accessible (\u00a76.6) static members
015     * with a given simple name from a type. This makes these static members available
016     * under their simple name in the class and interface declarations of the
017     * compilation unit in which the single-static import declaration appears.
018     * @production SingleStaticImportDecl : {@link StaticImportDecl} ::= <span class="component">&lt;ID:String&gt;</span>;
019     * @ast node
020     * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/StaticImports.ast:12
021     */
022    public class SingleStaticImportDecl extends StaticImportDecl implements Cloneable {
023      /**
024       * @apilevel low-level
025       */
026      public void flushCache() {
027      }
028      /**
029       * @apilevel internal
030       */
031      public void flushCollectionCache() {
032      }
033      /**
034       * @apilevel internal
035       */
036      @SuppressWarnings({"unchecked", "cast"})
037      public SingleStaticImportDecl clone() throws CloneNotSupportedException {
038        SingleStaticImportDecl node = (SingleStaticImportDecl)super.clone();
039        node.in$Circle(false);
040        node.is$Final(false);
041        return node;
042      }
043    /**
044     * @apilevel internal
045     */
046      @SuppressWarnings({"unchecked", "cast"})
047    public SingleStaticImportDecl copy() {
048      
049      try {
050        SingleStaticImportDecl node = (SingleStaticImportDecl) clone();
051        node.parent = null;
052        if(children != null)
053          node.children = (ASTNode[]) children.clone();
054        
055        return node;
056      } catch (CloneNotSupportedException e) {
057        throw new Error("Error: clone not supported for " + getClass().getName());
058      }
059      
060    }/**
061     * Create a deep copy of the AST subtree at this node.
062     * The copy is dangling, i.e. has no parent.
063     * @return dangling copy of the subtree at this node
064     * @apilevel low-level
065     */
066      @SuppressWarnings({"unchecked", "cast"})
067    public SingleStaticImportDecl fullCopy() {
068      
069      SingleStaticImportDecl tree = (SingleStaticImportDecl) copy();
070      if (children != null) {
071        for (int i = 0; i < children.length; ++i) {
072          
073          ASTNode child = (ASTNode) children[i];
074          if(child != null) {
075            child = child.fullCopy();
076            tree.setChild(child, i);
077          }
078        }
079      }
080      return tree;
081      
082    }  /**
083       * @ast method 
084       * @aspect StaticImports
085       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/StaticImports.jrag:61
086       */
087      public void typeCheck() { 
088        if(!getAccess().type().typeName().equals(typeName()) && !getAccess().type().isUnknown())
089          error("Single-type import " + typeName() + " is not the canonical name of type " + getAccess().type().typeName());
090      }
091      /**
092       * @ast method 
093       * @aspect StaticImports
094       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/StaticImports.jrag:93
095       */
096      public void nameCheck() {
097        if(importedFields(name()).isEmpty() && importedMethods(name()).isEmpty() && importedTypes(name()).isEmpty() &&
098           !getAccess().type().isUnknown()) {
099          error("Semantic Error: At least one static member named " + name() + " must be available in static imported type " + type().fullName());
100        }
101      }
102      /**
103       * @ast method 
104       * @aspect StaticImports
105       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/StaticImports.jrag:207
106       */
107      public void toString(StringBuffer s) {
108        s.append("import static ");
109        getAccess().toString(s);
110        s.append("." + getID());
111        s.append(";\n");
112      }
113      /**
114       * @ast method 
115       * 
116       */
117      public SingleStaticImportDecl() {
118        super();
119    
120    
121      }
122      /**
123       * Initializes the child array to the correct size.
124       * Initializes List and Opt nta children.
125       * @apilevel internal
126       * @ast method
127       * @ast method 
128       * 
129       */
130      public void init$Children() {
131        children = new ASTNode[1];
132      }
133      /**
134       * @ast method 
135       * 
136       */
137      public SingleStaticImportDecl(Access p0, String p1) {
138        setChild(p0, 0);
139        setID(p1);
140      }
141      /**
142       * @ast method 
143       * 
144       */
145      public SingleStaticImportDecl(Access p0, beaver.Symbol p1) {
146        setChild(p0, 0);
147        setID(p1);
148      }
149      /**
150       * @apilevel low-level
151       * @ast method 
152       * 
153       */
154      protected int numChildren() {
155        return 1;
156      }
157      /**
158       * @apilevel internal
159       * @ast method 
160       * 
161       */
162      public boolean mayHaveRewrite() {
163        return false;
164      }
165      /**
166       * Replaces the Access child.
167       * @param node The new node to replace the Access child.
168       * @apilevel high-level
169       * @ast method 
170       * 
171       */
172      public void setAccess(Access node) {
173        setChild(node, 0);
174      }
175      /**
176       * Retrieves the Access child.
177       * @return The current node used as the Access child.
178       * @apilevel high-level
179       * @ast method 
180       * 
181       */
182      public Access getAccess() {
183        return (Access)getChild(0);
184      }
185      /**
186       * Retrieves the Access child.
187       * <p><em>This method does not invoke AST transformations.</em></p>
188       * @return The current node used as the Access child.
189       * @apilevel low-level
190       * @ast method 
191       * 
192       */
193      public Access getAccessNoTransform() {
194        return (Access)getChildNoTransform(0);
195      }
196      /**
197       * Replaces the lexeme ID.
198       * @param value The new value for the lexeme ID.
199       * @apilevel high-level
200       * @ast method 
201       * 
202       */
203      public void setID(String value) {
204        tokenString_ID = value;
205      }
206      /**
207       * @apilevel internal
208       * @ast method 
209       * 
210       */
211      
212      /**
213       * @apilevel internal
214       */
215      protected String tokenString_ID;
216      /**
217       * @ast method 
218       * 
219       */
220      
221      public int IDstart;
222      /**
223       * @ast method 
224       * 
225       */
226      
227      public int IDend;
228      /**
229       * JastAdd-internal setter for lexeme ID using the Beaver parser.
230       * @apilevel internal
231       * @ast method 
232       * 
233       */
234      public void setID(beaver.Symbol symbol) {
235        if(symbol.value != null && !(symbol.value instanceof String))
236          throw new UnsupportedOperationException("setID is only valid for String lexemes");
237        tokenString_ID = (String)symbol.value;
238        IDstart = symbol.getStart();
239        IDend = symbol.getEnd();
240      }
241      /**
242       * Retrieves the value for the lexeme ID.
243       * @return The value for the lexeme ID.
244       * @apilevel high-level
245       * @ast method 
246       * 
247       */
248      public String getID() {
249        return tokenString_ID != null ? tokenString_ID : "";
250      }
251      /**
252       * @attribute syn
253       * @aspect StaticImports
254       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/StaticImports.jrag:53
255       */
256      public TypeDecl type() {
257        ASTNode$State state = state();
258        try {  return getAccess().type();  }
259        finally {
260        }
261      }
262      /**
263       * @attribute syn
264       * @aspect StaticImports
265       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/StaticImports.jrag:99
266       */
267      public String name() {
268        ASTNode$State state = state();
269        try {  return getID();  }
270        finally {
271        }
272      }
273      /**
274       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/StaticImports.jrag:203
275       * @apilevel internal
276       */
277      public NameType Define_NameType_nameType(ASTNode caller, ASTNode child) {
278        if(caller == getAccessNoTransform()) {
279          return NameType.TYPE_NAME;
280        }
281        else {      return getParent().Define_NameType_nameType(this, caller);
282        }
283      }
284      /**
285       * @apilevel internal
286       */
287      public ASTNode rewriteTo() {
288        return super.rewriteTo();
289      }
290    }