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 SingleTypeImportDecl : {@link ImportDecl};
015     * @ast node
016     * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/java.ast:11
017     */
018    public class SingleTypeImportDecl extends ImportDecl 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 SingleTypeImportDecl clone() throws CloneNotSupportedException {
034        SingleTypeImportDecl node = (SingleTypeImportDecl)super.clone();
035        node.importedTypes_String_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 SingleTypeImportDecl copy() {
045      
046      try {
047        SingleTypeImportDecl node = (SingleTypeImportDecl) 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 SingleTypeImportDecl fullCopy() {
065      
066      SingleTypeImportDecl tree = (SingleTypeImportDecl) 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 NameCheck
082       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/NameCheck.jrag:20
083       */
084      public void nameCheck() {
085        if(!getAccess().type().typeName().equals(typeName()) && !getAccess().type().isUnknown())
086          error("Single-type import " + typeName() + " is not the canonical name of type " + getAccess().type().typeName());
087        else if(allImportedTypes(getAccess().type().name()).size() > 1)
088          error(getAccess().type().name() + " is imported multiple times");
089      }
090      /**
091       * @ast method 
092       * @aspect PrettyPrint
093       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/PrettyPrint.jadd:50
094       */
095      public void toString(StringBuffer s) {
096        s.append("import ");
097        getAccess().toString(s);
098        s.append(";\n");
099      }
100      /**
101       * @ast method 
102       * 
103       */
104      public SingleTypeImportDecl() {
105        super();
106    
107    
108      }
109      /**
110       * Initializes the child array to the correct size.
111       * Initializes List and Opt nta children.
112       * @apilevel internal
113       * @ast method
114       * @ast method 
115       * 
116       */
117      public void init$Children() {
118        children = new ASTNode[1];
119      }
120      /**
121       * @ast method 
122       * 
123       */
124      public SingleTypeImportDecl(Access p0) {
125        setChild(p0, 0);
126      }
127      /**
128       * @apilevel low-level
129       * @ast method 
130       * 
131       */
132      protected int numChildren() {
133        return 1;
134      }
135      /**
136       * @apilevel internal
137       * @ast method 
138       * 
139       */
140      public boolean mayHaveRewrite() {
141        return false;
142      }
143      /**
144       * Replaces the Access child.
145       * @param node The new node to replace the Access child.
146       * @apilevel high-level
147       * @ast method 
148       * 
149       */
150      public void setAccess(Access node) {
151        setChild(node, 0);
152      }
153      /**
154       * Retrieves the Access child.
155       * @return The current node used as the Access child.
156       * @apilevel high-level
157       * @ast method 
158       * 
159       */
160      public Access getAccess() {
161        return (Access)getChild(0);
162      }
163      /**
164       * Retrieves the Access child.
165       * <p><em>This method does not invoke AST transformations.</em></p>
166       * @return The current node used as the Access child.
167       * @apilevel low-level
168       * @ast method 
169       * 
170       */
171      public Access getAccessNoTransform() {
172        return (Access)getChildNoTransform(0);
173      }
174      protected java.util.Map importedTypes_String_values;
175      /**
176       * @attribute syn
177       * @aspect TypeScopePropagation
178       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/LookupType.jrag:323
179       */
180      @SuppressWarnings({"unchecked", "cast"})
181      public SimpleSet importedTypes(String name) {
182        Object _parameters = name;
183        if(importedTypes_String_values == null) importedTypes_String_values = new java.util.HashMap(4);
184        if(importedTypes_String_values.containsKey(_parameters)) {
185          return (SimpleSet)importedTypes_String_values.get(_parameters);
186        }
187          ASTNode$State state = state();
188      int num = state.boundariesCrossed;
189      boolean isFinal = this.is$Final();
190        SimpleSet importedTypes_String_value = importedTypes_compute(name);
191      if(isFinal && num == state().boundariesCrossed){ importedTypes_String_values.put(_parameters, importedTypes_String_value); }
192            return importedTypes_String_value;
193      }
194      /**
195       * @apilevel internal
196       */
197      private SimpleSet importedTypes_compute(String name) {
198        SimpleSet set = SimpleSet.emptySet;
199        if(getAccess().type().name().equals(name))
200          set = set.add(getAccess().type());
201        return set;
202      }
203      /**
204       * @attribute inh
205       * @aspect NameCheck
206       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/NameCheck.jrag:26
207       */
208      @SuppressWarnings({"unchecked", "cast"})
209      public SimpleSet allImportedTypes(String name) {
210          ASTNode$State state = state();
211        SimpleSet allImportedTypes_String_value = getParent().Define_SimpleSet_allImportedTypes(this, null, name);
212            return allImportedTypes_String_value;
213      }
214      /**
215       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/SyntacticClassification.jrag:72
216       * @apilevel internal
217       */
218      public NameType Define_NameType_nameType(ASTNode caller, ASTNode child) {
219        if(caller == getAccessNoTransform()) {
220          return NameType.TYPE_NAME;
221        }
222        else {      return getParent().Define_NameType_nameType(this, caller);
223        }
224      }
225      /**
226       * @apilevel internal
227       */
228      public ASTNode rewriteTo() {
229        return super.rewriteTo();
230      }
231    }