com.intellij.psi
Interface PsiClass

All Superinterfaces:
Iconable, Navigatable, NavigationItem, PsiDocCommentOwner, PsiElement, PsiMember, PsiMetaOwner, PsiModifierListOwner, PsiNamedElement, PsiTypeParameterListOwner, UserDataHolder
All Known Subinterfaces:
PsiAnonymousClass, PsiAspect, PsiEnumConstantInitializer, PsiTypeParameter

public interface PsiClass
extends PsiElement, PsiNamedElement, PsiModifierListOwner, PsiDocCommentOwner, PsiMetaOwner, PsiTypeParameterListOwner, PsiMember

Represents a Java class or interface.

See Also:
PsiJavaFile.getClasses()

Field Summary
static PsiClass[] EMPTY_ARRAY
          The empty array of PSI classes 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
 
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
 PsiField findFieldByName(java.lang.String name, boolean checkBases)
          Searches the class (and optionally its superclasses) for the field with the specified name.
 PsiClass findInnerClassByName(java.lang.String name, boolean checkBases)
          Searches the class (and optionally its superclasses) for the inner class with the specified name.
 PsiMethod findMethodBySignature(PsiMethod patternMethod, boolean checkBases)
          Searches the class (and optionally its superclasses) for the method with the signature matching the signature of the specified method.
 java.util.List<Pair<PsiMethod,PsiSubstitutor>> findMethodsAndTheirSubstitutorsByName(java.lang.String name, boolean checkBases)
          Searches the class (and optionally its superclasses) for the methods with the specified name and returns the methods along with their substitutors.
 PsiMethod[] findMethodsByName(java.lang.String name, boolean checkBases)
          Searches the class (and optionally its superclasses) for the methods with the specified name.
 PsiMethod[] findMethodsBySignature(PsiMethod patternMethod, boolean checkBases)
          Searches the class (and optionally its superclasses) for the methods with the signature matching the signature of the specified method.
 PsiField[] getAllFields()
          Returns the list of fields in the class and all its superclasses.
 PsiClass[] getAllInnerClasses()
          Returns the list of inner classes for the class and all its superclasses..
 PsiMethod[] getAllMethods()
          Returns the list of methods in the class and all its superclasses.
 java.util.List<Pair<PsiMethod,PsiSubstitutor>> getAllMethodsAndTheirSubstitutors()
          Returns the list of methods in the class and all its superclasses, along with their substitutors.
 PsiMethod[] getConstructors()
          Returns the list of constructors for the class.
 PsiClass getContainingClass()
          For an inner class, returns its containing class.
 PsiReferenceList getExtendsList()
          Returns the list of classes that this class or interface extends.
 PsiClassType[] getExtendsListTypes()
          Returns the list of class types for the classes that this class or interface extends.
 PsiField[] getFields()
          Returns the list of fields in the class.
 PsiReferenceList getImplementsList()
          Returns the list of interfaces that this class implements.
 PsiClassType[] getImplementsListTypes()
          Returns the list of class types for the interfaces that this class implements.
 PsiClassInitializer[] getInitializers()
          Returns the list of class initializers for the class.
 PsiClass[] getInnerClasses()
          Returns the list of inner classes for the class.
 PsiClass[] getInterfaces()
          Returns the list of interfaces implemented by the class, or extended by the interface.
 PsiJavaToken getLBrace()
          Returns the token representing the opening curly brace of the class.
 PsiMethod[] getMethods()
          Returns the list of methods in the class.
 PsiIdentifier getNameIdentifier()
          Returns the name identifier of the class.
 PomMemberOwner getPom()
          Returns the POM representation of the class.
 java.lang.String getQualifiedName()
          Returns the fully qualified name of the class.
 PsiJavaToken getRBrace()
          Returns the token representing the closing curly brace of the class.
 PsiElement getScope()
          Returns the PSI member in which the class has been declared (for example, the method containing the anonymous inner class, or the file containing a regular class, or the class owning a type parameter).
 PsiClass getSuperClass()
          Returns the base class of this class.
 PsiClass[] getSupers()
          Returns the list of classes and interfaces extended or implemented by the class.
 PsiClassType[] getSuperTypes()
          Returns the list of class types for the classes and interfaces extended or implemented by the class.
 boolean isAnnotationType()
          Checks if the class is an annotation type.
 boolean isEnum()
          Checks if the class is an enumeration.
 boolean isInheritor(PsiClass baseClass, boolean checkDeep)
          Checks if this class is an inheritor of the specified base class.
 boolean isInterface()
          Checks if the class is an interface.
 
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.psi.PsiNamedElement
getName, setName
 
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.psi.PsiModifierListOwner
getModifierList, 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.psi.PsiDocCommentOwner
getDocComment, isDeprecated
 
