com.intellij.psi
Interface PsiMethod

All Superinterfaces:
Iconable, Navigatable, NavigationItem, PsiDocCommentOwner, PsiElement, PsiMember, PsiModifierListOwner, PsiNamedElement, PsiTypeParameterListOwner, UserDataHolder
All Known Subinterfaces:
PsiAnnotationMethod, PsiAspectMethod, PsiIntertypeMethod

public interface PsiMethod
extends PsiMember, PsiNamedElement, PsiModifierListOwner, PsiDocCommentOwner, PsiTypeParameterListOwner

Represents a Java method or constructor.

See Also:
PsiClass.getMethods()

Field Summary
static PsiMethod[] EMPTY_ARRAY
          The empty array of PSI methods which can be reused to avoid unnecessary allocations.
 
Fields inherited from interface com.intellij.openapi.util.Iconable
ICON_FLAG_CLOSED, ICON_FLAG_OPEN, ICON_FLAG_READ_STATUS, ICON_FLAG_VISIBILITY
 
Fields inherited from interface com.intellij.openapi.util.Iconable
ICON_FLAG_CLOSED, ICON_FLAG_OPEN, ICON_FLAG_READ_STATUS, ICON_FLAG_VISIBILITY
 
Fields inherited from interface com.intellij.openapi.util.Iconable
ICON_FLAG_CLOSED, ICON_FLAG_OPEN, ICON_FLAG_READ_STATUS, ICON_FLAG_VISIBILITY
 
Method Summary
 PsiMethod findDeepestSuperMethod()
          Returns the method in the deepest base superclass or interface of the containing class which this method overrides or implements.
 PsiMethod[] findSuperMethods()
          Searches the superclasses and base interfaces of the containing class to find the methods which this method overrides or implements.
 PsiMethod[] findSuperMethods(boolean checkAccess)
          Searches the superclasses and base interfaces of the containing class to find the methods which this method overrides or implements, optionally omitting the accessibility check.
 PsiMethod[] findSuperMethods(PsiClass parentClass)
          Searches the superclasses and base interfaces of the specified class to find the methods which this method can override or implement.
 java.util.List<MethodSignatureBackedByPsiMethod> findSuperMethodSignaturesIncludingStatic(boolean checkAccess)
          Searches the superclasses and base interfaces of the containing class to find static and instance methods with the signature matching the signature of this method.
 PsiCodeBlock getBody()
          Returns the body of the method.
 PsiModifierList getModifierList()
          Returns the list of modifiers for the element.
 PsiIdentifier getNameIdentifier()
          Returns the name identifier for the method.
 PsiParameterList getParameterList()
          Returns the parameter list for the method.
 PomMethod getPom()
          Returns the POM representation of the method.
 PsiType getReturnType()
          Returns the return type of the method.
 PsiTypeElement getReturnTypeElement()
          Returns the type element for the return type of the method.
 MethodSignature getSignature(PsiSubstitutor substitutor)
          Returns the signature of this method, using the specified substitutor to specify values of generic type parameters.
 PsiReferenceList getThrowsList()
          Returns the list of thrown exceptions for the method.
 boolean isConstructor()
          Checks if the method is a constructor.
 boolean isVarArgs()
          Checks if the method accepts a variable number of arguments.
 
Methods inherited from interface com.intellij.psi.PsiMember
getContainingClass
 
Methods inherited from interface com.intellij.psi.PsiModifierListOwner
hasModifierProperty
 
Methods inherited from interface com.intellij.psi.PsiElement
accept, acceptChildren, add, addAfter, addBefore, addRange, addRangeAfter, addRangeBefore, checkAdd, checkDelete, copy, delete, deleteChildRange, findElementAt, findReferenceAt, getChildren, getContainingFile, getContext, getCopyableUserData, getFirstChild, getLanguage, getLastChild, getManager, getNavigationElement, getNextSibling, getNode, getOriginalElement, getParent, getPrevSibling, getProject, getReference, getReferences, getResolveScope, getStartOffsetInParent, getText, getTextLength, getTextOffset, getTextRange, getUseScope, isPhysical, isValid, isWritable, processDeclarations, putCopyableUserData, replace, textContains, textMatches, textMatches, textToCharArray
 
