public class ASTJMethod extends ASTJMember<MethodDeclaration> implements JMethod
MethodDeclaration object.| Modifier and Type | Field and Description |
|---|---|
protected java.util.List<java.lang.String> |
addedExceptions
List of added exceptions by calling
addException(String). |
protected java.lang.String |
body |
protected java.lang.String[] |
exceptions
Array of cached exceptions.
|
protected java.lang.String[] |
parameterNames |
protected java.lang.String[] |
parameters |
protected java.lang.String |
returnType |
protected java.lang.String[] |
typeParameters |
commentisCommentedOut, name, rewriter, UNITIALIZED_STRINGEMPTY_STRING_ARRAY, qualifiedName| Constructor and Description |
|---|
ASTJMethod(MethodDeclaration methodDeclaration) |
| Modifier and Type | Method and Description |
|---|---|
void |
addException(java.lang.String exceptionType)
Adds the given exception to the end of the list of exceptions this method
is declared to throw.
|
protected java.lang.String |
computeQualifiedName() |
void |
dispose() |
java.lang.String |
getBody()
Returns the body of this method.
|
java.lang.String[] |
getExceptions()
Returns the type signatures of the exceptions this method throws,
in the order declared in the source.
|
java.lang.String[] |
getFullParameterTypes()
Returns all the types of formal parameters of the original method declaration.
|
java.lang.String |
getName()
Returns the name of this node.
|
java.lang.String[] |
getParameterNames()
Returns parameter names.
|
java.lang.String[] |
getParameters()
Returned parameters will not include new names set by
setParameterNames(String[]). |
java.lang.String[] |
getParameterTypes()
Returns type erasure of all the types of formal parameters of the original method declaration.
|
java.lang.String |
getReturnType()
Returns the return type name, or
null. |
java.lang.String[] |
getTypeParameters()
Returns the formal type parameters for this method.
|
boolean |
isConstructor()
Returns whether this method is a constructor.
|
void |
setBody(java.lang.String body)
Sets the body of this method.
|
void |
setExceptions(java.lang.String[] exceptionTypes)
Sets the names of the exception types this method throws,
in the order in which they are declared in the source.
|
void |
setName(java.lang.String name)
Sets the name of this node.
|
void |
setParameterNames(java.lang.String[] names)
Sets parameter names.
|
void |
setParameters(java.lang.String[] parameters)
Sets the parameters in this method in the order they are
to be declared.
|
void |
setReturnType(java.lang.String type)
Sets the return type name.
|
void |
setTypeParameters(java.lang.String[] typeParameters)
Sets the formal type parameters for this method.
|
addChild, getAnnotationList, getChildren, getComment, getFlags, insertLastAnnotation, insertSibling, remove, setComment, setFlagsaddValueToListProperty, addValueToListProperty, ancestorInserted, ancestorToBeRemoved, childToBeChanged, combineArrayAndList, commentOut, convertASTNodeListToStringArray, disableTrackAndReplace, enableTrackAndReplace, getASTNode, getContents, getFacadeHelper, getParent, getRemovedASTNode, getRewriter, getWrappedObject, insert, insertFirst, insertLast, isDisposed, nodeToBeMoved, nodeToBeRemoved, remove, removeNodeFromListProperty, removeTrackAndReplace, setASTNode, setFacadeHelper, setListNodeProperty, setNodeProperty, setNodeProperty, setParent, setRemovedASTNode, setRewriter, setTrackedNodeProperty, setWrappedObject, trackAndReplacecomputeQualifiedName, computeQualifiedName, computeQualifiedName, getName, getQualifiedNameclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetComment, setCommentgetChildren, getContents, getFlags, getParent, getQualifiedName, setFlagsprotected java.lang.String returnType
protected java.lang.String[] typeParameters
protected java.lang.String[] parameterNames
protected java.lang.String[] parameters
protected java.lang.String[] exceptions
addedExceptions.protected java.util.List<java.lang.String> addedExceptions
addException(String).
This list does not include existing exceptions, nor exceptions set by setExceptions(String[])protected java.lang.String body
public ASTJMethod(MethodDeclaration methodDeclaration)
methodDeclaration - public void dispose()
dispose in class ASTJMember<MethodDeclaration>public boolean isConstructor()
JMethodisConstructor in interface JMethodtrue for constructors, and false for methodspublic java.lang.String getName()
JNodepublic void setName(java.lang.String name)
JNodesetName in interface JNodeJNode.getQualifiedName()public java.lang.String getReturnType()
JMethodnull.
Returns null for constructors.
The syntax for return type name corresponds to ReturnType in
MethodDeclaration (JLS2 8.4). Names are returned as they appear in the source
code; for example: "File", "java.io.File",
"int[]", or "void".getReturnType in interface JMethodpublic void setReturnType(java.lang.String type)
JMethod"File", "java.io.File",
"int[]", or "void".setReturnType in interface JMethodtype - the return typepublic java.lang.String[] getTypeParameters()
JMethodFormal type parameters are as they appear in the source
code; for example:
"X extends List<String> & Serializable".
getTypeParameters in interface JMethodpublic void setTypeParameters(java.lang.String[] typeParameters)
JMethodsetTypeParameters in interface JMethodtypeParameters - in the order declared in the source, or an empty array if no type parameters
are declaredpublic java.lang.String[] getParameterNames()
Note that if parameters have been changed by setParameters(String[]) method,
this method will not parse parameters, and will not return the new parameter names.
This method will return either parameter names set by setParameterNames(String[]) method
or original parameter names.
getParameterNames in interface JMethodJMethod.getParameterNames()public java.lang.String[] getParameterTypes()
This method is used to create a method signature, and match methods by signature.
Note that this implementation does not expand types into fully qualified names, nor does it replace type parameters defined for a class or a method.
getParameterTypes in interface JMethodASTFacadeHelper#getTypeErasure(org.eclipse.jdt.core.dom.Type),
JMethod.getParameterTypes()public java.lang.String[] getFullParameterTypes()
getFullParameterTypes in interface JMethodJMethod.getFullParameterTypes()public void setParameterNames(java.lang.String[] names)
getParameters(),
but will be returned by getParameterNames().setParameterNames in interface JMethodnames - the list of parameter namesgetParameterNames(),
getParameters(),
JMethod.setParameterNames(java.lang.String[])public java.lang.String[] getExceptions()
JMethod
For example, a source method declaring "throws IOException",
would return the array {"QIOException;"}.
The type signatures may be either unresolved (for source types) or resolved (for binary types), and either basic (for basic types) or rich (for parameterized types).
getExceptions in interface JMethodpublic void setExceptions(java.lang.String[] exceptionTypes)
JMethod"IOException" or "java.io.IOException".setExceptions in interface JMethodexceptionTypes - the list of exception typespublic void addException(java.lang.String exceptionType)
JMethod"IOException" or "java.io.IOException".
This is a convenience method for setExceptions.addException in interface JMethodexceptionType - the exception typeJMethod.setExceptions(String[])public java.lang.String getBody()
JMethodpublic void setBody(java.lang.String body)
JMethodprotected java.lang.String computeQualifiedName()
computeQualifiedName in class AbstractJNodepublic java.lang.String[] getParameters()
setParameterNames(String[]).getParameters in interface JMethodJMethod.getParameters()public void setParameters(java.lang.String[] parameters)
JMethod"File file", "java.io.File file", or
"int[][] n[]", or final @Annotation int[]... n.setParameters in interface JMethodparameters - the list of parameters, or or an empty array if no parameters
are declaredCopyright © 2021. Licensed under the Eclipse Public License v2.0. All rights reserved.
Submit a bug or feature