|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.fife.rsta.ac.java.rjc.ast.CompilationUnit
public class CompilationUnit
A CompilationUnit is the root node of an AST for a Java
source file.
CompilationUnit:
[[Annotations] 'package' QualifiedIdentifier ';' ] {ImportDeclaration} {TypeDeclaration}
| Constructor Summary | |
|---|---|
CompilationUnit(String name)
|
|
| Method Summary | |
|---|---|
void |
addImportDeclaration(ImportDeclaration dec)
|
void |
addParserNotice(ParserNotice notice)
|
void |
addParserNotice(Token t,
String msg)
Shorthand for "addParserNotice(new ParserNotice(t, msg))". |
void |
addTypeDeclaration(TypeDeclaration typeDec)
|
int |
getAnnotationCount()
|
Iterator |
getAnnotationIterator()
|
TypeDeclaration |
getDeepestTypeDeclarationAtOffset(int offs)
Returns the deepest-nested type declaration that contains a given offset. |
Point |
getEnclosingMethodRange(int offs)
TODO: Return range for more instances than just class methods. |
int |
getImportCount()
|
Iterator |
getImportIterator()
|
List |
getImports()
Returns the import declarations of this compilation unit. |
String |
getName()
Returns the "name" of this node. |
int |
getNameEndOffset()
Returns the end offset of the "name" of this node. |
int |
getNameStartOffset()
Returns the start offset of the "name" of this node. |
Package |
getPackage()
Returns the package of this compilation unit. |
String |
getPackageName()
Returns the fully-qualified package name of this compilation unit. |
ParserNotice |
getParserNotice(int index)
|
int |
getParserNoticeCount()
|
TypeDeclaration |
getTypeDeclaration(int index)
|
TypeDeclaration |
getTypeDeclarationAtOffset(int offs)
Returns the type declaration in this file that contains the specified offset. |
int |
getTypeDeclarationCount()
|
Iterator |
getTypeDeclarationIterator()
|
void |
setDeclarationEndOffset(Offset end)
|
protected void |
setDeclarationOffsets(Offset start,
Offset end)
Sets the start and end offsets of this node. |
void |
setPackage(Package pkg)
|
String |
toString()
Returns the name of this node (e.g. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public CompilationUnit(String name)
| Method Detail |
|---|
public void addImportDeclaration(ImportDeclaration dec)
public void addParserNotice(Token t,
String msg)
t - msg - public void addParserNotice(ParserNotice notice)
public void addTypeDeclaration(TypeDeclaration typeDec)
addTypeDeclaration in interface TypeDeclarationContainerpublic int getAnnotationCount()
public Iterator getAnnotationIterator()
public TypeDeclaration getDeepestTypeDeclarationAtOffset(int offs)
offs - The offset.
null if the offset is outside of any type
declaration (such as in the import statements, etc.).getTypeDeclarationAtOffset(int)public Point getEnclosingMethodRange(int offs)
offs -
public int getImportCount()
public List getImports()
ImportDeclarations are not copies, so modifying them will modify
this compilation unit!
public Iterator getImportIterator()
public Package getPackage()
null if
this compilation unit is not in a package.getPackageName()public String getPackageName()
null if this compilation unit
is not in a package (in the default package).getPackage()public ParserNotice getParserNotice(int index)
public int getParserNoticeCount()
public TypeDeclaration getTypeDeclaration(int index)
public TypeDeclaration getTypeDeclarationAtOffset(int offs)
offs - The offset.
null if the offset is
outside of any type declaration.getDeepestTypeDeclarationAtOffset(int)public int getTypeDeclarationCount()
public Iterator getTypeDeclarationIterator()
public void setPackage(Package pkg)
public String getName()
CodeBlocks
it will be CodeBlock.NAME.Note that this may not be unique. For example, a class with an overloaded method will have multiple methods with the same "name," just with different signatures.
getName in interface ASTNodepublic int getNameEndOffset()
getNameEndOffset in interface ASTNodepublic int getNameStartOffset()
getNameStartOffset in interface ASTNodepublic void setDeclarationEndOffset(Offset end)
protected void setDeclarationOffsets(Offset start,
Offset end)
start - The start offset.end - The end offset.public String toString()
getName()).
Subclasses can override this method if appropriate.
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||