Methods inherited from interface com.intellij.openapi.util.UserDataHolder
getUserData, putUserData
 
Methods inherited from interface com.intellij.openapi.util.Iconable
getIcon
 
Methods inherited from interface com.intellij.navigation.NavigationItem
getFileStatus, getName, getPresentation
 
Methods inherited from interface com.intellij.pom.Navigatable
canNavigate, canNavigateToSource, navigate
 
Methods inherited from interface com.intellij.psi.PsiNamedElement
getName, setName
 
Methods inherited from interface com.intellij.psi.PsiDocCommentOwner
getDocComment, isDeprecated
 
Methods inherited from interface com.intellij.psi.PsiMember
getContainingClass
 
Methods inherited from interface com.intellij.psi.PsiModifierListOwner
hasModifierProperty
 
Methods inherited from interface com.intellij.psi.PsiElement
accept, acceptChildren, add, addAfter, addBefore, addRange, addRangeAfter, addRangeBefore, checkAdd, checkDelete, copy, delete, deleteChildRange, findElementAt, findReferenceAt, getChildren, getContainingFile, getContext, getCopyableUserData, getFirstChild, getLanguage, getLastChild, getManager, getNavigationElement, getNextSibling, getNode, getOriginalElement, getParent, getPrevSibling, getProject, getReference, getReferences, getResolveScope, getStartOffsetInParent, getText, getTextLength, getTextOffset, getTextRange, getUseScope, isPhysical, isValid, isWritable, processDeclarations, putCopyableUserData, replace, textContains, textMatches, textMatches, textToCharArray
 
Methods inherited from interface com.intellij.openapi.util.UserDataHolder
getUserData, putUserData
 
Methods inherited from interface com.intellij.openapi.util.Iconable
getIcon
 
Methods inherited from interface com.intellij.navigation.NavigationItem
getFileStatus, getName, getPresentation
 
Methods inherited from interface com.intellij.pom.Navigatable
canNavigate, canNavigateToSource, navigate
 
Methods inherited from interface com.intellij.psi.PsiTypeParameterListOwner
getTypeParameterList, getTypeParameters, hasTypeParameters
 
Methods inherited from interface com.intellij.psi.PsiMember
getContainingClass
 
Methods inherited from interface com.intellij.psi.PsiModifierListOwner
hasModifierProperty
 
Methods inherited from interface com.intellij.psi.PsiElement
accept, acceptChildren, add, addAfter, addBefore, addRange, addRangeAfter, addRangeBefore, checkAdd, checkDelete, copy, delete, deleteChildRange, findElementAt, findReferenceAt, getChildren, getContainingFile, getContext, getCopyableUserData, getFirstChild, getLanguage, getLastChild, getManager, getNavigationElement, getNextSibling, getNode, getOriginalElement, getParent, getPrevSibling, getProject, getReference, getReferences, getResolveScope, getStartOffsetInParent, getText, getTextLength, getTextOffset, getTextRange, getUseScope, isPhysical, isValid, isWritable, processDeclarations, putCopyableUserData, replace, textContains, textMatches, textMatches, textToCharArray
 
Methods inherited from interface com.intellij.openapi.util.UserDataHolder
getUserData, putUserData
 
Methods inherited from interface com.intellij.openapi.util.Iconable
getIcon
 
Methods inherited from interface com.intellij.navigation.NavigationItem
getFileStatus, getName, getPresentation
 
Methods inherited from interface com.intellij.pom.Navigatable
canNavigate, canNavigateToSource, navigate
 

Field Detail

EMPTY_ARRAY

static final PsiMethod[] EMPTY_ARRAY
The empty array of PSI methods which can be reused to avoid unnecessary allocations.

Method Detail

getReturnType