Methods inherited from interface com.intellij.psi.PsiModifierListOwner
getModifierList, 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.meta.PsiMetaOwner
getMetaData, isMetaEnough
 
Methods inherited from interface com.intellij.psi.PsiTypeParameterListOwner
getTypeParameterList, getTypeParameters, hasTypeParameters
 
Methods inherited from interface com.intellij.psi.PsiModifierListOwner
getModifierList, 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

@NotNull
static final PsiClass[] EMPTY_ARRAY
The empty array of PSI classes which can be reused to avoid unnecessary allocations.

Method Detail

getQualifiedName

@Nullable
java.lang.String getQualifiedName()
Returns the fully qualified name of the class.

Returns:
the qualified name of the class, or null for anonymous and local classes, and for type parameters

isInterface

boolean isInterface()
Checks if the class is an interface.

Returns:
true if the class is an interface, false otherwise.

isAnnotationType

boolean isAnnotationType()
Checks if the class is an annotation type.

Returns:
true if the class is an annotation type, false otherwise

isEnum

boolean isEnum()
Checks if the class is an enumeration.

Returns:
true if the class is an enumeration, false otherwise.

getExtendsList

@Nullable
PsiReferenceList getExtendsList()
Returns the list of classes that this class or interface extends.

Returns:
the extends list, or null for anonymous classes, enums and annotation types

getImplementsList

@Nullable
PsiReferenceList getImplementsList()
Returns the list of interfaces that this class implements.

Returns:
the implements list, or null for anonymous classes

getExtendsListTypes

@NotNull
PsiClassType[] getExtendsListTypes()
Returns the list of class types for the classes that this class or interface extends.

Returns:
the list of extended class types, or an empty list for anonymous classes, enums and annotation types

getImplementsListTypes

@NotNull
PsiClassType[] getImplementsListTypes()
Returns the list of class types for the interfaces that this class implements.

Returns:
the list of extended class types, or an empty list for anonymous classes, enums and annotation types

getSuperClass

@Nullable
PsiClass getSuperClass()
Returns the base class of this class.

Returns:
the base class. May return null when jdk is not configured, so no java.lang.Object is found, or for java.lang.Object itself

getInterfaces

PsiClass[] getInterfaces()
Returns the list of interfaces implemented by the class, or extended by the interface.

Returns:
the list of interfaces.

getSupers

@NotNull
PsiClass[] getSupers()
Returns the list of classes and interfaces extended or implemented by the class.

Returns:
the list of classes or interfaces. May return zero elements when jdk is not configured, so no java.lang.Object is found

getSuperTypes

@NotNull
PsiClassType[] getSuperTypes()
Returns the list of class types for the classes and interfaces extended or implemented by the class.

Returns:
the list of class types for the classes or interfaces. The returned list always contains at least one element, for the type of the java.lang.Object class.

getFields

@NotNull
PsiField[] getFields()
Returns the list of fields in the class.

Returns:
the list of fields.

getMethods

@NotNull
PsiMethod[] getMethods()
Returns the list of methods in the class.

Returns:
the list of methods.

getConstructors

@NotNull
PsiMethod[] getConstructors()
Returns the list of constructors for the class.

Returns:
the list of constructors,

getInnerClasses

@NotNull
PsiClass[] getInnerClasses()
Returns the list of inner classes for the class.

Returns:
the list of inner classes.

getInitializers

@NotNull
PsiClassInitializer[] getInitializers()
Returns the list of class initializers for the class.

Returns:
the list of class initializers.

getAllFields

@NotNull
PsiField[] getAllFields()
Returns the list of fields in the class and all its superclasses.

Returns:
the list of fields.

getAllMethods

@NotNull
PsiMethod[] getAllMethods()
Returns the list of methods in the class and all its superclasses.

Returns:
the list of methods.

getAllInnerClasses

@NotNull
PsiClass[] getAllInnerClasses()
Returns the list of inner classes for the class and all its superclasses..

