|
RECODER 0.92 | |||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||
java.lang.Objectrecoder.java.JavaSourceElement
recoder.java.JavaProgramElement
recoder.java.JavaNonTerminalProgramElement
recoder.java.CompilationUnit
public class CompilationUnit
A node representing a single source file containing TypeDeclarations
and an optional PackageSpecificationand an optional set of
Imports. In Java, any source file may contain at most one public
class type definition.
| Field Summary |
|---|
| Fields inherited from class recoder.java.JavaSourceElement |
|---|
factory |
| Constructor Summary | |
|---|---|
|
CompilationUnit()
Compilation unit. |
protected |
CompilationUnit(CompilationUnit proto)
Compilation unit. |
|
CompilationUnit(PackageSpecification pkg,
ASTList<Import> imports,
ASTList<TypeDeclaration> typeDeclarations)
Compilation unit. |
| Method Summary | |
|---|---|
void |
accept(SourceVisitor v)
Receive a visitor, for instance a pretty printer. |
void |
addTypeToScope(ClassType type,
java.lang.String name)
|
CompilationUnit |
deepClone()
Deep clone. |
NonTerminalProgramElement |
getASTParent()
A compilation unit has no syntactical parent |
ProgramElement |
getChildAt(int index)
Returns the child at the specified index in this node's "virtual" child array |
int |
getChildCount()
Returns the number of children of this node. |
int |
getChildPositionCode(ProgramElement child)
Returns the positional code of the given child, or -1 if
there is no such child. |
DataLocation |
getDataLocation()
Gets the current data location. |
ASTList<TypeDeclaration> |
getDeclarations()
Get declarations. |
SourceElement |
getFirstElement()
Finds the source element that occurs first in the source. |
ASTList<Import> |
getImports()
Get imports. |
SourceElement |
getLastElement()
Finds the source element that occurs last in the source. |
java.lang.String |
getName()
Get name of the unit. |
DataLocation |
getOriginalDataLocation()
Gets the original data location. |
PackageSpecification |
getPackageSpecification()
Get package specification. |
TypeDeclaration |
getPrimaryTypeDeclaration()
Gets the primary type declaration of the compilation unit. |
TypeDeclaration |
getTypeDeclarationAt(int index)
|
int |
getTypeDeclarationCount()
Get the number of type declarations in this container. |
ClassType |
getTypeInScope(java.lang.String name)
|
java.util.List<ClassType> |
getTypesInScope()
|
boolean |
isDefinedScope()
Check if the scope has been set up. |
void |
makeParentRoleValid()
Make parent role valid. |
void |
removeTypeFromScope(java.lang.String name)
|
boolean |
replaceChild(ProgramElement p,
ProgramElement q)
Replace a single child in the current node. |
void |
setDataLocation(DataLocation location)
Sets the current data location. |
void |
setDeclarations(ASTList<TypeDeclaration> list)
Set declarations. |
void |
setDefinedScope(boolean defined)
Sets the scope to be defined or undefined. |
void |
setImports(ASTList<Import> list)
Set imports. |
void |
setPackageSpecification(PackageSpecification p)
Set package specification. |
| Methods inherited from class recoder.java.JavaNonTerminalProgramElement |
|---|
getIndexOfChild, getRoleOfChild, makeAllParentRolesValid, validateAll |
| Methods inherited from class recoder.java.JavaProgramElement |
|---|
getComments, getID, setComments, validate |
| Methods inherited from class recoder.java.JavaSourceElement |
|---|
getEndPosition, getFactory, getRelativePosition, getStartPosition, setEndPosition, setRelativePosition, setStartPosition, toSource |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CompilationUnit()
public CompilationUnit(PackageSpecification pkg,
ASTList<Import> imports,
ASTList<TypeDeclaration> typeDeclarations)
pkg - a package specification.imports - an import mutable list.typeDeclarations - a type declaration mutable list.protected CompilationUnit(CompilationUnit proto)
proto - a compilation unit.| Method Detail |
|---|
public CompilationUnit deepClone()
deepClone in interface SourceElementpublic void makeParentRoleValid()
makeParentRoleValid in interface NonTerminalProgramElementmakeParentRoleValid in class JavaNonTerminalProgramElement
public boolean replaceChild(ProgramElement p,
ProgramElement q)
replaceChild in interface NonTerminalProgramElementp - the old child.p - the new child.
java.lang.ClassCastException - if the new child cannot take over the role of the old one.public SourceElement getFirstElement()
JavaSourceElement
getFirstElement in interface SourceElementgetFirstElement in class JavaSourceElementJavaSourceElement.toSource(),
JavaSourceElement.getStartPosition()public SourceElement getLastElement()
JavaSourceElement
getLastElement in interface SourceElementgetLastElement in class JavaSourceElementJavaSourceElement.toSource(),
JavaSourceElement.getEndPosition()public java.lang.String getName()
getDataLocation()public NonTerminalProgramElement getASTParent()
getASTParent in interface ProgramElementpublic int getChildCount()
getChildCount in interface NonTerminalProgramElementpublic ProgramElement getChildAt(int index)
getChildAt in interface NonTerminalProgramElementindex - an index into this node's "virtual" child array
java.lang.ArrayIndexOutOfBoundsException - if index is out of boundspublic int getChildPositionCode(ProgramElement child)
NonTerminalProgramElement-1 if
there is no such child. The result contains an encoding of the relative
position of the child as well as the role it has been playing in this
parent element. This information is required internally for proper undo
of transformations and is to be delivered to the detached method of the
ChangeHistory.
getChildPositionCode in interface NonTerminalProgramElementchild - the exact child to look for.
-1.ChangeHistory.detached(recoder.java.ProgramElement, recoder.java.NonTerminalProgramElement, int)public DataLocation getDataLocation()
public void setDataLocation(DataLocation location)
null
, the location also becomes the new original location.
location - a data location.public DataLocation getOriginalDataLocation()
public ASTList<Import> getImports()
public void setImports(ASTList<Import> list)
list - an import mutable list.public PackageSpecification getPackageSpecification()
public void setPackageSpecification(PackageSpecification p)
p - a package specification.public int getTypeDeclarationCount()
getTypeDeclarationCount in interface TypeDeclarationContainerpublic TypeDeclaration getTypeDeclarationAt(int index)
getTypeDeclarationAt in interface TypeDeclarationContainerpublic ASTList<TypeDeclaration> getDeclarations()
public void setDeclarations(ASTList<TypeDeclaration> list)
list - a type declaration mutable list.public TypeDeclaration getPrimaryTypeDeclaration()
null.
public boolean isDefinedScope()
ScopeDefiningElement
isDefinedScope in interface ScopeDefiningElementpublic void setDefinedScope(boolean defined)
ScopeDefiningElement
setDefinedScope in interface ScopeDefiningElementpublic java.util.List<ClassType> getTypesInScope()
getTypesInScope in interface TypeScopepublic ClassType getTypeInScope(java.lang.String name)
getTypeInScope in interface TypeScope
public void addTypeToScope(ClassType type,
java.lang.String name)
addTypeToScope in interface TypeScopepublic void removeTypeFromScope(java.lang.String name)
removeTypeFromScope in interface TypeScopepublic void accept(SourceVisitor v)
SourceElement
accept in interface SourceElementv - a source visitor.
|
RECODER 0.92 | |||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||