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     * @ast node
026     * @declaredat /home/jesper/git/extendj/java4/grammar/Java.ast:43
027     * @production EmptyType : {@link PrimitiveType};
028    
029     */
030    public class EmptyType extends PrimitiveType implements Cloneable {
031      /**
032       * @aspect Java4PrettyPrint
033       * @declaredat /home/jesper/git/extendj/java4/frontend/PrettyPrint.jadd:269
034       */
035      public void prettyPrint(PrettyPrinter out) {
036        out.print(";");
037      }
038      /**
039       * @declaredat ASTNode:1
040       */
041      public EmptyType() {
042        super();
043      }
044      /**
045       * Initializes the child array to the correct size.
046       * Initializes List and Opt nta children.
047       * @apilevel internal
048       * @ast method
049       * @declaredat ASTNode:10
050       */
051      public void init$Children() {
052        children = new ASTNode[3];
053        setChild(new Opt(), 1);
054        setChild(new List(), 2);
055      }
056      /**
057       * @declaredat ASTNode:15
058       */
059      public EmptyType(Modifiers p0, String p1, Opt<Access> p2, List<BodyDecl> p3) {
060        setChild(p0, 0);
061        setID(p1);
062        setChild(p2, 1);
063        setChild(p3, 2);
064      }
065      /**
066       * @declaredat ASTNode:21
067       */
068      public EmptyType(Modifiers p0, beaver.Symbol p1, Opt<Access> p2, List<BodyDecl> p3) {
069        setChild(p0, 0);
070        setID(p1);
071        setChild(p2, 1);
072        setChild(p3, 2);
073      }
074      /**
075       * @apilevel low-level
076       * @declaredat ASTNode:30
077       */
078      protected int numChildren() {
079        return 3;
080      }
081      /**
082       * @apilevel internal
083       * @declaredat ASTNode:36
084       */
085      public boolean mayHaveRewrite() {
086        return false;
087      }
088      /**
089       * @apilevel internal
090       * @declaredat ASTNode:42
091       */
092      public void flushAttrCache() {
093        super.flushAttrCache();
094      }
095      /**
096       * @apilevel internal
097       * @declaredat ASTNode:48
098       */
099      public void flushCollectionCache() {
100        super.flushCollectionCache();
101      }
102      /**
103       * @apilevel internal
104       * @declaredat ASTNode:54
105       */
106      public void flushRewriteCache() {
107        super.flushRewriteCache();
108      }
109      /**
110       * @apilevel internal
111       * @declaredat ASTNode:60
112       */
113      public EmptyType clone() throws CloneNotSupportedException {
114        EmptyType node = (EmptyType) super.clone();
115        return node;
116      }
117      /**
118       * @apilevel internal
119       * @declaredat ASTNode:67
120       */
121      public EmptyType copy() {
122        try {
123          EmptyType node = (EmptyType) clone();
124          node.parent = null;
125          if (children != null) {
126            node.children = (ASTNode[]) children.clone();
127          }
128          return node;
129        } catch (CloneNotSupportedException e) {
130          throw new Error("Error: clone not supported for " + getClass().getName());
131        }
132      }
133      /**
134       * Create a deep copy of the AST subtree at this node.
135       * The copy is dangling, i.e. has no parent.
136       * @return dangling copy of the subtree at this node
137       * @apilevel low-level
138       * @deprecated Please use treeCopy or treeCopyNoTransform instead
139       * @declaredat ASTNode:86
140       */
141      @Deprecated
142      public EmptyType fullCopy() {
143        return treeCopyNoTransform();
144      }
145      /**
146       * Create a deep copy of the AST subtree at this node.
147       * The copy is dangling, i.e. has no parent.
148       * @return dangling copy of the subtree at this node
149       * @apilevel low-level
150       * @declaredat ASTNode:96
151       */
152      public EmptyType treeCopyNoTransform() {
153        EmptyType tree = (EmptyType) copy();
154        if (children != null) {
155          for (int i = 0; i < children.length; ++i) {
156            ASTNode child = (ASTNode) children[i];
157            if (child != null) {
158              child = child.treeCopyNoTransform();
159              tree.setChild(child, i);
160            }
161          }
162        }
163        return tree;
164      }
165      /**
166       * Create a deep copy of the AST subtree at this node.
167       * The subtree of this node is traversed to trigger rewrites before copy.
168       * The copy is dangling, i.e. has no parent.
169       * @return dangling copy of the subtree at this node
170       * @apilevel low-level
171       * @declaredat ASTNode:116
172       */
173      public EmptyType treeCopy() {
174        doFullTraversal();
175        return treeCopyNoTransform();
176      }
177      /**
178       * @apilevel internal
179       * @declaredat ASTNode:123
180       */
181      protected boolean is$Equal(ASTNode node) {
182        return super.is$Equal(node) && (tokenString_ID == ((EmptyType)node).tokenString_ID);    
183      }
184      /**
185       * Replaces the Modifiers child.
186       * @param node The new node to replace the Modifiers child.
187       * @apilevel high-level
188       */
189      public void setModifiers(Modifiers node) {
190        setChild(node, 0);
191      }
192      /**
193       * Retrieves the Modifiers child.
194       * @return The current node used as the Modifiers child.
195       * @apilevel high-level
196       */
197      @ASTNodeAnnotation.Child(name="Modifiers")
198      public Modifiers getModifiers() {
199        return (Modifiers) getChild(0);
200      }
201      /**
202       * Retrieves the Modifiers child.
203       * <p><em>This method does not invoke AST transformations.</em></p>
204       * @return The current node used as the Modifiers child.
205       * @apilevel low-level
206       */
207      public Modifiers getModifiersNoTransform() {
208        return (Modifiers) getChildNoTransform(0);
209      }
210      /**
211       * Replaces the lexeme ID.
212       * @param value The new value for the lexeme ID.
213       * @apilevel high-level
214       */
215      public void setID(String value) {
216        tokenString_ID = value;
217      }
218      /**
219       * JastAdd-internal setter for lexeme ID using the Beaver parser.
220       * @param symbol Symbol containing the new value for the lexeme ID
221       * @apilevel internal
222       */
223      public void setID(beaver.Symbol symbol) {
224        if (symbol.value != null && !(symbol.value instanceof String))
225        throw new UnsupportedOperationException("setID is only valid for String lexemes");
226        tokenString_ID = (String)symbol.value;
227        IDstart = symbol.getStart();
228        IDend = symbol.getEnd();
229      }
230      /**
231       * Retrieves the value for the lexeme ID.
232       * @return The value for the lexeme ID.
233       * @apilevel high-level
234       */
235      @ASTNodeAnnotation.Token(name="ID")
236      public String getID() {
237        return tokenString_ID != null ? tokenString_ID : "";
238      }
239      /**
240       * Replaces the optional node for the SuperClass child. This is the <code>Opt</code>
241       * node containing the child SuperClass, not the actual child!
242       * @param opt The new node to be used as the optional node for the SuperClass child.
243       * @apilevel low-level
244       */
245      public void setSuperClassOpt(Opt<Access> opt) {
246        setChild(opt, 1);
247      }
248      /**
249       * Replaces the (optional) SuperClass child.
250       * @param node The new node to be used as the SuperClass child.
251       * @apilevel high-level
252       */
253      public void setSuperClass(Access node) {
254        getSuperClassOpt().setChild(node, 0);
255      }
256      /**
257       * Check whether the optional SuperClass child exists.
258       * @return {@code true} if the optional SuperClass child exists, {@code false} if it does not.
259       * @apilevel high-level
260       */
261      public boolean hasSuperClass() {
262        return getSuperClassOpt().getNumChild() != 0;
263      }
264      /**
265       * Retrieves the (optional) SuperClass child.
266       * @return The SuperClass child, if it exists. Returns {@code null} otherwise.
267       * @apilevel low-level
268       */
269      public Access getSuperClass() {
270        return (Access) getSuperClassOpt().getChild(0);
271      }
272      /**
273       * Retrieves the optional node for the SuperClass child. This is the <code>Opt</code> node containing the child SuperClass, not the actual child!
274       * @return The optional node for child the SuperClass child.
275       * @apilevel low-level
276       */
277      @ASTNodeAnnotation.OptChild(name="SuperClass")
278      public Opt<Access> getSuperClassOpt() {
279        return (Opt<Access>) getChild(1);
280      }
281      /**
282       * Retrieves the optional node for child SuperClass. This is the <code>Opt</code> node containing the child SuperClass, not the actual child!
283       * <p><em>This method does not invoke AST transformations.</em></p>
284       * @return The optional node for child SuperClass.
285       * @apilevel low-level
286       */
287      public Opt<Access> getSuperClassOptNoTransform() {
288        return (Opt<Access>) getChildNoTransform(1);
289      }
290      /**
291       * Replaces the BodyDecl list.
292       * @param list The new list node to be used as the BodyDecl list.
293       * @apilevel high-level
294       */
295      public void setBodyDeclList(List<BodyDecl> list) {
296        setChild(list, 2);
297      }
298      /**
299       * Retrieves the number of children in the BodyDecl list.
300       * @return Number of children in the BodyDecl list.
301       * @apilevel high-level
302       */
303      public int getNumBodyDecl() {
304        return getBodyDeclList().getNumChild();
305      }
306      /**
307       * Retrieves the number of children in the BodyDecl list.
308       * Calling this method will not trigger rewrites.
309       * @return Number of children in the BodyDecl list.
310       * @apilevel low-level
311       */
312      public int getNumBodyDeclNoTransform() {
313        return getBodyDeclListNoTransform().getNumChildNoTransform();
314      }
315      /**
316       * Retrieves the element at index {@code i} in the BodyDecl list.
317       * @param i Index of the element to return.
318       * @return The element at position {@code i} in the BodyDecl list.
319       * @apilevel high-level
320       */
321      public BodyDecl getBodyDecl(int i) {
322        return (BodyDecl) getBodyDeclList().getChild(i);
323      }
324      /**
325       * Check whether the BodyDecl list has any children.
326       * @return {@code true} if it has at least one child, {@code false} otherwise.
327       * @apilevel high-level
328       */
329      public boolean hasBodyDecl() {
330        return getBodyDeclList().getNumChild() != 0;
331      }
332      /**
333       * Append an element to the BodyDecl list.
334       * @param node The element to append to the BodyDecl list.
335       * @apilevel high-level
336       */
337      public void addBodyDecl(BodyDecl node) {
338        List<BodyDecl> list = (parent == null) ? getBodyDeclListNoTransform() : getBodyDeclList();
339        list.addChild(node);
340      }
341      /**
342       * @apilevel low-level
343       */
344      public void addBodyDeclNoTransform(BodyDecl node) {
345        List<BodyDecl> list = getBodyDeclListNoTransform();
346        list.addChild(node);
347      }
348      /**
349       * Replaces the BodyDecl list element at index {@code i} with the new node {@code node}.
350       * @param node The new node to replace the old list element.
351       * @param i The list index of the node to be replaced.
352       * @apilevel high-level
353       */
354      public void setBodyDecl(BodyDecl node, int i) {
355        List<BodyDecl> list = getBodyDeclList();
356        list.setChild(node, i);
357      }
358      /**
359       * Retrieves the BodyDecl list.
360       * @return The node representing the BodyDecl list.
361       * @apilevel high-level
362       */
363      @ASTNodeAnnotation.ListChild(name="BodyDecl")
364      public List<BodyDecl> getBodyDeclList() {
365        List<BodyDecl> list = (List<BodyDecl>) getChild(2);
366        return list;
367      }
368      /**
369       * Retrieves the BodyDecl list.
370       * <p><em>This method does not invoke AST transformations.</em></p>
371       * @return The node representing the BodyDecl list.
372       * @apilevel low-level
373       */
374      public List<BodyDecl> getBodyDeclListNoTransform() {
375        return (List<BodyDecl>) getChildNoTransform(2);
376      }
377      /**
378       * Retrieves the BodyDecl list.
379       * @return The node representing the BodyDecl list.
380       * @apilevel high-level
381       */
382      public List<BodyDecl> getBodyDecls() {
383        return getBodyDeclList();
384      }
385      /**
386       * Retrieves the BodyDecl list.
387       * <p><em>This method does not invoke AST transformations.</em></p>
388       * @return The node representing the BodyDecl list.
389       * @apilevel low-level
390       */
391      public List<BodyDecl> getBodyDeclsNoTransform() {
392        return getBodyDeclListNoTransform();
393      }
394      /**
395       * @apilevel internal
396       */
397      public ASTNode rewriteTo() {
398        return super.rewriteTo();
399      }
400    }