Returns:
the list of inner classes.

findFieldByName

@Nullable
PsiField findFieldByName(java.lang.String name,
                                  boolean checkBases)
Searches the class (and optionally its superclasses) for the field with the specified name.

Parameters:
name - the name of the field to find.
checkBases - if true, the field is also searched in the base classes of the class.
Returns:
the field instance, or null if the field cannot be found.

findMethodBySignature

@Nullable
PsiMethod findMethodBySignature(PsiMethod patternMethod,
                                         boolean checkBases)
Searches the class (and optionally its superclasses) for the method with the signature matching the signature of the specified method.

Parameters:
patternMethod - the method used as a pattern for the search.
checkBases - if true, the method is also searched in the base classes of the class.
Returns:
the method instance, or null if the method cannot be found.

findMethodsBySignature

@NotNull
PsiMethod[] findMethodsBySignature(PsiMethod patternMethod,
                                           boolean checkBases)
Searches the class (and optionally its superclasses) for the methods with the signature matching the signature of the specified method. If the superclasses are not searched, the method returns multiple results only in case of a syntax error (duplicate method).

Parameters:
patternMethod - the method used as a pattern for the search.
checkBases - if true, the method is also searched in the base classes of the class.
Returns:
the found methods, or an empty array if no methods are found.

findMethodsByName

@NotNull
PsiMethod[] findMethodsByName(java.lang.String name,
                                      boolean checkBases)
Searches the class (and optionally its superclasses) for the methods with the specified name.

Parameters:
name - the name of the methods to find.
checkBases - if true, the methods are also searched in the base classes of the class.
Returns:
the found methods, or an empty array if no methods are found.

findMethodsAndTheirSubstitutorsByName

@NotNull
java.util.List<Pair<PsiMethod,PsiSubstitutor>> findMethodsAndTheirSubstitutorsByName(java.lang.String name,
                                                                                             boolean checkBases)
Searches the class (and optionally its superclasses) for the methods with the specified name and returns the methods along with their substitutors.

Parameters:
name - the name of the methods to find.
checkBases - if true, the methods are also searched in the base classes of the class.
Returns:
the found methods and their substitutors, or an empty list if no methods are found.

getAllMethodsAndTheirSubstitutors

@NotNull
java.util.List<Pair<PsiMethod,PsiSubstitutor>> getAllMethodsAndTheirSubstitutors()
Returns the list of methods in the class and all its superclasses, along with their substitutors.

Returns:
the list of methods and their substitutors

findInnerClassByName

@Nullable
PsiClass findInnerClassByName(java.lang.String name,
                                       boolean checkBases)
Searches the class (and optionally its superclasses) for the inner class with the specified name.

Parameters:
name - the name of the inner class to find.
checkBases - if true, the inner class is also searched in the base classes of the class.
Returns:
the inner class instance, or null if the inner class cannot be found.

getLBrace

@Nullable
PsiJavaToken getLBrace()
Returns the token representing the opening curly brace of the class.

Returns:
the token instance, or null if the token is missing in the source code file.

getRBrace

@Nullable
PsiJavaToken getRBrace()
Returns the token representing the closing curly brace of the class.

Returns:
the token instance, or null if the token is missing in the source code file.

getNameIdentifier

@Nullable
PsiIdentifier getNameIdentifier()
Returns the name identifier of the class.

Returns:
the name identifier, or null if the class is incomplete and the name identifier is missing.

getScope

PsiElement getScope()
Returns the PSI member in which the class has been declared (for example, the method containing the anonymous inner class, or the file containing a regular class, or the class owning a type parameter).

Returns:
the member in which the class has been declared.

isInheritor

boolean isInheritor(PsiClass baseClass,
                    boolean checkDeep)
Checks if this class is an inheritor of the specified base class.

Parameters:
baseClass - the base class to check the inheritance.
checkDeep - if false, only direct inheritance is checked; if true, the base class is searched in the entire inheritance chain
Returns:
true if the class is an inheritor, false otherwise

getPom

@Nullable
PomMemberOwner getPom()
Returns the POM representation of the class.

Returns:
the POM representation.

getContainingClass

@Nullable
PsiClass getContainingClass()
For an inner class, returns its containing class.

Specified by:
getContainingClass in interface PsiMember
Returns:
the containing class, or null if the class is not an inner class.