org.extendj.ast.ImportDecl 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 java.io.BufferedInputStream;
import java.io.DataInputStream;
import org.jastadd.util.PrettyPrintable;
import org.jastadd.util.PrettyPrinter;
import java.io.FileNotFoundException;
import java.io.InputStream;
import org.jastadd.util.*;
import java.io.File;
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;
/**
* An abstract import declaration.
*
* Multiple concrete subclasses exist for different kind of
* import declarations. More import declarations were added in Java 5.
*
* See JLS 6 §7.5.
* @ast node
* @declaredat /home/jesper/git/extendj/java4/grammar/Java.ast:61
* @astdecl ImportDecl : ASTNode ::= Access;
* @production ImportDecl : {@link ASTNode} ::= {@link Access};
*/
public abstract class ImportDecl extends ASTNode implements Cloneable {
/**
* @declaredat ASTNode:1
*/
public ImportDecl() {
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 ImportDecl(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();
importedTypes_String_reset();
importedTypes_reset();
}
/** @apilevel internal
* @declaredat ASTNode:38
*/
public void flushCollectionCache() {
super.flushCollectionCache();
}
/** @apilevel internal
* @declaredat ASTNode:42
*/
public ImportDecl clone() throws CloneNotSupportedException {
ImportDecl node = (ImportDecl) super.clone();
return node;
}
/**
* 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:53
*/
@Deprecated
public abstract ImportDecl fullCopy();
/**
* 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:61
*/
public abstract ImportDecl treeCopyNoTransform();
/**
* 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:69
*/
public abstract ImportDecl treeCopy();
/**
* 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);
}
/** @apilevel internal */
private void importedTypes_String_reset() {
importedTypes_String_computed = null;
importedTypes_String_values = null;
}
/** @apilevel internal */
protected java.util.Map importedTypes_String_values;
/** @apilevel internal */
protected java.util.Map importedTypes_String_computed;
/**
* @attribute syn
* @aspect TypeScopePropagation
* @declaredat /home/jesper/git/extendj/java4/frontend/LookupType.jrag:479
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="TypeScopePropagation", declaredAt="/home/jesper/git/extendj/java4/frontend/LookupType.jrag:479")
public SimpleSet importedTypes(String name) {
Object _parameters = name;
if (importedTypes_String_computed == null) importedTypes_String_computed = new java.util.HashMap(4);
if (importedTypes_String_values == null) importedTypes_String_values = new java.util.HashMap(4);
ASTState state = state();
if (importedTypes_String_values.containsKey(_parameters)
&& importedTypes_String_computed.containsKey(_parameters)
&& (importedTypes_String_computed.get(_parameters) == ASTState.NON_CYCLE || importedTypes_String_computed.get(_parameters) == state().cycle())) {
return (SimpleSet) importedTypes_String_values.get(_parameters);
}
SimpleSet importedTypes_String_value = emptySet();
if (state().inCircle()) {
importedTypes_String_values.put(_parameters, importedTypes_String_value);
importedTypes_String_computed.put(_parameters, state().cycle());
} else {
importedTypes_String_values.put(_parameters, importedTypes_String_value);
importedTypes_String_computed.put(_parameters, ASTState.NON_CYCLE);
}
return importedTypes_String_value;
}
/** @apilevel internal */
private void importedTypes_reset() {
importedTypes_computed = null;
importedTypes_value = null;
}
/** @apilevel internal */
protected ASTState.Cycle importedTypes_computed = null;
/** @apilevel internal */
protected SimpleSet importedTypes_value;
/**
* For a single-import declaration this will return a SimpleSet
* containing the TypeDecl for the imported type. For dynamic
* import declarations this returns the empty set.
* @return TypeDecl of imported type wrapped in SimpleSet
* @attribute syn
* @aspect TypeScopePropagation
* @declaredat /home/jesper/git/extendj/java4/frontend/LookupType.jrag:496
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="TypeScopePropagation", declaredAt="/home/jesper/git/extendj/java4/frontend/LookupType.jrag:496")
public SimpleSet importedTypes() {
ASTState state = state();
if (importedTypes_computed == ASTState.NON_CYCLE || importedTypes_computed == state().cycle()) {
return importedTypes_value;
}
importedTypes_value = emptySet();
if (state().inCircle()) {
importedTypes_computed = state().cycle();
} else {
importedTypes_computed = ASTState.NON_CYCLE;
}
return importedTypes_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 = false;
return isOnDemand_value;
}
/**
* @attribute syn
* @aspect Names
* @declaredat /home/jesper/git/extendj/java4/frontend/QualifiedNames.jrag:60
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="Names", declaredAt="/home/jesper/git/extendj/java4/frontend/QualifiedNames.jrag:60")
public String typeName() {
{
Access a = getAccess().lastAccess();
String name = a.isTypeAccess() ? ((TypeAccess) a).nameWithPackage() : "";
while (a.hasPrevExpr() && a.prevExpr() instanceof Access) {
Access pred = (Access) a.prevExpr();
if (pred.isTypeAccess()) {
name = ((TypeAccess) pred).nameWithPackage() + "." + name;
}
a = pred;
}
return name;
}
}
/**
* @attribute inh
* @aspect TypeScopePropagation
* @declaredat /home/jesper/git/extendj/java4/frontend/LookupType.jrag:525
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.INH)
@ASTNodeAnnotation.Source(aspect="TypeScopePropagation", declaredAt="/home/jesper/git/extendj/java4/frontend/LookupType.jrag:525")
public String packageName() {
String packageName_value = getParent().Define_packageName(this, null);
return packageName_value;
}
/**
* @attribute inh
* @aspect NameCheck
* @declaredat /home/jesper/git/extendj/java4/frontend/NameCheck.jrag:50
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.INH)
@ASTNodeAnnotation.Source(aspect="NameCheck", declaredAt="/home/jesper/git/extendj/java4/frontend/NameCheck.jrag:50")
public SimpleSet allImportedTypes(String name) {
SimpleSet allImportedTypes_String_value = getParent().Define_allImportedTypes(this, null, name);
return allImportedTypes_String_value;
}
/**
* @declaredat /home/jesper/git/extendj/java4/frontend/ResolveAmbiguousNames.jrag:86
* @apilevel internal
*/
public boolean Define_isLeftChildOfDot(ASTNode _callerNode, ASTNode _childNode) {
int childIndex = this.getIndexOfChild(_callerNode);
return false;
}
/**
* @declaredat /home/jesper/git/extendj/java4/frontend/ResolveAmbiguousNames.jrag:86
* @apilevel internal
* @return {@code true} if this node has an equation for the inherited attribute isLeftChildOfDot
*/
protected boolean canDefine_isLeftChildOfDot(ASTNode _callerNode, ASTNode _childNode) {
return true;
}
/**
* @declaredat /home/jesper/git/extendj/java4/frontend/ResolveAmbiguousNames.jrag:101
* @apilevel internal
*/
public boolean Define_isRightChildOfDot(ASTNode _callerNode, ASTNode _childNode) {
int childIndex = this.getIndexOfChild(_callerNode);
return false;
}
/**
* @declaredat /home/jesper/git/extendj/java4/frontend/ResolveAmbiguousNames.jrag:101
* @apilevel internal
* @return {@code true} if this node has an equation for the inherited attribute isRightChildOfDot
*/
protected boolean canDefine_isRightChildOfDot(ASTNode _callerNode, ASTNode _childNode) {
return true;
}
/**
* @declaredat /home/jesper/git/extendj/java4/frontend/ResolveAmbiguousNames.jrag:118
* @apilevel internal
*/
public Expr Define_prevExpr(ASTNode _callerNode, ASTNode _childNode) {
int childIndex = this.getIndexOfChild(_callerNode);
return prevExprError();
}
/**
* @declaredat /home/jesper/git/extendj/java4/frontend/ResolveAmbiguousNames.jrag:118
* @apilevel internal
* @return {@code true} if this node has an equation for the inherited attribute prevExpr
*/
protected boolean canDefine_prevExpr(ASTNode _callerNode, ASTNode _childNode) {
return true;
}
/**
* @declaredat /home/jesper/git/extendj/java4/frontend/ResolveAmbiguousNames.jrag:142
* @apilevel internal
*/
public Access Define_nextAccess(ASTNode _callerNode, ASTNode _childNode) {
int childIndex = this.getIndexOfChild(_callerNode);
return nextAccessError();
}
/**
* @declaredat /home/jesper/git/extendj/java4/frontend/ResolveAmbiguousNames.jrag:142
* @apilevel internal
* @return {@code true} if this node has an equation for the inherited attribute nextAccess
*/
protected boolean canDefine_nextAccess(ASTNode _callerNode, ASTNode _childNode) {
return true;
}
/**
* @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:34
* @apilevel internal
*/
public boolean Define_isDest(ASTNode _callerNode, ASTNode _childNode) {
if (getAccessNoTransform() != null && _callerNode == getAccess()) {
// @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:42
return false;
}
else {
return getParent().Define_isDest(this, _callerNode);
}
}
/**
* @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:34
* @apilevel internal
* @return {@code true} if this node has an equation for the inherited attribute isDest
*/
protected boolean canDefine_isDest(ASTNode _callerNode, ASTNode _childNode) {
return true;
}
/**
* @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:44
* @apilevel internal
*/
public boolean Define_isSource(ASTNode _callerNode, ASTNode _childNode) {
if (getAccessNoTransform() != null && _callerNode == getAccess()) {
// @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:51
return true;
}
else {
return getParent().Define_isSource(this, _callerNode);
}
}
/**
* @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:44
* @apilevel internal
* @return {@code true} if this node has an equation for the inherited attribute isSource
*/
protected boolean canDefine_isSource(ASTNode _callerNode, ASTNode _childNode) {
return true;
}
/** @apilevel internal */
public ASTNode rewriteTo() {
return super.rewriteTo();
}
/** @apilevel internal */
public boolean canRewrite() {
return false;
}
}