001    /* This file was generated with JastAdd2 (http://jastadd.org) version 2.1.13-12-g880e696 */
002    package org.extendj.ast;
003    
004    import java.util.HashSet;
005    import java.io.File;
006    import java.util.Set;
007    import java.util.Collections;
008    import java.util.Collection;
009    import java.util.ArrayList;
010    import beaver.*;
011    import java.util.*;
012    import java.io.ByteArrayOutputStream;
013    import java.io.PrintStream;
014    import java.lang.reflect.InvocationTargetException;
015    import java.lang.reflect.Method;
016    import org.jastadd.util.*;
017    import java.util.zip.*;
018    import java.io.*;
019    import org.jastadd.util.PrettyPrintable;
020    import org.jastadd.util.PrettyPrinter;
021    import java.io.FileNotFoundException;
022    import java.io.BufferedInputStream;
023    import java.io.DataInputStream;
024    /**
025     * 7.5.4 A static-import-on-demand declaration allows all accessible (\u00a76.6) static
026     * members declared in the type named by a canonical name to be imported as
027     * needed.
028     * @ast node
029     * @declaredat /home/jesper/git/extendj/java5/grammar/StaticImports.ast:19
030     * @production StaticImportOnDemandDecl : {@link StaticImportDecl};
031    
032     */
033    public class StaticImportOnDemandDecl extends StaticImportDecl implements Cloneable {
034      /**
035       * @aspect Java5PrettyPrint
036       * @declaredat /home/jesper/git/extendj/java5/frontend/PrettyPrint.jadd:328
037       */
038      public void prettyPrint(PrettyPrinter out) {
039        out.print("import static ");
040        out.print(getAccess());
041        out.print(".*;");
042      }
043      /**
044       * The TypeName must be the canonical name of a class or interface type
045       * @aspect StaticImports
046       * @declaredat /home/jesper/git/extendj/java5/frontend/StaticImports.jrag:118
047       */
048      public void nameCheck() {
049        if (!getAccess().type().typeName().equals(typeName())) {
050          errorf("In on-demand import: %s is not the canonical name of type %s",
051              typeName(), getAccess().type().typeName());
052        }
053      }
054      /**
055       * @declaredat ASTNode:1
056       */
057      public StaticImportOnDemandDecl() {
058        super();
059      }
060      /**
061       * Initializes the child array to the correct size.
062       * Initializes List and Opt nta children.
063       * @apilevel internal
064       * @ast method
065       * @declaredat ASTNode:10
066       */
067      public void init$Children() {
068        children = new ASTNode[1];
069      }
070      /**
071       * @declaredat ASTNode:13
072       */
073      public StaticImportOnDemandDecl(Access p0) {
074        setChild(p0, 0);
075      }
076      /**
077       * @apilevel low-level
078       * @declaredat ASTNode:19
079       */
080      protected int numChildren() {
081        return 1;
082      }
083      /**
084       * @apilevel internal
085       * @declaredat ASTNode:25
086       */
087      public boolean mayHaveRewrite() {
088        return false;
089      }
090      /**
091       * @apilevel internal
092       * @declaredat ASTNode:31
093       */
094      public void flushAttrCache() {
095        super.flushAttrCache();
096      }
097      /**
098       * @apilevel internal
099       * @declaredat ASTNode:37
100       */
101      public void flushCollectionCache() {
102        super.flushCollectionCache();
103      }
104      /**
105       * @apilevel internal
106       * @declaredat ASTNode:43
107       */
108      public void flushRewriteCache() {
109        super.flushRewriteCache();
110      }
111      /**
112       * @apilevel internal
113       * @declaredat ASTNode:49
114       */
115      public StaticImportOnDemandDecl clone() throws CloneNotSupportedException {
116        StaticImportOnDemandDecl node = (StaticImportOnDemandDecl) super.clone();
117        return node;
118      }
119      /**
120       * @apilevel internal
121       * @declaredat ASTNode:56
122       */
123      public StaticImportOnDemandDecl copy() {
124        try {
125          StaticImportOnDemandDecl node = (StaticImportOnDemandDecl) clone();
126          node.parent = null;
127          if (children != null) {
128            node.children = (ASTNode[]) children.clone();
129          }
130          return node;
131        } catch (CloneNotSupportedException e) {
132          throw new Error("Error: clone not supported for " + getClass().getName());
133        }
134      }
135      /**
136       * Create a deep copy of the AST subtree at this node.
137       * The copy is dangling, i.e. has no parent.
138       * @return dangling copy of the subtree at this node
139       * @apilevel low-level
140       * @deprecated Please use treeCopy or treeCopyNoTransform instead
141       * @declaredat ASTNode:75
142       */
143      @Deprecated
144      public StaticImportOnDemandDecl fullCopy() {
145        return treeCopyNoTransform();
146      }
147      /**
148       * Create a deep copy of the AST subtree at this node.
149       * The copy is dangling, i.e. has no parent.
150       * @return dangling copy of the subtree at this node
151       * @apilevel low-level
152       * @declaredat ASTNode:85
153       */
154      public StaticImportOnDemandDecl treeCopyNoTransform() {
155        StaticImportOnDemandDecl tree = (StaticImportOnDemandDecl) copy();
156        if (children != null) {
157          for (int i = 0; i < children.length; ++i) {
158            ASTNode child = (ASTNode) children[i];
159            if (child != null) {
160              child = child.treeCopyNoTransform();
161              tree.setChild(child, i);
162            }
163          }
164        }
165        return tree;
166      }
167      /**
168       * Create a deep copy of the AST subtree at this node.
169       * The subtree of this node is traversed to trigger rewrites before copy.
170       * The copy is dangling, i.e. has no parent.
171       * @return dangling copy of the subtree at this node
172       * @apilevel low-level
173       * @declaredat ASTNode:105
174       */
175      public StaticImportOnDemandDecl treeCopy() {
176        doFullTraversal();
177        return treeCopyNoTransform();
178      }
179      /**
180       * @apilevel internal
181       * @declaredat ASTNode:112
182       */
183      protected boolean is$Equal(ASTNode node) {
184        return super.is$Equal(node);    
185      }
186      /**
187       * Replaces the Access child.
188       * @param node The new node to replace the Access child.
189       * @apilevel high-level
190       */
191      public void setAccess(Access node) {
192        setChild(node, 0);
193      }
194      /**
195       * Retrieves the Access child.
196       * @return The current node used as the Access child.
197       * @apilevel high-level
198       */
199      @ASTNodeAnnotation.Child(name="Access")
200      public Access getAccess() {
201        return (Access) getChild(0);
202      }
203      /**
204       * Retrieves the Access child.
205       * <p><em>This method does not invoke AST transformations.</em></p>
206       * @return The current node used as the Access child.
207       * @apilevel low-level
208       */
209      public Access getAccessNoTransform() {
210        return (Access) getChildNoTransform(0);
211      }
212      /**
213       * @attribute syn
214       * @aspect StaticImports
215       * @declaredat /home/jesper/git/extendj/java5/frontend/StaticImports.jrag:95
216       */
217      @ASTNodeAnnotation.Attribute
218      public TypeDecl type() {
219        TypeDecl type_value = getAccess().type();
220    
221        return type_value;
222      }
223      /**
224       * @attribute syn
225       * @aspect TypeScopePropagation
226       * @declaredat /home/jesper/git/extendj/java4/frontend/LookupType.jrag:466
227       */
228      @ASTNodeAnnotation.Attribute
229      public boolean isOnDemand() {
230        boolean isOnDemand_value = true;
231    
232        return isOnDemand_value;
233      }
234      /**
235       * @declaredat /home/jesper/git/extendj/java4/frontend/SyntacticClassification.jrag:36
236       * @apilevel internal
237       */
238      public NameType Define_nameType(ASTNode caller, ASTNode child) {
239        if (caller == getAccessNoTransform()) {
240          // @declaredat /home/jesper/git/extendj/java5/frontend/StaticImports.jrag:296
241          return NameType.TYPE_NAME;
242        }
243        else {
244          return getParent().Define_nameType(this, caller);
245        }
246      }
247      protected boolean canDefine_nameType(ASTNode caller, ASTNode child) {
248        return true;
249      }
250      /**
251       * @apilevel internal
252       */
253      public ASTNode rewriteTo() {
254        return super.rewriteTo();
255      }
256    }