org.extendj.ast.StaticImportOnDemandDecl Maven / Gradle / Ivy
/* This file was generated with JastAdd2 (http://jastadd.org) version 2.3.0 */
package org.extendj.ast;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
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.*;
import java.util.zip.*;
import java.io.*;
import org.jastadd.util.PrettyPrintable;
import org.jastadd.util.PrettyPrinter;
import org.jastadd.util.*;
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.io.BufferedInputStream;
import java.io.DataInputStream;
/**
* 7.5.4 A static-import-on-demand declaration allows all accessible (\u00a76.6) static
* members declared in the type named by a canonical name to be imported as
* needed.
* @ast node
* @declaredat /home/jesper/git/extendj/java5/grammar/StaticImports.ast:19
* @astdecl StaticImportOnDemandDecl : StaticImportDecl;
* @production StaticImportOnDemandDecl : {@link StaticImportDecl};
*/
public class StaticImportOnDemandDecl extends StaticImportDecl implements Cloneable {
/**
* @aspect Java5PrettyPrint
* @declaredat /home/jesper/git/extendj/java5/frontend/PrettyPrint.jadd:350
*/
public void prettyPrint(PrettyPrinter out) {
out.print("import static ");
out.print(getAccess());
out.print(".*;");
}
/**
* @declaredat ASTNode:1
*/
public StaticImportOnDemandDecl() {
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[1];
}
/**
* @declaredat ASTNode:13
*/
@ASTNodeAnnotation.Constructor(
name = {"Access"},
type = {"Access"},
kind = {"Child"}
)
public StaticImportOnDemandDecl(Access p0) {
setChild(p0, 0);
}
/** @apilevel low-level
* @declaredat ASTNode:22
*/
protected int numChildren() {
return 1;
}
/**
* @apilevel internal
* @declaredat ASTNode:28
*/
public boolean mayHaveRewrite() {
return false;
}
/** @apilevel internal
* @declaredat ASTNode:32
*/
public void flushAttrCache() {
super.flushAttrCache();
}
/** @apilevel internal
* @declaredat ASTNode:36
*/
public void flushCollectionCache() {
super.flushCollectionCache();
}
/** @apilevel internal
* @declaredat ASTNode:40
*/
public StaticImportOnDemandDecl clone() throws CloneNotSupportedException {
StaticImportOnDemandDecl node = (StaticImportOnDemandDecl) super.clone();
return node;
}
/** @apilevel internal
* @declaredat ASTNode:45
*/
public StaticImportOnDemandDecl copy() {
try {
StaticImportOnDemandDecl node = (StaticImportOnDemandDecl) 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:64
*/
@Deprecated
public StaticImportOnDemandDecl 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:74
*/
public StaticImportOnDemandDecl treeCopyNoTransform() {
StaticImportOnDemandDecl tree = (StaticImportOnDemandDecl) copy();
if (children != null) {
for (int i = 0; i < children.length; ++i) {
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:94
*/
public StaticImportOnDemandDecl treeCopy() {
StaticImportOnDemandDecl tree = (StaticImportOnDemandDecl) copy();
if (children != null) {
for (int i = 0; i < children.length; ++i) {
ASTNode child = (ASTNode) getChild(i);
if (child != null) {
child = child.treeCopy();
tree.setChild(child, i);
}
}
}
return tree;
}
/** @apilevel internal
* @declaredat ASTNode:108
*/
protected boolean is$Equal(ASTNode node) {
return super.is$Equal(node);
}
/**
* Replaces the Access child.
* @param node The new node to replace the Access child.
* @apilevel high-level
*/
public void setAccess(Access node) {
setChild(node, 0);
}
/**
* Retrieves the Access child.
* @return The current node used as the Access child.
* @apilevel high-level
*/
@ASTNodeAnnotation.Child(name="Access")
public Access getAccess() {
return (Access) getChild(0);
}
/**
* Retrieves the Access child.
* This method does not invoke AST transformations.
* @return The current node used as the Access child.
* @apilevel low-level
*/
public Access getAccessNoTransform() {
return (Access) getChildNoTransform(0);
}
/**
* @attribute syn
* @aspect StaticImports
* @declaredat /home/jesper/git/extendj/java5/frontend/StaticImports.jrag:98
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="StaticImports", declaredAt="/home/jesper/git/extendj/java5/frontend/StaticImports.jrag:98")
public TypeDecl type() {
TypeDecl type_value = getAccess().type();
return type_value;
}
/**
* @attribute syn
* @aspect TypeScopePropagation
* @declaredat /home/jesper/git/extendj/java4/frontend/LookupType.jrag:527
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="TypeScopePropagation", declaredAt="/home/jesper/git/extendj/java4/frontend/LookupType.jrag:527")
public boolean isOnDemand() {
boolean isOnDemand_value = true;
return isOnDemand_value;
}
/**
* @declaredat /home/jesper/git/extendj/java4/frontend/SyntacticClassification.jrag:36
* @apilevel internal
*/
public NameType Define_nameType(ASTNode _callerNode, ASTNode _childNode) {
if (getAccessNoTransform() != null && _callerNode == getAccess()) {
// @declaredat /home/jesper/git/extendj/java5/frontend/StaticImports.jrag:303
return NameType.TYPE_NAME;
}
else {
return getParent().Define_nameType(this, _callerNode);
}
}
/**
* @declaredat /home/jesper/git/extendj/java4/frontend/SyntacticClassification.jrag:36
* @apilevel internal
* @return {@code true} if this node has an equation for the inherited attribute nameType
*/
protected boolean canDefine_nameType(ASTNode _callerNode, ASTNode _childNode) {
return true;
}
/** @apilevel internal */
public ASTNode rewriteTo() {
return super.rewriteTo();
}
/** @apilevel internal */
public boolean canRewrite() {
return false;
}
/** @apilevel internal */
protected void collect_contributors_CompilationUnit_problems(CompilationUnit _root, java.util.Map> _map) {
// @declaredat /home/jesper/git/extendj/java5/frontend/StaticImports.jrag:125
if (!getAccess().type().typeName().equals(typeName())) {
{
java.util.Set contributors = _map.get(_root);
if (contributors == null) {
contributors = new java.util.LinkedHashSet();
_map.put((ASTNode) _root, contributors);
}
contributors.add(this);
}
}
super.collect_contributors_CompilationUnit_problems(_root, _map);
}
/** @apilevel internal */
protected void contributeTo_CompilationUnit_problems(LinkedList collection) {
super.contributeTo_CompilationUnit_problems(collection);
if (!getAccess().type().typeName().equals(typeName())) {
collection.add(errorf("In on-demand import: %s is not the canonical name of type %s",
typeName(), getAccess().type().typeName()));
}
}
}