Class ParameterDecl
- java.lang.Object
-
- com.tonic.analysis.source.ast.decl.ParameterDecl
-
-
Constructor Summary
Constructors Constructor Description ParameterDecl(String name, SourceType type)Creates a parameter with no source position.ParameterDecl(String name, SourceType type, SourceLocation location)Creates a parameter that is neither final nor varargs and has no annotations.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Taccept(SourceVisitor<T> visitor)Accepts a visitor for this node.ParameterDecladdAnnotation(AnnotationExpr annotation)Appends an annotation.NodeList<AnnotationExpr>getAnnotations()List<ASTNode>getChildren()Lists the direct children a node holds, in source order.SourceLocationgetLocation()Gets the source location of this node.StringgetName()ASTNodegetParent()Gets the parent node in the AST tree.SourceTypegetType()booleanisFinal()booleanisVarArgs()voidsetFinal(boolean isFinal)Marks the parameter final or not.voidsetName(String name)Renames the parameter.voidsetParent(ASTNode parent)Records the node this parameter hangs under.voidsetType(SourceType type)Replaces the declared type.voidsetVarArgs(boolean isVarArgs)Marks the parameter varargs or not.StringtoString()ParameterDeclwithFinal(boolean isFinal)Marks the parameter final or not.ParameterDeclwithName(String name)Renames the parameter.ParameterDeclwithType(SourceType type)Replaces the declared type.ParameterDeclwithVarArgs(boolean isVarArgs)Marks the parameter varargs or not.-
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
-
ParameterDecl
public ParameterDecl(String name, SourceType type, SourceLocation location)
Creates a parameter that is neither final nor varargs and has no annotations.- Parameters:
name- the parameter nametype- the declared typelocation- the source position, or null for UNKNOWN
-
ParameterDecl
public ParameterDecl(String name, SourceType type)
Creates a parameter with no source position.- Parameters:
name- the parameter nametype- the declared type
-
-
Method Detail
-
getName
public String getName()
- Returns:
- the name
-
setName
public void setName(String name)
Renames the parameter.- Parameters:
name- the new name
-
getType
public SourceType getType()
- Returns:
- the type
-
setType
public void setType(SourceType type)
Replaces the declared type.- Parameters:
type- the new type
-
isFinal
public boolean isFinal()
- Returns:
- whether final
-
setFinal
public void setFinal(boolean isFinal)
Marks the parameter final or not.- Parameters:
isFinal- true to print a final modifier
-
isVarArgs
public boolean isVarArgs()
- Returns:
- whether var args
-
setVarArgs
public void setVarArgs(boolean isVarArgs)
Marks the parameter varargs or not.- Parameters:
isVarArgs- true to print the type with a trailing ellipsis
-
getAnnotations
public NodeList<AnnotationExpr> getAnnotations()
- Returns:
- the annotations
-
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)
Records the node this parameter hangs under.
-
withName
public ParameterDecl withName(String name)
Renames the parameter.- Parameters:
name- the new name- Returns:
- this parameter
-
withType
public ParameterDecl withType(SourceType type)
Replaces the declared type.- Parameters:
type- the new type- Returns:
- this parameter
-
withFinal
public ParameterDecl withFinal(boolean isFinal)
Marks the parameter final or not.- Parameters:
isFinal- true to print a final modifier- Returns:
- this parameter
-
withVarArgs
public ParameterDecl withVarArgs(boolean isVarArgs)
Marks the parameter varargs or not.- Parameters:
isVarArgs- true to print the type with a trailing ellipsis- Returns:
- this parameter
-
addAnnotation
public ParameterDecl addAnnotation(AnnotationExpr annotation)
Appends an annotation.- Parameters:
annotation- the annotation to add- Returns:
- this parameter
-
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.
-
-