org.extendj.ast.PackageAccess 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;
/**
* @ast node
* @declaredat /home/jesper/git/extendj/java4/grammar/Java.ast:98
* @astdecl PackageAccess : Access ::= ;
* @production PackageAccess : {@link Access} ::= <Package:String>;
*/
public class PackageAccess extends Access implements Cloneable {
/**
* @aspect Java4PrettyPrint
* @declaredat /home/jesper/git/extendj/java4/frontend/PrettyPrint.jadd:525
*/
public void prettyPrint(PrettyPrinter out) {
out.print(getPackage());
}
/**
* @aspect NodeConstructors
* @declaredat /home/jesper/git/extendj/java4/frontend/NodeConstructors.jrag:40
*/
public PackageAccess(String name, int start, int end) {
this(name);
this.start = this.Packagestart = start;
this.end = this.Packageend = end;
}
/**
* @declaredat ASTNode:1
*/
public PackageAccess() {
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() {
}
/**
* @declaredat ASTNode:12
*/
@ASTNodeAnnotation.Constructor(
name = {"Package"},
type = {"String"},
kind = {"Token"}
)
public PackageAccess(String p0) {
setPackage(p0);
}
/**
* @declaredat ASTNode:20
*/
public PackageAccess(beaver.Symbol p0) {
setPackage(p0);
}
/** @apilevel low-level
* @declaredat ASTNode:24
*/
protected int numChildren() {
return 0;
}
/**
* @apilevel internal
* @declaredat ASTNode:30
*/
public boolean mayHaveRewrite() {
return false;
}
/** @apilevel internal
* @declaredat ASTNode:34
*/
public void flushAttrCache() {
super.flushAttrCache();
}
/** @apilevel internal
* @declaredat ASTNode:38
*/
public void flushCollectionCache() {
super.flushCollectionCache();
}
/** @apilevel internal
* @declaredat ASTNode:42
*/
public PackageAccess clone() throws CloneNotSupportedException {
PackageAccess node = (PackageAccess) super.clone();
return node;
}
/** @apilevel internal
* @declaredat ASTNode:47
*/
public PackageAccess copy() {
try {
PackageAccess node = (PackageAccess) 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:66
*/
@Deprecated
public PackageAccess 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:76
*/
public PackageAccess treeCopyNoTransform() {
PackageAccess tree = (PackageAccess) 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:96
*/
public PackageAccess treeCopy() {
PackageAccess tree = (PackageAccess) 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:110
*/
protected boolean is$Equal(ASTNode node) {
return super.is$Equal(node) && (tokenString_Package == ((PackageAccess) node).tokenString_Package);
}
/**
* Replaces the lexeme Package.
* @param value The new value for the lexeme Package.
* @apilevel high-level
*/
public void setPackage(String value) {
tokenString_Package = value;
}
/** @apilevel internal
*/
protected String tokenString_Package;
/**
*/
public int Packagestart;
/**
*/
public int Packageend;
/**
* JastAdd-internal setter for lexeme Package using the Beaver parser.
* @param symbol Symbol containing the new value for the lexeme Package
* @apilevel internal
*/
public void setPackage(beaver.Symbol symbol) {
if (symbol.value != null && !(symbol.value instanceof String))
throw new UnsupportedOperationException("setPackage is only valid for String lexemes");
tokenString_Package = (String)symbol.value;
Packagestart = symbol.getStart();
Packageend = symbol.getEnd();
}
/**
* Retrieves the value for the lexeme Package.
* @return The value for the lexeme Package.
* @apilevel high-level
*/
@ASTNodeAnnotation.Token(name="Package")
public String getPackage() {
return tokenString_Package != null ? tokenString_Package : "";
}
/**
* @attribute syn
* @aspect AccessTypes
* @declaredat /home/jesper/git/extendj/java4/frontend/ResolveAmbiguousNames.jrag:68
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="AccessTypes", declaredAt="/home/jesper/git/extendj/java4/frontend/ResolveAmbiguousNames.jrag:68")
public boolean isPackageAccess() {
boolean isPackageAccess_value = true;
return isPackageAccess_value;
}
/**
* @attribute syn
* @aspect LookupFullyQualifiedTypes
* @declaredat /home/jesper/git/extendj/java4/frontend/LookupType.jrag:106
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="LookupFullyQualifiedTypes", declaredAt="/home/jesper/git/extendj/java4/frontend/LookupType.jrag:106")
public boolean hasQualifiedPackage(String packageName) {
boolean hasQualifiedPackage_String_value = hasPackage(packageName() + "." + packageName);
return hasQualifiedPackage_String_value;
}
/**
* @attribute syn
* @aspect TypeScopePropagation
* @declaredat /home/jesper/git/extendj/java4/frontend/LookupType.jrag:608
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="TypeScopePropagation", declaredAt="/home/jesper/git/extendj/java4/frontend/LookupType.jrag:608")
public SimpleSet qualifiedLookupType(String name) {
{
SimpleSet result = emptySet();
TypeDecl typeDecl = lookupType(packageName(), name);
if (!typeDecl.isUnknown()) {
if (hostType() != null && typeDecl.accessibleFrom(hostType())) {
result = result.add(typeDecl);
} else if (hostType() == null && typeDecl.accessibleFromPackage(hostPackage())) {
result = result.add(typeDecl);
}
}
return result;
}
}
/**
* @attribute syn
* @aspect NameCheck
* @declaredat /home/jesper/git/extendj/java4/frontend/NameCheck.jrag:87
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="NameCheck", declaredAt="/home/jesper/git/extendj/java4/frontend/NameCheck.jrag:87")
public Collection nameProblems() {
{
Collection problems = new LinkedList();
if (!hasPackage(packageName())) {
problems.add(errorf("package %s not found", packageName()));
}
return problems;
}
}
/**
* @attribute syn
* @aspect Names
* @declaredat /home/jesper/git/extendj/java4/frontend/QualifiedNames.jrag:41
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="Names", declaredAt="/home/jesper/git/extendj/java4/frontend/QualifiedNames.jrag:41")
public String name() {
String name_value = getPackage();
return name_value;
}
/**
* @attribute syn
* @aspect Names
* @declaredat /home/jesper/git/extendj/java4/frontend/QualifiedNames.jrag:43
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="Names", declaredAt="/home/jesper/git/extendj/java4/frontend/QualifiedNames.jrag:43")
public String packageName() {
{
StringBuilder sb = new StringBuilder();
if (hasPrevExpr()) {
sb.append(prevExpr().packageName());
sb.append(".");
}
sb.append(getPackage());
return sb.toString();
}
}
/**
* Defines the expected kind of name for the left hand side in a qualified
* expression.
* @attribute syn
* @aspect SyntacticClassification
* @declaredat /home/jesper/git/extendj/java4/frontend/SyntacticClassification.jrag:60
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="SyntacticClassification", declaredAt="/home/jesper/git/extendj/java4/frontend/SyntacticClassification.jrag:60")
public NameType predNameType() {
NameType predNameType_value = NameType.PACKAGE_NAME;
return predNameType_value;
}
/**
* @attribute syn
* @aspect VariableScope
* @declaredat /home/jesper/git/extendj/java4/frontend/LookupVariable.jrag:264
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="VariableScope", declaredAt="/home/jesper/git/extendj/java4/frontend/LookupVariable.jrag:264")
public SimpleSet qualifiedLookupVariable(String name) {
SimpleSet qualifiedLookupVariable_String_value = emptySet();
return qualifiedLookupVariable_String_value;
}
/**
* @attribute syn
* @aspect TypeHierarchyCheck
* @declaredat /home/jesper/git/extendj/java4/frontend/TypeHierarchyCheck.jrag:47
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="TypeHierarchyCheck", declaredAt="/home/jesper/git/extendj/java4/frontend/TypeHierarchyCheck.jrag:47")
public boolean isUnknown() {
boolean isUnknown_value = !hasPackage(packageName());
return isUnknown_value;
}
/**
* @attribute inh
* @aspect NameCheck
* @declaredat /home/jesper/git/extendj/java4/frontend/NameCheck.jrag:366
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.INH)
@ASTNodeAnnotation.Source(aspect="NameCheck", declaredAt="/home/jesper/git/extendj/java4/frontend/NameCheck.jrag:366")
public boolean hasPackage(String packageName) {
boolean hasPackage_String_value = getParent().Define_hasPackage(this, null, packageName);
return hasPackage_String_value;
}
/** @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/java4/frontend/NameCheck.jrag:85
{
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);
for (Problem value : nameProblems()) {
collection.add(value);
}
}
}