public final class CompilationUnit extends Node implements org.walkmod.merger.Mergeable<CompilationUnit>
This class represents the entire compilation unit. Each java file denotes a compilation unit.
The CompilationUnit is constructed following the syntax:
CompilationUnit
::=
( PackageDeclaration )?
( ImportDeclaration )*
( TypeDeclaration )*
| Constructor and Description |
|---|
CompilationUnit() |
CompilationUnit(int beginLine,
int beginColumn,
int endLine,
int endColumn,
PackageDeclaration pakage,
List<ImportDeclaration> imports,
List<TypeDeclaration> types,
List<Comment> comments) |
CompilationUnit(PackageDeclaration pakage,
List<ImportDeclaration> imports,
List<TypeDeclaration> types,
List<Comment> comments) |
| Modifier and Type | Method and Description |
|---|---|
<R,A> R |
accept(GenericVisitor<R,A> v,
A arg)
Accept method for visitor support.
|
<A> void |
accept(VoidVisitor<A> v,
A arg)
Accept method for visitor support.
|
CompilationUnit |
clone() |
List<Node> |
getChildren() |
List<Comment> |
getComments()
Return a list containing all comments declared in this compilation unit.
|
String |
getFileName() |
Comparator<?> |
getIdentityComparator() |
List<ImportDeclaration> |
getImports()
Retrieves the list of imports declared in this compilation unit or
null if there
is no import. |
PackageDeclaration |
getPackage()
Retrieves the package declaration of this compilation unit.
|
String |
getQualifiedName() |
String |
getSimpleName() |
List<TypeDeclaration> |
getTypes()
Return the list of types declared in this compilation unit.
|
URI |
getURI() |
boolean |
hasEqualFileName(CompilationUnit other) |
void |
merge(CompilationUnit remoteCU,
org.walkmod.merger.MergeEngine configuration) |
boolean |
removeChild(Node child) |
boolean |
replaceChildNode(Node oldChild,
Node newChild) |
void |
setComments(List<Comment> comments)
Sets the list of comments of this compilation unit.
|
void |
setImports(List<ImportDeclaration> imports)
Sets the list of imports of this compilation unit.
|
void |
setPackage(PackageDeclaration pakage)
Sets or clear the package declarations of this compilation unit.
|
void |
setTypes(List<TypeDeclaration> types)
Sets the list of types declared in this compilation unit.
|
void |
setURI(URI uri) |
boolean |
withSymbols() |
void |
withSymbols(boolean isCompilable) |
check, clone, clone, contains, diableConstraints, enableConstraints, equals, getBeginColumn, getBeginLine, getCommonAncestor, getConstraints, getData, getEndColumn, getEndLine, getParentNode, getPrettySource, getPrettySource, hashCode, isAncestorOf, isInEqualLocation, isNewNode, isPreviousThan, remove, replaceChildNodeInList, setAsParentNodeOf, setAsParentNodeOf, setBeginColumn, setBeginLine, setConstraints, setData, setEndColumn, setEndLine, toString, updateReferencespublic CompilationUnit()
public CompilationUnit(PackageDeclaration pakage, List<ImportDeclaration> imports, List<TypeDeclaration> types, List<Comment> comments)
public CompilationUnit(int beginLine,
int beginColumn,
int endLine,
int endColumn,
PackageDeclaration pakage,
List<ImportDeclaration> imports,
List<TypeDeclaration> types,
List<Comment> comments)
public void setURI(URI uri)
public URI getURI()
public List<Node> getChildren()
getChildren in class Nodepublic boolean removeChild(Node child)
removeChild in class Nodepublic <R,A> R accept(GenericVisitor<R,A> v, A arg)
Nodepublic <A> void accept(VoidVisitor<A> v, A arg)
Nodepublic List<Comment> getComments()
null is returned.nullJavadocComment,
LineComment,
BlockCommentpublic List<ImportDeclaration> getImports()
null if there
is no import.null if there is no importpublic PackageDeclaration getPackage()
null is
returned.nullpublic List<TypeDeclaration> getTypes()
null is returned.null null if there is no typeAnnotationDeclaration,
ClassOrInterfaceDeclaration,
EmptyTypeDeclaration,
EnumDeclarationpublic void setComments(List<Comment> comments)
comments - the list of commentspublic void setImports(List<ImportDeclaration> imports)
null.imports - the list of importspublic void setPackage(PackageDeclaration pakage)
pakage - the pakage declaration to set or null to default packagepublic void setTypes(List<TypeDeclaration> types)
types - the lis of typespublic Comparator<?> getIdentityComparator()
getIdentityComparator in interface org.walkmod.merger.IdentificableNodepublic void merge(CompilationUnit remoteCU, org.walkmod.merger.MergeEngine configuration)
merge in interface org.walkmod.merger.Mergeable<CompilationUnit>public boolean replaceChildNode(Node oldChild, Node newChild)
replaceChildNode in class Nodepublic boolean hasEqualFileName(CompilationUnit other)
public String getQualifiedName()
public String getFileName()
public String getSimpleName()
public CompilationUnit clone() throws CloneNotSupportedException
clone in class NodeCloneNotSupportedExceptionpublic boolean withSymbols()
public void withSymbols(boolean isCompilable)
Copyright © 2018. All rights reserved.