Class ImportDecl
- java.lang.Object
-
- com.tonic.analysis.source.ast.decl.ImportDecl
-
-
Constructor Summary
Constructors Constructor Description ImportDecl(String name)Creates a plain single-type import at an unknown location.ImportDecl(String name, boolean isStatic, boolean isWildcard)Creates an import at an unknown location.ImportDecl(String name, boolean isStatic, boolean isWildcard, SourceLocation location)Creates an import.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Taccept(SourceVisitor<T> visitor)Accepts a visitor for this node.SourceLocationgetLocation()Gets the source location of this node.StringgetName()StringgetPackageName()ASTNodegetParent()Gets the parent node in the AST tree.StringgetSimpleName()booleanisStatic()booleanisWildcard()static ImportDeclregular(String name)Creates a single-type import.voidsetName(String name)voidsetParent(ASTNode parent)Sets the parent node in the AST tree.static ImportDeclstaticImport(String name)Creates a single static member import.static ImportDeclstaticWildcard(String className)Creates a static on-demand import.StringtoString()static ImportDeclwildcard(String packageName)Creates an on-demand import.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.tonic.analysis.source.ast.ASTNode
deepClone, findAll, findAll, findAncestor, findFirst, findFirst, getChildren, getRoot, isDescendantOf, remove, replaceWith, stream, stream, walk
-
-
-
-
Constructor Detail
-
ImportDecl
public ImportDecl(String name, boolean isStatic, boolean isWildcard, SourceLocation location)
Creates an import.- Parameters:
name- the imported nameisStatic- true for a static importisWildcard- true for an on-demand importlocation- the source location, null becomes UNKNOWN
-
ImportDecl
public ImportDecl(String name, boolean isStatic, boolean isWildcard)
Creates an import at an unknown location.- Parameters:
name- the imported nameisStatic- true for a static importisWildcard- true for an on-demand import
-
ImportDecl
public ImportDecl(String name)
Creates a plain single-type import at an unknown location.- Parameters:
name- the imported name
-
-
Method Detail
-
getName
public String getName()
- Returns:
- the name
-
setName
public void setName(String name)
- Parameters:
name- the imported name
-
isStatic
public boolean isStatic()
- Returns:
- whether static
-
isWildcard
public boolean isWildcard()
- Returns:
- whether wildcard
-
getLocation
public SourceLocation getLocation()
Description copied from interface:ASTNodeGets the source location of this node.- Specified by:
getLocationin interfaceASTNode- Returns:
- the location
-
getParent
public ASTNode getParent()
Description copied from interface:ASTNodeGets the parent node in the AST tree.
-
setParent
public void setParent(ASTNode parent)
Description copied from interface:ASTNodeSets the parent node in the AST tree.
-
regular
public static ImportDecl regular(String name)
Creates a single-type import.- Parameters:
name- the fully qualified type name- Returns:
- the import
-
staticImport
public static ImportDecl staticImport(String name)
Creates a single static member import.- Parameters:
name- the fully qualified member name- Returns:
- the import
-
wildcard
public static ImportDecl wildcard(String packageName)
Creates an on-demand import.- Parameters:
packageName- the package to import from- Returns:
- the import
-
staticWildcard
public static ImportDecl staticWildcard(String className)
Creates a static on-demand import.- Parameters:
className- the class whose static members are imported- Returns:
- the import
-
getPackageName
public String getPackageName()
- Returns:
- everything before the last dot, or "" if the name has no dot
-
getSimpleName
public String getSimpleName()
- Returns:
- "*" for a wildcard import, otherwise the segment after the last dot
-
accept
public <T> T accept(SourceVisitor<T> visitor)
Description copied from interface:ASTNodeAccepts a visitor for this node.
-
-