@Nullable
PsiType getReturnType()
Returns the return type of the method.

Returns:
the method return type, or null if the method is a constructor.

getReturnTypeElement

@Nullable
PsiTypeElement getReturnTypeElement()
Returns the type element for the return type of the method.

Returns:
the type element for the return type, or null if the method is a constructor.

getParameterList

@NotNull
PsiParameterList getParameterList()
Returns the parameter list for the method.

Returns:
the parameter list instance.

getThrowsList

@NotNull
PsiReferenceList getThrowsList()
Returns the list of thrown exceptions for the method.

Returns:
the list of thrown exceptions instance.

getBody

PsiCodeBlock getBody()
Returns the body of the method.

Returns:
the method body, or null if the method belongs to a compiled class.

isConstructor

boolean isConstructor()
Checks if the method is a constructor.

Returns:
true if the method is a constructor, false otherwise

isVarArgs

boolean isVarArgs()
Checks if the method accepts a variable number of arguments.

Returns:
true if the method is varargs, false otherwise

getSignature

MethodSignature getSignature(PsiSubstitutor substitutor)
Returns the signature of this method, using the specified substitutor to specify values of generic type parameters.

Parameters:
substitutor - the substitutor.
Returns:
the method signature instance.

getNameIdentifier

PsiIdentifier getNameIdentifier()
Returns the name identifier for the method.

Returns:
the name identifier instance.

findSuperMethods

@NotNull
PsiMethod[] findSuperMethods()
Searches the superclasses and base interfaces of the containing class to find the methods which this method overrides or implements. Can return multiple results if the base class and/or one or more of the implemented interfaces have a method with the same signature. If the overridden method in turn overrides another method, only the directly overridden method is returned.

Returns:
the array of super methods, or an empty array if no methods are found.

findSuperMethods

@NotNull
PsiMethod[] findSuperMethods(boolean checkAccess)
Searches the superclasses and base interfaces of the containing class to find the methods which this method overrides or implements, optionally omitting the accessibility check. Can return multiple results if the base class and/or one or more of the implemented interfaces have a method with the same signature. If the overridden method in turn overrides another method, only the directly overridden method is returned.

Parameters:
checkAccess - if false, the super methods are searched even if this method is private. If true, an empty result list is returned for private methods.
Returns:
the array of super methods, or an empty array if no methods are found.

findSuperMethods

PsiMethod[] findSuperMethods(PsiClass parentClass)
Searches the superclasses and base interfaces of the specified class to find the methods which this method can override or implement. Can return multiple results if the base class and/or one or more of the implemented interfaces have a method with the same signature.

Parameters:
parentClass - the class to search for super methods.
Returns:
the array of super methods, or an empty array if no methods are found.

findSuperMethodSignaturesIncludingStatic

java.util.List<MethodSignatureBackedByPsiMethod> findSuperMethodSignaturesIncludingStatic(boolean checkAccess)
Searches the superclasses and base interfaces of the containing class to find static and instance methods with the signature matching the signature of this method. Can return multiple results if the base class and/or one or more of the implemented interfaces have a method with the same signature. If the overridden method in turn overrides another method, only the directly overridden method is returned.

Parameters:
checkAccess - if false, the super methods are searched even if this method is private. If true, an empty result list is returned for private methods.
Returns:
the array of matching method signatures, or an empty array if no methods are found.

findDeepestSuperMethod

@Nullable
PsiMethod findDeepestSuperMethod()
Returns the method in the deepest base superclass or interface of the containing class which this method overrides or implements.

Returns:
the overridden or implemented method, or null if this method does not override or implement any other method.

getPom

PomMethod getPom()
Returns the POM representation of the method.

Returns:
the POM representation.

getModifierList

@NotNull
PsiModifierList getModifierList()
Description copied from interface: PsiModifierListOwner
Returns the list of modifiers for the element.

Specified by:
getModifierList in interface PsiModifierListOwner
Returns:
the list of modifiers, or null if the element (for example, an anonymous inner class) does not have the list of modifiers.