public interface PsiVariable extends PsiModifierListOwner, PsiNameIdentifierOwner, PsiTarget, PomRenameableTarget<PsiElement>
Iconable.IconFlags, Iconable.LastComputedIconEMPTY_ARRAYARRAY_FACTORYICON_FLAG_IGNORE_MASK, ICON_FLAG_OPEN, ICON_FLAG_READ_STATUS, ICON_FLAG_VISIBILITYEMPTY_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, hasModifierPropertygetIdentifyingElementgetNameaccept, 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, toStringgetUserData, putUserDatagetNavigationElementisWritablegetNamecanNavigate, canNavigateToSource, navigatePsiType 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 PsiNameIdentifierOwnerPsiElement setName(java.lang.String name) throws IncorrectOperationException
PsiNamedElementsetName in interface PomRenameableTarget<PsiElement>setName in interface PsiNamedElementname - 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.