Class CompilationUnit
java.lang.Object
org.fife.rsta.ac.java.rjc.ast.AbstractASTNode
org.fife.rsta.ac.java.rjc.ast.CompilationUnit
- All Implemented Interfaces:
ASTNode, TypeDeclarationContainer
A
CompilationUnit is the root node of an AST for a Java
source file.
CompilationUnit:
[[Annotations] 'package' QualifiedIdentifier ';' ] {ImportDeclaration} {TypeDeclaration}
- Version:
- 1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classAn offset that always returns 0. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate List<Annotation> private List<ImportDeclaration> private List<ParserNotice> private Packageprivate List<TypeDeclaration> private static final Offset -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds an import declaration to this compilation unit.voidaddParserNotice(Token t, String msg) Shorthand for "addParserNotice(new ParserNotice(t, msg))".voidaddParserNotice(ParserNotice notice) Adds a parser notice to this compilation unit.voidaddTypeDeclaration(TypeDeclaration typeDec) Adds a type declaration to this container.intgetDeepestTypeDeclarationAtOffset(int offs) Returns the deepest-nested type declaration that contains a given offset.getEnclosingMethodRange(int offs) TODO: Return range for more instances than just class methods.intReturns the import declarations of this compilation unit.Returns the package of this compilation unit.Returns the fully-qualified package name of this compilation unit.getParserNotice(int index) Returns the specified parser notice.intgetTypeDeclaration(int index) Returns the specified type declaration.getTypeDeclarationAtOffset(int offs) Returns the type declaration in this file that contains the specified offset.intvoidsetPackage(Package pkg) Methods inherited from class AbstractASTNode
getName, getNameEndOffset, getNameStartOffset, setDeclarationEndOffset, setDeclarationOffsets, toString
-
Field Details
-
annotations
-
pkg
-
imports
-
typeDeclarations
-
notices
-
ZERO_OFFSET
-
-
Constructor Details
-
CompilationUnit
-
-
Method Details
-
addImportDeclaration
Adds an import declaration to this compilation unit.- Parameters:
dec- The import declaration.- See Also:
-
addParserNotice
-
addParserNotice
Adds a parser notice to this compilation unit.- Parameters:
notice- The notice to add.- See Also:
-
addTypeDeclaration
Description copied from interface:TypeDeclarationContainerAdds a type declaration to this container.- Specified by:
addTypeDeclarationin interfaceTypeDeclarationContainer- Parameters:
typeDec- The new type declaration.
-
getAnnotationCount
public int getAnnotationCount() -
getAnnotationIterator
-
getDeepestTypeDeclarationAtOffset
Returns the deepest-nested type declaration that contains a given offset.- Parameters:
offs- The offset.- Returns:
- The deepest-nested type declaration containing the offset, or
nullif the offset is outside any type declaration (such as in the import statements, etc.). - See Also:
-
getEnclosingMethodRange
TODO: Return range for more instances than just class methods. Also handle child TypeDeclarations.- Parameters:
offs- The offset to check.- Returns:
- The starting and ending offset of the enclosing method range.
-
getImportCount
public int getImportCount() -
getImports
Returns the import declarations of this compilation unit. This is a copy of the list of imports, but the actual individualImportDeclarations are not copies, so modifying them will modify this compilation unit!- Returns:
- A list or imports, or an empty list if there are none.
-
getImportIterator
-
getPackage
Returns the package of this compilation unit.- Returns:
- The package of this compilation unit, or
nullif this compilation unit is not in a package. - See Also:
-
getPackageName
Returns the fully-qualified package name of this compilation unit.- Returns:
- The package name, or
nullif this compilation unit is not in a package (in the default package). - See Also:
-
getParserNotice
Returns the specified parser notice.- Parameters:
index- The index of the parser notice.- Returns:
- The parser notice.
- See Also:
-
getParserNoticeCount
public int getParserNoticeCount() -
getTypeDeclaration
Returns the specified type declaration.- Parameters:
index- The index of the type declaration.- Returns:
- The type declaration.
- See Also:
-
getTypeDeclarationAtOffset
Returns the type declaration in this file that contains the specified offset.- Parameters:
offs- The offset.- Returns:
- The type declaration, or
nullif the offset is outside any type declaration. - See Also:
-
getTypeDeclarationCount
public int getTypeDeclarationCount() -
getTypeDeclarationIterator
-
setPackage
-