Class ConstructorDecl
- java.lang.Object
-
- com.tonic.analysis.source.ast.decl.ConstructorDecl
-
-
Constructor Summary
Constructors Constructor Description ConstructorDecl(String name)Creates an empty constructor declaration at an unknown location.ConstructorDecl(String name, SourceLocation location)Creates an empty constructor declaration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Taccept(SourceVisitor<T> visitor)Accepts a visitor for this node.ConstructorDecladdAnnotation(AnnotationExpr annotation)Adds an annotation.ConstructorDecladdModifier(Modifier modifier)Adds a modifier.ConstructorDecladdParameter(ParameterDecl parameter)Adds a parameter.ConstructorDecladdThrowsType(SourceType throwsType)Adds a declared thrown exception type.ConstructorDecladdTypeParameter(SourceType typeParam)Adds a type parameter.NodeList<AnnotationExpr>getAnnotations()BlockStmtgetBody()List<ASTNode>getChildren()Lists the direct children a node holds, in source order.SourceLocationgetLocation()Gets the source location of this node.Set<Modifier>getModifiers()StringgetName()NodeList<ParameterDecl>getParameters()ASTNodegetParent()Gets the parent node in the AST tree.StringgetSignature()Builds a name-and-parameter-types signature string.NodeList<SourceType>getThrowsTypes()NodeList<SourceType>getTypeParameters()booleanisPrivate()booleanisProtected()booleanisPublic()voidsetBody(BlockStmt body)Sets the constructor body.voidsetName(String name)Sets the constructor name.voidsetParent(ASTNode parent)Sets the parent node.StringtoString()ConstructorDeclwithBody(BlockStmt body)Replaces the body, adopting the new block and releasing the old one.ConstructorDeclwithModifiers(Set<Modifier> modifiers)Replaces all modifiers with the given set.ConstructorDeclwithName(String name)Sets the constructor name.-
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, getRoot, isDescendantOf, remove, replaceWith, stream, stream, walk
-
-
-
-
Constructor Detail
-
ConstructorDecl
public ConstructorDecl(String name, SourceLocation location)
Creates an empty constructor declaration.- Parameters:
name- the declaring class's simple namelocation- the source location, or null for unknown
-
ConstructorDecl
public ConstructorDecl(String name)
Creates an empty constructor declaration at an unknown location.- Parameters:
name- the declaring class's simple name
-
-
Method Detail
-
getName
public String getName()
- Returns:
- the name
-
setName
public void setName(String name)
Sets the constructor name.- Parameters:
name- the declaring class's simple name
-
getAnnotations
public NodeList<AnnotationExpr> getAnnotations()
- Returns:
- the annotations
-
getParameters
public NodeList<ParameterDecl> getParameters()
- Returns:
- the parameters
-
getTypeParameters
public NodeList<SourceType> getTypeParameters()
- Returns:
- the type parameters
-
getThrowsTypes
public NodeList<SourceType> getThrowsTypes()
- Returns:
- the throws types
-
getBody
public BlockStmt getBody()
- Returns:
- the body
-
setBody
public void setBody(BlockStmt body)
Sets the constructor body.- Parameters:
body- the body block, or null for none
-
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)
Sets the parent node.
-
withName
public ConstructorDecl withName(String name)
Sets the constructor name.- Parameters:
name- the declaring class's simple name- Returns:
- this declaration
-
withModifiers
public ConstructorDecl withModifiers(Set<Modifier> modifiers)
Replaces all modifiers with the given set.- Parameters:
modifiers- the modifiers to apply- Returns:
- this declaration
-
addModifier
public ConstructorDecl addModifier(Modifier modifier)
Adds a modifier.- Parameters:
modifier- the modifier to add- Returns:
- this declaration
-
addAnnotation
public ConstructorDecl addAnnotation(AnnotationExpr annotation)
Adds an annotation.- Parameters:
annotation- the annotation to add- Returns:
- this declaration
-
addParameter
public ConstructorDecl addParameter(ParameterDecl parameter)
Adds a parameter.- Parameters:
parameter- the parameter declaration- Returns:
- this declaration
-
addTypeParameter
public ConstructorDecl addTypeParameter(SourceType typeParam)
Adds a type parameter.- Parameters:
typeParam- the type parameter- Returns:
- this declaration
-
addThrowsType
public ConstructorDecl addThrowsType(SourceType throwsType)
Adds a declared thrown exception type.- Parameters:
throwsType- the exception type- Returns:
- this declaration
-
withBody
public ConstructorDecl withBody(BlockStmt body)
Replaces the body, adopting the new block and releasing the old one.- Parameters:
body- the body block, or null for none- Returns:
- this declaration
-
isPublic
public boolean isPublic()
- Returns:
- true if the public modifier is present
-
isProtected
public boolean isProtected()
- Returns:
- true if the protected modifier is present
-
isPrivate
public boolean isPrivate()
- Returns:
- true if the private modifier is present
-
getSignature
public String getSignature()
Builds a name-and-parameter-types signature string.- Returns:
- the signature, e.g. Foo(int,String)
-
getChildren
public List<ASTNode> getChildren()
Description copied from interface:ASTNodeLists the direct children a node holds, in source order.- Specified by:
getChildrenin interfaceASTNode- Returns:
- the direct children, empty for a leaf
-
accept
public <T> T accept(SourceVisitor<T> visitor)
Description copied from interface:ASTNodeAccepts a visitor for this node.
-
-