org.extendj.ast.FieldDeclarationSubstituted Maven / Gradle / Ivy
The newest version!
/* This file was generated with JastAdd2 (http://jastadd.org) version 2.3.0 */
package org.extendj.ast;
import java.util.ArrayList;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.IOException;
import java.util.Set;
import beaver.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.LinkedHashSet;
import java.util.*;
import org.jastadd.util.PrettyPrintable;
import org.jastadd.util.PrettyPrinter;
import java.util.zip.*;
import java.io.*;
import org.jastadd.util.*;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
/**
* @ast node
* @declaredat /home/jesper/git/extendj/java5/grammar/Generics.ast:84
* @astdecl FieldDeclarationSubstituted : FieldDeclarator ::= ;
* @production FieldDeclarationSubstituted : {@link FieldDeclarator} ::= <Original:FieldDeclarator>;
*/
public class FieldDeclarationSubstituted extends FieldDeclarator implements Cloneable {
/**
* @declaredat ASTNode:1
*/
public FieldDeclarationSubstituted() {
super();
}
/**
* Initializes the child array to the correct size.
* Initializes List and Opt nta children.
* @apilevel internal
* @ast method
* @declaredat ASTNode:10
*/
public void init$Children() {
children = new ASTNode[3];
setChild(new List(), 0);
setChild(new Opt(), 1);
}
/**
* @declaredat ASTNode:15
*/
@ASTNodeAnnotation.Constructor(
name = {"ID", "Dims", "Init", "Original"},
type = {"String", "List", "Opt", "FieldDeclarator"},
kind = {"Token", "List", "Opt", "Token"}
)
public FieldDeclarationSubstituted(String p0, List p1, Opt p2, FieldDeclarator p3) {
setID(p0);
setChild(p1, 0);
setChild(p2, 1);
setOriginal(p3);
}
/**
* @declaredat ASTNode:26
*/
public FieldDeclarationSubstituted(beaver.Symbol p0, List p1, Opt p2, FieldDeclarator p3) {
setID(p0);
setChild(p1, 0);
setChild(p2, 1);
setOriginal(p3);
}
/** @apilevel low-level
* @declaredat ASTNode:33
*/
protected int numChildren() {
return 2;
}
/**
* @apilevel internal
* @declaredat ASTNode:39
*/
public boolean mayHaveRewrite() {
return false;
}
/** @apilevel internal
* @declaredat ASTNode:43
*/
public void flushAttrCache() {
super.flushAttrCache();
}
/** @apilevel internal
* @declaredat ASTNode:47
*/
public void flushCollectionCache() {
super.flushCollectionCache();
}
/** @apilevel internal
* @declaredat ASTNode:51
*/
public FieldDeclarationSubstituted clone() throws CloneNotSupportedException {
FieldDeclarationSubstituted node = (FieldDeclarationSubstituted) super.clone();
return node;
}
/** @apilevel internal
* @declaredat ASTNode:56
*/
public FieldDeclarationSubstituted copy() {
try {
FieldDeclarationSubstituted node = (FieldDeclarationSubstituted) clone();
node.parent = null;
if (children != null) {
node.children = (ASTNode[]) children.clone();
}
return node;
} catch (CloneNotSupportedException e) {
throw new Error("Error: clone not supported for " + getClass().getName());
}
}
/**
* Create a deep copy of the AST subtree at this node.
* The copy is dangling, i.e. has no parent.
* @return dangling copy of the subtree at this node
* @apilevel low-level
* @deprecated Please use treeCopy or treeCopyNoTransform instead
* @declaredat ASTNode:75
*/
@Deprecated
public FieldDeclarationSubstituted fullCopy() {
return treeCopyNoTransform();
}
/**
* Create a deep copy of the AST subtree at this node.
* The copy is dangling, i.e. has no parent.
* @return dangling copy of the subtree at this node
* @apilevel low-level
* @declaredat ASTNode:85
*/
public FieldDeclarationSubstituted treeCopyNoTransform() {
FieldDeclarationSubstituted tree = (FieldDeclarationSubstituted) copy();
if (children != null) {
for (int i = 0; i < children.length; ++i) {
switch (i) {
case 2:
tree.children[i] = null;
continue;
}
ASTNode child = (ASTNode) children[i];
if (child != null) {
child = child.treeCopyNoTransform();
tree.setChild(child, i);
}
}
}
return tree;
}
/**
* Create a deep copy of the AST subtree at this node.
* The subtree of this node is traversed to trigger rewrites before copy.
* The copy is dangling, i.e. has no parent.
* @return dangling copy of the subtree at this node
* @apilevel low-level
* @declaredat ASTNode:110
*/
public FieldDeclarationSubstituted treeCopy() {
FieldDeclarationSubstituted tree = (FieldDeclarationSubstituted) copy();
if (children != null) {
for (int i = 0; i < children.length; ++i) {
switch (i) {
case 2:
tree.children[i] = null;
continue;
}
ASTNode child = (ASTNode) getChild(i);
if (child != null) {
child = child.treeCopy();
tree.setChild(child, i);
}
}
}
return tree;
}
/** @apilevel internal
* @declaredat ASTNode:129
*/
protected boolean is$Equal(ASTNode node) {
return super.is$Equal(node) && (tokenString_ID == ((FieldDeclarationSubstituted) node).tokenString_ID) && (tokenFieldDeclarator_Original == ((FieldDeclarationSubstituted) node).tokenFieldDeclarator_Original);
}
/**
* Replaces the lexeme ID.
* @param value The new value for the lexeme ID.
* @apilevel high-level
*/
public void setID(String value) {
tokenString_ID = value;
}
/**
* JastAdd-internal setter for lexeme ID using the Beaver parser.
* @param symbol Symbol containing the new value for the lexeme ID
* @apilevel internal
*/
public void setID(beaver.Symbol symbol) {
if (symbol.value != null && !(symbol.value instanceof String))
throw new UnsupportedOperationException("setID is only valid for String lexemes");
tokenString_ID = (String)symbol.value;
IDstart = symbol.getStart();
IDend = symbol.getEnd();
}
/**
* Retrieves the value for the lexeme ID.
* @return The value for the lexeme ID.
* @apilevel high-level
*/
@ASTNodeAnnotation.Token(name="ID")
public String getID() {
return tokenString_ID != null ? tokenString_ID : "";
}
/**
* Replaces the Dims list.
* @param list The new list node to be used as the Dims list.
* @apilevel high-level
*/
public void setDimsList(List list) {
setChild(list, 0);
}
/**
* Retrieves the number of children in the Dims list.
* @return Number of children in the Dims list.
* @apilevel high-level
*/
public int getNumDims() {
return getDimsList().getNumChild();
}
/**
* Retrieves the number of children in the Dims list.
* Calling this method will not trigger rewrites.
* @return Number of children in the Dims list.
* @apilevel low-level
*/
public int getNumDimsNoTransform() {
return getDimsListNoTransform().getNumChildNoTransform();
}
/**
* Retrieves the element at index {@code i} in the Dims list.
* @param i Index of the element to return.
* @return The element at position {@code i} in the Dims list.
* @apilevel high-level
*/
public Dims getDims(int i) {
return (Dims) getDimsList().getChild(i);
}
/**
* Check whether the Dims list has any children.
* @return {@code true} if it has at least one child, {@code false} otherwise.
* @apilevel high-level
*/
public boolean hasDims() {
return getDimsList().getNumChild() != 0;
}
/**
* Append an element to the Dims list.
* @param node The element to append to the Dims list.
* @apilevel high-level
*/
public void addDims(Dims node) {
List list = (parent == null) ? getDimsListNoTransform() : getDimsList();
list.addChild(node);
}
/** @apilevel low-level
*/
public void addDimsNoTransform(Dims node) {
List list = getDimsListNoTransform();
list.addChild(node);
}
/**
* Replaces the Dims list element at index {@code i} with the new node {@code node}.
* @param node The new node to replace the old list element.
* @param i The list index of the node to be replaced.
* @apilevel high-level
*/
public void setDims(Dims node, int i) {
List list = getDimsList();
list.setChild(node, i);
}
/**
* Retrieves the Dims list.
* @return The node representing the Dims list.
* @apilevel high-level
*/
@ASTNodeAnnotation.ListChild(name="Dims")
public List getDimsList() {
List list = (List) getChild(0);
return list;
}
/**
* Retrieves the Dims list.
* This method does not invoke AST transformations.
* @return The node representing the Dims list.
* @apilevel low-level
*/
public List getDimsListNoTransform() {
return (List) getChildNoTransform(0);
}
/**
* @return the element at index {@code i} in the Dims list without
* triggering rewrites.
*/
public Dims getDimsNoTransform(int i) {
return (Dims) getDimsListNoTransform().getChildNoTransform(i);
}
/**
* Retrieves the Dims list.
* @return The node representing the Dims list.
* @apilevel high-level
*/
public List getDimss() {
return getDimsList();
}
/**
* Retrieves the Dims list.
* This method does not invoke AST transformations.
* @return The node representing the Dims list.
* @apilevel low-level
*/
public List getDimssNoTransform() {
return getDimsListNoTransform();
}
/**
* Replaces the optional node for the Init child. This is the Opt
* node containing the child Init, not the actual child!
* @param opt The new node to be used as the optional node for the Init child.
* @apilevel low-level
*/
public void setInitOpt(Opt opt) {
setChild(opt, 1);
}
/**
* Replaces the (optional) Init child.
* @param node The new node to be used as the Init child.
* @apilevel high-level
*/
public void setInit(Expr node) {
getInitOpt().setChild(node, 0);
}
/**
* Check whether the optional Init child exists.
* @return {@code true} if the optional Init child exists, {@code false} if it does not.
* @apilevel high-level
*/
public boolean hasInit() {
return getInitOpt().getNumChild() != 0;
}
/**
* Retrieves the (optional) Init child.
* @return The Init child, if it exists. Returns {@code null} otherwise.
* @apilevel low-level
*/
public Expr getInit() {
return (Expr) getInitOpt().getChild(0);
}
/**
* Retrieves the optional node for the Init child. This is the Opt
node containing the child Init, not the actual child!
* @return The optional node for child the Init child.
* @apilevel low-level
*/
@ASTNodeAnnotation.OptChild(name="Init")
public Opt getInitOpt() {
return (Opt) getChild(1);
}
/**
* Retrieves the optional node for child Init. This is the Opt
node containing the child Init, not the actual child!
* This method does not invoke AST transformations.
* @return The optional node for child Init.
* @apilevel low-level
*/
public Opt getInitOptNoTransform() {
return (Opt) getChildNoTransform(1);
}
/**
* Replaces the lexeme Original.
* @param value The new value for the lexeme Original.
* @apilevel high-level
*/
public void setOriginal(FieldDeclarator value) {
tokenFieldDeclarator_Original = value;
}
/** @apilevel internal
*/
protected FieldDeclarator tokenFieldDeclarator_Original;
/**
* Retrieves the value for the lexeme Original.
* @return The value for the lexeme Original.
* @apilevel high-level
*/
@ASTNodeAnnotation.Token(name="Original")
public FieldDeclarator getOriginal() {
return tokenFieldDeclarator_Original;
}
/**
* Retrieves the TypeAccess child.
* This method does not invoke AST transformations.
* @return The current node used as the TypeAccess child.
* @apilevel low-level
*/
public Access getTypeAccessNoTransform() {
return (Access) getChildNoTransform(2);
}
/**
* Retrieves the child position of the optional child TypeAccess.
* @return The the child position of the optional child TypeAccess.
* @apilevel low-level
*/
protected int getTypeAccessChildPosition() {
return 2;
}
/** @apilevel internal */
public ASTNode rewriteTo() {
return super.rewriteTo();
}
/** @apilevel internal */
public boolean canRewrite() {
return false;
}
}