com.intellij.psi
Class PsiType

java.lang.Object
  extended by com.intellij.psi.PsiType
Direct Known Subclasses:
PsiArrayType, PsiCapturedWildcardType, PsiClassType, PsiIntersectionType, PsiPrimitiveType, PsiWildcardType

public abstract class PsiType
extends java.lang.Object

Representation of Java type (primitive type, array or class type).


Field Summary
static PsiType BOOLEAN
           
static PsiType BYTE
           
static PsiType CHAR
           
static PsiType DOUBLE
           
static PsiType[] EMPTY_ARRAY
           
static PsiType FLOAT
           
static PsiType INT
           
static PsiType LONG
           
static PsiType NULL
           
static PsiType SHORT
           
static PsiType VOID
           
 
Constructor Summary
PsiType()
           
 
Method Summary
abstract
<A> A
accept(PsiTypeVisitor<A> visitor)
          Passes the type to the specified visitor.
 PsiArrayType createArrayType()
          Creates array type with this type as a component.
abstract  boolean equalsToText(java.lang.String text)
          Checks if the specified string is equivalent to the canonical text of the type.
 int getArrayDimensions()
          Returns the number of array dimensions for the type.
abstract  java.lang.String getCanonicalText()
           
 PsiType getDeepComponentType()
          Returns the innermost component type for an array type.
abstract  java.lang.String getInternalCanonicalText()
           
static PsiClassType getJavaLangClass(PsiManager manager, GlobalSearchScope resolveScope)
          Returns the class type for the java.lang.Class class.
static PsiClassType getJavaLangError(PsiManager manager, GlobalSearchScope resolveScope)
          Returns the class type for the java.lang.Error class.
static PsiClassType getJavaLangObject(PsiManager manager, GlobalSearchScope resolveScope)
          Returns the class type for the java.lang.Object class.
static PsiClassType getJavaLangRuntimeException(PsiManager manager, GlobalSearchScope resolveScope)
          Returns the class type for the java.lang.RuntimeException class.
static PsiClassType getJavaLangString(PsiManager manager, GlobalSearchScope resolveScope)
          Returns the class type for the java.lang.String class.
static PsiClassType getJavaLangTrowable(PsiManager manager, GlobalSearchScope resolveScope)
          Returns the class type for the java.lang.Throwable class.
abstract  java.lang.String getPresentableText()
          Returns text of this type that can be presented to user.
abstract  GlobalSearchScope getResolveScope()
          Returns the scope in which the reference to the underlying class of a class type is searched.
abstract  PsiType[] getSuperTypes()
          Returns the list of superclass types for a class type.
 boolean isAssignableFrom(PsiType type)
          Checks whether values of type type can be assigned to rvalues of this type.
 boolean isConvertibleFrom(PsiType type)
          Checks whether values of type type can be casted to this type.
abstract  boolean isValid()
          Checks if the type is currently valid.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BYTE

public static final PsiType BYTE

CHAR

public static final PsiType CHAR

DOUBLE

public static final PsiType DOUBLE

FLOAT

public static final PsiType FLOAT

INT

public static final PsiType INT

LONG

public static final PsiType LONG

SHORT

public static final PsiType SHORT

BOOLEAN

public static final PsiType BOOLEAN

VOID

public static final PsiType VOID

NULL

public static final PsiType NULL

EMPTY_ARRAY

public static PsiType[] EMPTY_ARRAY
Constructor Detail

PsiType

public PsiType()
Method Detail

createArrayType

public PsiArrayType createArrayType()
Creates array type with this type as a component.


getPresentableText

public abstract java.lang.String getPresentableText()
Returns text of this type that can be presented to user.


getCanonicalText

public abstract java.lang.String getCanonicalText()

getInternalCanonicalText

public abstract java.lang.String getInternalCanonicalText()

isValid

public abstract boolean isValid()
Checks if the type is currently valid.

Returns:
true if the type is valid, false otherwise.
See Also:
PsiElement.isValid()

isAssignableFrom

public boolean isAssignableFrom(PsiType type)
Checks whether values of type type can be assigned to rvalues of this type.


isConvertibleFrom

public boolean isConvertibleFrom(PsiType type)
Checks whether values of type type can be casted to this type.


equalsToText

public abstract boolean equalsToText(java.lang.String text)
Checks if the specified string is equivalent to the canonical text of the type.

Parameters:
text - the text to compare with.
Returns:
true if the string is equivalent to the type, false otherwise

getJavaLangObject

public static PsiClassType getJavaLangObject(PsiManager manager,
                                             GlobalSearchScope resolveScope)
Returns the class type for the java.lang.Object class.

Parameters:
manager - the PSI manager used to create the class type.
resolveScope - the scope in which the class is searched.
Returns:
the class instance.

getJavaLangClass

public static PsiClassType getJavaLangClass(PsiManager manager,
                                            GlobalSearchScope resolveScope)
Returns the class type for the java.lang.Class class.

Parameters:
manager - the PSI manager used to create the class type.
resolveScope - the scope in which the class is searched.
Returns:
the class instance.

getJavaLangTrowable

public static PsiClassType getJavaLangTrowable(PsiManager manager,
                                               GlobalSearchScope resolveScope)
Returns the class type for the java.lang.Throwable class.

Parameters:
manager - the PSI manager used to create the class type.
resolveScope - the scope in which the class is searched.
Returns:
the class instance.

getJavaLangString

public static PsiClassType getJavaLangString(PsiManager manager,
                                             GlobalSearchScope resolveScope)
Returns the class type for the java.lang.String class.

Parameters:
manager - the PSI manager used to create the class type.
resolveScope - the scope in which the class is searched.
Returns:
the class instance.

getJavaLangError

public static PsiClassType getJavaLangError(PsiManager manager,
                                            GlobalSearchScope resolveScope)
Returns the class type for the java.lang.Error class.

Parameters:
manager - the PSI manager used to create the class type.
resolveScope - the scope in which the class is searched.
Returns:
the class instance.

getJavaLangRuntimeException

public static PsiClassType getJavaLangRuntimeException(PsiManager manager,
                                                       GlobalSearchScope resolveScope)
Returns the class type for the java.lang.RuntimeException class.

Parameters:
manager - the PSI manager used to create the class type.
resolveScope - the scope in which the class is searched.
Returns:
the class instance.

accept

public abstract <A> A accept(PsiTypeVisitor<A> visitor)
Passes the type to the specified visitor.

Parameters:
visitor - the visitor to accept the type.
Returns:
the value returned by the visitor.

getArrayDimensions

public final int getArrayDimensions()
Returns the number of array dimensions for the type.

Returns:
the number of dimensions, or 0 if the type is not an array type.

getDeepComponentType

@NotNull
public final PsiType getDeepComponentType()
Returns the innermost component type for an array type.

Returns:
the innermost (non-array) component of the type, or this if the type is not an array type.

getResolveScope

@Nullable
public abstract GlobalSearchScope getResolveScope()
Returns the scope in which the reference to the underlying class of a class type is searched.

Returns:
the resolve scope instance, or null if the type is a primitive or an array of primitives.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getSuperTypes

@NotNull
public abstract PsiType[] getSuperTypes()
Returns the list of superclass types for a class type.

Returns:
the array of superclass types, or an empty array if the type is not a class type.