com.intellij.psi
Interface PsiModifierList

All Superinterfaces:
Iconable, PsiElement, UserDataHolder

public interface PsiModifierList
extends PsiElement

Represents the list of modifiers and annotations on a Java element (class, method, field and so on). Possible modifiers are defined as constants in the PsiModifier class.

See Also:
PsiModifierListOwner.getModifierList()

Field Summary
 
Fields inherited from interface com.intellij.psi.PsiElement
EMPTY_ARRAY
 
Fields inherited from interface com.intellij.openapi.util.Iconable
ICON_FLAG_CLOSED, ICON_FLAG_OPEN, ICON_FLAG_READ_STATUS, ICON_FLAG_VISIBILITY
 
Method Summary
 void checkSetModifierProperty(java.lang.String name, boolean value)
          Checks if it is possible to add or remove the specified modifier to the modifier list, and throws an exception if the operation is not possible.
 PsiAnnotation findAnnotation(java.lang.String qualifiedName)
          Searches the modifier list for an annotation with the specified fully qualified name and returns one if it is found.
 PsiAnnotation[] getAnnotations()
          Returns the list of annotations contained in the modifier list.
 boolean hasExplicitModifier(java.lang.String name)
          Checks if the modifier list has the specified modifier set by an explicit keyword.
 boolean hasModifierProperty(java.lang.String name)
          Checks if the modifier list has the specified modifier set either by an explicit keyword or implicitly (for example, interface methods are implicitly public).
 void setModifierProperty(java.lang.String name, boolean value)
          Adds or removes the specified modifier to the modifier list.
 
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
 

Method Detail

hasModifierProperty

boolean hasModifierProperty(@NotNull
                            java.lang.String name)
Checks if the modifier list has the specified modifier set either by an explicit keyword or implicitly (for example, interface methods are implicitly public).

Parameters:
name - the name of the modifier to check.
Returns:
true if the list has the modifier, false otherwise
See Also:
hasExplicitModifier(String)

hasExplicitModifier

boolean hasExplicitModifier(@NotNull
                            java.lang.String name)
Checks if the modifier list has the specified modifier set by an explicit keyword.

Parameters:
name - the name of the modifier to check.
Returns:
true if the list has the modifier, false otherwise
See Also:
hasModifierProperty(String)

setModifierProperty

void setModifierProperty(@NotNull
                         java.lang.String name,
                         boolean value)
                         throws IncorrectOperationException
Adds or removes the specified modifier to the modifier list.

Parameters:
name - the name of the modifier to add or remove.
value - true if the modifier should be added, false if it should be removed.
Throws:
IncorrectOperationException - if the modification fails for some reason.

checkSetModifierProperty

void checkSetModifierProperty(@NotNull
                              java.lang.String name,
                              boolean value)
                              throws IncorrectOperationException
Checks if it is possible to add or remove the specified modifier to the modifier list, and throws an exception if the operation is not possible. Does not actually modify anything.

Parameters:
name - the name of the modifier to check the add or remove possibility for.
value - true if the modifier should be added, false if it should be removed.
Throws:
IncorrectOperationException - if the modification fails for some reason.

getAnnotations

@NotNull
PsiAnnotation[] getAnnotations()
Returns the list of annotations contained in the modifier list.

Returns:
the list of annotations.

findAnnotation

@Nullable
PsiAnnotation findAnnotation(@NotNull
                                      java.lang.String qualifiedName)
Searches the modifier list for an annotation with the specified fully qualified name and returns one if it is found.

Parameters:
qualifiedName - the fully qualified name of the annotation to find.
Returns:
the annotation instance, or null if no such annotation is found.