public interface PsiVariable extends PsiModifierListOwner, PsiNameIdentifierOwner, PsiTarget, PomRenameableTarget<PsiElement>
Iconable.IconFlags, Iconable.LastComputedIcon
EMPTY_ARRAY
ARRAY_FACTORY
ICON_FLAG_IGNORE_MASK, ICON_FLAG_OPEN, ICON_FLAG_READ_STATUS, ICON_FLAG_VISIBILITY
EMPTY_ARRAY
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
computeConstantValue()
Calculates and returns the constant value of the variable initializer.
|
PsiExpression |
getInitializer()
Returns the initializer for the variable.
|
PsiIdentifier |
getNameIdentifier()
Returns the identifier declaring the name of the variable.
|
PsiType |
getType()
Returns the type of the variable.
|
PsiTypeElement |
getTypeElement()
Returns the type element declaring the type of the variable.
|
boolean |
hasInitializer()
Checks if the variable has an initializer.
|
void |
normalizeDeclaration()
Ensures that the variable declaration is not combined in the same statement with
other declarations.
|
default void |
setInitializer(PsiExpression initializer)
Adds initializer to the variable declaration statement or, if
initializer
parameter is null, removes initializer from variable. |
PsiElement |
setName(java.lang.String name)
Renames the element.
|
getAnnotation, getAnnotations, getModifierList, hasAnnotation, hasModifier, hasModifierProperty
getIdentifyingElement
getName
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, getOwnReferences, getParent, getPrevSibling, getProject, getReference, getReferences, getResolveScope, getStartOffsetInParent, getText, getTextLength, getTextOffset, getTextRange, getTextRangeInParent, getUseScope, isEquivalentTo, isPhysical, isValid, isWritable, processDeclarations, putCopyableUserData, replace, textContains, textMatches, textMatches, textToCharArray, toString
getUserData, putUserData
getNavigationElement
isWritable
getName
canNavigate, canNavigateToSource, navigate
PsiType getType()
PsiTypeElement getTypeElement()
PsiExpression getInitializer()
hasInitializer()
boolean hasInitializer()
Checks if the variable has an initializer.
Please note that even when hasInitializer()
returns true, getInitializer()
still can return null,
e.g. for implicit initializer in case of enum constant declaration.
default void setInitializer(PsiExpression initializer) throws IncorrectOperationException
initializer
parameter is null, removes initializer from variable.initializer
- the initializer to add.IncorrectOperationException
- if the modifications fails, or if this variable does not support initializers (e.g. parameters).void normalizeDeclaration() throws IncorrectOperationException
int[] a
)
and not in C style (int a[]
).IncorrectOperationException
- if the modification fails for some reason.java.lang.Object computeConstantValue()
PsiIdentifier getNameIdentifier()
getNameIdentifier
in interface PsiNameIdentifierOwner
PsiElement setName(java.lang.String name) throws IncorrectOperationException
PsiNamedElement
setName
in interface PomRenameableTarget<PsiElement>
setName
in interface PsiNamedElement
name
- the new element name.this
or a different element if the rename caused the element to be replaced).IncorrectOperationException
- if the modification is not supported or not possible for some reason.