| java.lang.Object xtc.tree.Visitor xtc.lang.JavaExternalAnalyzer
JavaExternalAnalyzer | public class JavaExternalAnalyzer extends Visitor (Code) | | A visitor that constructs externally visible types and fills the symbol table
for a Java file. Does not descend into method bodies, just finds the class,
interface, method, and field signatures. Used in conjunction with
JavaAnalyzer. Let F be the file currently analyzed by the JavaAnalyzer; then
the JavaExternalAnalyzer is used on (i) classes defined in F, and (ii)
compilation units that define classes whose name gets used in F. Packages,
classes, and interfaces go into namespace "tag(..)", methods go into
namespace "method(..)", and fields go into the default namespace. The scopes
associated with packages and types do not have the namespace in their name,
only the symbols do. For example, scope "java" contains scope "lang", but
scope "java" maps symbol "tag(lang)" to an instance of PackageT. Declared
types are represented by instances of ClassT or InterfaceT, whereas names
used, for example, as method return types are represented by instances of
AliasT.
author: Martin Hirzel version: $Revision: 1.71 $ |
Method Summary | |
protected static void | addModifier(List<Attribute> modifiers, String name) | protected static void | addModifiers(List<Attribute> modifiers, List<Attribute> toAdd) | protected boolean | assrt(GNode n, boolean cond, String msgFormat, Object... msgArgs) Use this for asserting that the input is typed correctly. | protected void | assrtDiffersFromEnclosing(GNode n, String canonicalName) | protected void | assrtLegalModifiers(GNode n, List<Attribute> expected, List<Attribute> actual, String context) | public static int | countDimensions(GNode dimNode) | final protected String | currentScopeName() | final protected Type | declareDefaultConstructorIfNecessary() | protected static boolean | hasModifier(List<Attribute> modifiers, String modifier) | final protected List<Type> | makeList(GNode n) | final protected boolean | memberOfInterface() | final public List<Type> | processDeclarators(List<Attribute> modifiers, Type type, GNode declarators) | final public void | visitBlockDeclaration(GNode n) Visit a BlockDeclaration = ["static"] Block (gosling_et_al_2000 §8.6,
§8.7). | final public void | visitClassBody(GNode n) Visit a ClassBody = Declaration* (gosling_et_al_2000 §8.1.5,
§9.1.3,
§15.9). | final public ClassT | visitClassDeclaration(GNode n) Visit a ClassDeclaration = Modifiers Identifier null [Extension]
[Implementation] ClassBody (gosling_et_al_2000 §8.1,
§14.3). | final public void | visitCompilationUnit(GNode n) Visit a CompilationUnit = [PackageDeclaration] ImportDeclaration*
Declaration* (gosling_et_al_2000 §7.3). | final public void | visitEmptyDeclaration(GNode n) Visit a EmptyDeclaration = (no children) (gosling_et_al_2000 §14.6). | final public List<Type> | visitExtension(GNode n) Visit an Extension = Type+. | final public List<Type> | visitFieldDeclaration(GNode n) Visit a FieldDeclaration = Modifiers Type Declarators. | final public Type | visitFormalParameter(GNode n) Visit a FormalParameter = [Modifier] Type null Identifier [Dimensions]. | final public List<Type> | visitFormalParameters(GNode n) Visit a FormalParameters = FormalParameter*. | final public List<Type> | visitImplementation(GNode n) Visit an Implementation = Type+. | final public void | visitImportDeclaration(GNode n) Visit an ImportDeclaration = QualifiedIdentifier ["*"]. | final public InterfaceT | visitInterfaceDeclaration(GNode n) Visit a InterfaceDeclaration = Modifiers Identifier null [Extension] ClassBody. | final public Type | visitMethodDeclaration(GNode n) Visit a MethodDeclaration = Modifiers null Type Identifier FormalParameters [Dimensions]
[ThrowsClause] [Block]. | final public List<Attribute> | visitModifiers(GNode n) Visit a Modifiers = Modifier*. | final public PackageT | visitPackageDeclaration(GNode n) Visit a PackageDeclaration = QualifiedIdentifier. | final public Type | visitPrimitiveType(GNode n) Visit a PrimitiveType = ("byte" / "short" / "char" / "int" / "long" / "float" / "double" / "boolean")
(gosling_et_al_2000 §4.2). | final public String | visitQualifiedIdentifier(GNode n) Visit a QualifiedIdentifier = Identifier+. | final public List<Type> | visitThrowsClause(GNode n) Visit a ThrowsClause = QualifiedIdentifier+. | final public Type | visitType(GNode n) Visit a Type = TypeName Dimensions
(gosling_et_al_2000 §4,
§10.1).
Note that TypeName is either PrimitiveType or ClassType, i.e., QualifiedIdentifier.
Make no resolution attempt in the case of a qualified identifier, just
return an alias every time. | final public Type | visitVoidType(GNode n) Visit a VoidType = (no children). |
MODIFIERS_INTERFACE_MEMBERTYPE | protected static List<Attribute> MODIFIERS_INTERFACE_MEMBERTYPE(Code) | | |
assrt | protected boolean assrt(GNode n, boolean cond, String msgFormat, Object... msgArgs)(Code) | | Use this for asserting that the input is typed correctly.
|
assrtDiffersFromEnclosing | protected void assrtDiffersFromEnclosing(GNode n, String canonicalName)(Code) | | |
countDimensions | public static int countDimensions(GNode dimNode)(Code) | | |
currentScopeName | final protected String currentScopeName()(Code) | | |
declareDefaultConstructorIfNecessary | final protected Type declareDefaultConstructorIfNecessary()(Code) | | |
memberOfInterface | final protected boolean memberOfInterface()(Code) | | |
visitBlockDeclaration | final public void visitBlockDeclaration(GNode n)(Code) | | Visit a BlockDeclaration = ["static"] Block (gosling_et_al_2000 §8.6,
§8.7).
|
visitClassDeclaration | final public ClassT visitClassDeclaration(GNode n)(Code) | | Visit a ClassDeclaration = Modifiers Identifier null [Extension]
[Implementation] ClassBody (gosling_et_al_2000 §8.1,
§14.3).
|
visitCompilationUnit | final public void visitCompilationUnit(GNode n)(Code) | | Visit a CompilationUnit = [PackageDeclaration] ImportDeclaration*
Declaration* (gosling_et_al_2000 §7.3).
|
visitEmptyDeclaration | final public void visitEmptyDeclaration(GNode n)(Code) | | Visit a EmptyDeclaration = (no children) (gosling_et_al_2000 §14.6).
|
visitExtension | final public List<Type> visitExtension(GNode n)(Code) | | Visit an Extension = Type+.
|
visitFieldDeclaration | final public List<Type> visitFieldDeclaration(GNode n)(Code) | | Visit a FieldDeclaration = Modifiers Type Declarators.
Also descends into Declarators = Declarator+ and into
Declarator = Identifier [Dimensions] [VariableInitializer]
to get all the fields declared by this node.
|
visitFormalParameter | final public Type visitFormalParameter(GNode n)(Code) | | Visit a FormalParameter = [Modifier] Type null Identifier [Dimensions].
|
visitFormalParameters | final public List<Type> visitFormalParameters(GNode n)(Code) | | Visit a FormalParameters = FormalParameter*.
|
visitImplementation | final public List<Type> visitImplementation(GNode n)(Code) | | Visit an Implementation = Type+.
|
visitImportDeclaration | final public void visitImportDeclaration(GNode n)(Code) | | Visit an ImportDeclaration = QualifiedIdentifier ["*"].
|
visitInterfaceDeclaration | final public InterfaceT visitInterfaceDeclaration(GNode n)(Code) | | Visit a InterfaceDeclaration = Modifiers Identifier null [Extension] ClassBody.
|
visitMethodDeclaration | final public Type visitMethodDeclaration(GNode n)(Code) | | Visit a MethodDeclaration = Modifiers null Type Identifier FormalParameters [Dimensions]
[ThrowsClause] [Block].
|
visitPackageDeclaration | final public PackageT visitPackageDeclaration(GNode n)(Code) | | Visit a PackageDeclaration = QualifiedIdentifier.
|
visitPrimitiveType | final public Type visitPrimitiveType(GNode n)(Code) | | Visit a PrimitiveType = ("byte" / "short" / "char" / "int" / "long" / "float" / "double" / "boolean")
(gosling_et_al_2000 §4.2).
|
visitQualifiedIdentifier | final public String visitQualifiedIdentifier(GNode n)(Code) | | Visit a QualifiedIdentifier = Identifier+.
|
visitThrowsClause | final public List<Type> visitThrowsClause(GNode n)(Code) | | Visit a ThrowsClause = QualifiedIdentifier+.
|
visitType | final public Type visitType(GNode n)(Code) | | Visit a Type = TypeName Dimensions
(gosling_et_al_2000 §4,
§10.1).
Note that TypeName is either PrimitiveType or ClassType, i.e., QualifiedIdentifier.
Make no resolution attempt in the case of a qualified identifier, just
return an alias every time. The reason is that in general, there is
too little information to resolve the type at this point. For example, the
name may refer to a type declared in another file, which may recursively
mention an entity in this file.
|
visitVoidType | final public Type visitVoidType(GNode n)(Code) | | Visit a VoidType = (no children).
|
|
|