public class AnnotationUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
CHECK_EXTERNAL |
static int |
CHECK_HIERARCHY |
static int |
CHECK_INFERRED |
static int |
CHECK_TYPE |
static java.lang.String |
LANGUAGE |
static java.lang.String |
NLS |
static java.lang.String |
NON_NLS |
static java.lang.String |
NOT_NULL |
static java.lang.String |
NULLABLE |
static java.lang.String |
PROPERTY_KEY |
static java.lang.String |
PROPERTY_KEY_RESOURCE_BUNDLE_PARAMETER |
static java.lang.String |
TEST_ONLY |
Constructor and Description |
---|
AnnotationUtil() |
Modifier and Type | Method and Description |
---|---|
static java.util.List<PsiAnnotationMemberValue> |
arrayAttributeValues(PsiAnnotationMemberValue attributeValue) |
static boolean |
checkAnnotatedUsingPatterns(PsiModifierListOwner owner,
java.util.Collection<java.lang.String> annotations)
Works similar to #isAnnotated(PsiModifierListOwner, Collection
|
static boolean |
equal(PsiAnnotation [] annotations1,
PsiAnnotation [] annotations2)
Ignores Override and SuppressWarnings annotations.
|
static boolean |
equal(PsiAnnotationMemberValue value1,
PsiAnnotationMemberValue value2) |
static boolean |
equal(PsiAnnotation a,
PsiAnnotation b) |
static java.util.List<PsiAnnotation> |
findAllAnnotations(PsiModifierListOwner listOwner,
java.util.Collection<java.lang.String> annotationNames,
boolean skipExternal)
Returns all annotations associated with
listOwner having fully qualified names from annotationNames ,
including repeatable annotations and annotations from several external annotations roots. |
static PsiAnnotation |
findAnnotation(PsiModifierListOwner listOwner,
boolean skipExternal,
java.lang.String... annotationNames) |
static PsiAnnotation |
findAnnotation(PsiModifierListOwner listOwner,
java.util.Collection<java.lang.String> annotationNames) |
static PsiAnnotation |
findAnnotation(PsiModifierListOwner listOwner,
java.util.Collection<java.lang.String> annotationNames,
boolean skipExternal) |
static PsiAnnotation |
findAnnotation(PsiModifierListOwner listOwner,
java.util.Set<java.lang.String> annotationNames) |
static PsiAnnotation |
findAnnotation(PsiModifierListOwner listOwner,
java.lang.String... annotationNames) |
static <T extends java.lang.annotation.Annotation> |
findAnnotationInHierarchy(PsiModifierListOwner listOwner,
java.lang.Class<T> annotationClass) |
static PsiAnnotation |
findAnnotationInHierarchy(PsiModifierListOwner listOwner,
java.util.Set<java.lang.String> annotationNames) |
static PsiAnnotation |
findAnnotationInHierarchy(PsiModifierListOwner listOwner,
java.util.Set<java.lang.String> annotationNames,
boolean skipExternal) |
static PsiAnnotation |
findAnnotationInTypeHierarchy(PsiType type,
java.util.Set<java.lang.String> qualifiedNames) |
static PsiAnnotation [] |
findAnnotations(PsiModifierListOwner modifierListOwner,
java.util.Collection<java.lang.String> annotationNames) |
static PsiNameValuePair |
findDeclaredAttribute(PsiAnnotation annotation,
java.lang.String attributeName) |
static PsiAnnotation [] |
getAllAnnotations(PsiModifierListOwner owner,
boolean inHierarchy,
java.util.Set<? super PsiModifierListOwner> visited) |
static PsiAnnotation [] |
getAllAnnotations(PsiModifierListOwner owner,
boolean inHierarchy,
java.util.Set<? super PsiModifierListOwner> visited,
boolean withInferred) |
static PsiMethod |
getAnnotationMethod(PsiNameValuePair pair) |
static java.lang.Boolean |
getBooleanAttributeValue(PsiAnnotation anno,
java.lang.String attributeName) |
static java.lang.String |
getDeclaredStringAttributeValue(PsiAnnotation anno,
java.lang.String attributeName) |
static java.lang.Long |
getLongAttributeValue(PsiAnnotation anno,
java.lang.String attributeName) |
static java.lang.String |
getStringAttributeValue(PsiAnnotationMemberValue attrValue) |
static java.lang.String |
getStringAttributeValue(PsiAnnotation anno,
java.lang.String attributeName) |
static <T extends PsiModifierListOwner> |
getSuperAnnotationOwners(T element) |
static boolean |
isAnnotated(PsiModifierListOwner listOwner,
java.util.Collection<java.lang.String> annotations)
Deprecated.
|
static boolean |
isAnnotated(PsiModifierListOwner listOwner,
java.util.Collection<java.lang.String> annotations,
boolean checkHierarchy)
Deprecated.
|
static boolean |
isAnnotated(PsiModifierListOwner listOwner,
java.util.Collection<java.lang.String> annotations,
int flags) |
static boolean |
isAnnotated(PsiModifierListOwner listOwner,
java.lang.String annotationFQN,
boolean checkHierarchy)
Deprecated.
|
static boolean |
isAnnotated(PsiModifierListOwner listOwner,
java.lang.String annotationFQN,
boolean checkHierarchy,
boolean skipExternal)
Deprecated.
|
static boolean |
isAnnotated(PsiModifierListOwner listOwner,
java.lang.String annotationFqn,
int flags) |
static boolean |
isAnnotatingApplicable(PsiElement elt) |
static boolean |
isAnnotatingApplicable(PsiElement elt,
java.lang.String annotationFQN) |
static boolean |
isExternalAnnotation(PsiAnnotation annotation) |
static boolean |
isInferredAnnotation(PsiAnnotation annotation) |
static boolean |
isInsideAnnotation(PsiElement element) |
static boolean |
isJetbrainsAnnotation(java.lang.String simpleName)
Deprecated.
simple name is not enough for reliable identification
|
public static final java.lang.String NULLABLE
public static final java.lang.String NOT_NULL
public static final java.lang.String NON_NLS
public static final java.lang.String NLS
public static final java.lang.String PROPERTY_KEY
public static final java.lang.String PROPERTY_KEY_RESOURCE_BUNDLE_PARAMETER
public static final java.lang.String TEST_ONLY
public static final java.lang.String LANGUAGE
public static final int CHECK_HIERARCHY
public static final int CHECK_EXTERNAL
public static final int CHECK_INFERRED
public static final int CHECK_TYPE
public static PsiAnnotation findAnnotation(PsiModifierListOwner listOwner, java.lang.String... annotationNames)
public static PsiAnnotation findAnnotation(PsiModifierListOwner listOwner, boolean skipExternal, java.lang.String... annotationNames)
public static PsiAnnotation findAnnotation(PsiModifierListOwner listOwner, java.util.Set<java.lang.String> annotationNames)
public static PsiAnnotation findAnnotation(PsiModifierListOwner listOwner, java.util.Collection<java.lang.String> annotationNames)
public static PsiAnnotation findAnnotation(PsiModifierListOwner listOwner, java.util.Collection<java.lang.String> annotationNames, boolean skipExternal)
public static java.util.List<PsiAnnotation> findAllAnnotations(PsiModifierListOwner listOwner, java.util.Collection<java.lang.String> annotationNames, boolean skipExternal)
listOwner
having fully qualified names from annotationNames
,
including repeatable annotations and annotations from several external annotations roots.listOwner
- element to search annotations ofannotationNames
- fully-qualified annotations names to search forskipExternal
- false
if external and inferred annotations must also be searched,
true
only to search for own annotations declared in source codelistOwner
, including repeatable annotation
and annotations from several source roots, having FQ names from annotationNames
.public static PsiAnnotation [] findAnnotations(PsiModifierListOwner modifierListOwner, java.util.Collection<java.lang.String> annotationNames)
public static <T extends PsiModifierListOwner> java.util.List<T> getSuperAnnotationOwners(T element)
public static PsiAnnotation findAnnotationInHierarchy(PsiModifierListOwner listOwner, java.util.Set<java.lang.String> annotationNames)
public static PsiAnnotation findAnnotationInHierarchy(PsiModifierListOwner listOwner, java.util.Set<java.lang.String> annotationNames, boolean skipExternal)
public static PsiAnnotation findAnnotationInTypeHierarchy(PsiType type, java.util.Set<java.lang.String> qualifiedNames)
type
- type to checkqualifiedNames
- annotation qualified names of TYPE_USE annotations to look forpublic static boolean isAnnotated(PsiModifierListOwner listOwner, java.util.Collection<java.lang.String> annotations, int flags)
public static boolean isAnnotated(PsiModifierListOwner listOwner, java.lang.String annotationFqn, int flags)
public static boolean isAnnotatingApplicable(PsiElement elt)
public static boolean isAnnotatingApplicable(PsiElement elt, java.lang.String annotationFQN)
public static boolean checkAnnotatedUsingPatterns(PsiModifierListOwner owner, java.util.Collection<java.lang.String> annotations)
owner
- modifier listannotations
- annotations qualified names or patterns. Patterns can have '*' at the endtrue
if annotated of at least one annotation from the annotations listpublic static PsiMethod getAnnotationMethod(PsiNameValuePair pair)
public static PsiAnnotation [] getAllAnnotations(PsiModifierListOwner owner, boolean inHierarchy, java.util.Set<? super PsiModifierListOwner> visited)
public static PsiAnnotation [] getAllAnnotations(PsiModifierListOwner owner, boolean inHierarchy, java.util.Set<? super PsiModifierListOwner> visited, boolean withInferred)
public static boolean isInsideAnnotation(PsiElement element)
public static boolean isInferredAnnotation(PsiAnnotation annotation)
public static boolean isExternalAnnotation(PsiAnnotation annotation)
public static java.lang.String getStringAttributeValue(PsiAnnotation anno, java.lang.String attributeName)
public static java.lang.Boolean getBooleanAttributeValue(PsiAnnotation anno, java.lang.String attributeName)
public static java.lang.Long getLongAttributeValue(PsiAnnotation anno, java.lang.String attributeName)
public static java.lang.String getDeclaredStringAttributeValue(PsiAnnotation anno, java.lang.String attributeName)
public static java.lang.String getStringAttributeValue(PsiAnnotationMemberValue attrValue)
public static <T extends java.lang.annotation.Annotation> T findAnnotationInHierarchy(PsiModifierListOwner listOwner, java.lang.Class<T> annotationClass)
public static PsiNameValuePair findDeclaredAttribute(PsiAnnotation annotation, java.lang.String attributeName)
public static boolean equal(PsiAnnotation a, PsiAnnotation b)
public static boolean equal(PsiAnnotationMemberValue value1, PsiAnnotationMemberValue value2)
public static boolean equal(PsiAnnotation [] annotations1, PsiAnnotation [] annotations2)
@Deprecated public static boolean isJetbrainsAnnotation(java.lang.String simpleName)
@Deprecated public static boolean isAnnotated(PsiModifierListOwner listOwner, java.util.Collection<java.lang.String> annotations)
isAnnotated(PsiModifierListOwner, Collection, int)
@Deprecated public static boolean isAnnotated(PsiModifierListOwner listOwner, java.util.Collection<java.lang.String> annotations, boolean checkHierarchy)
isAnnotated(PsiModifierListOwner, Collection, int)
@Deprecated public static boolean isAnnotated(PsiModifierListOwner listOwner, java.lang.String annotationFQN, boolean checkHierarchy)
isAnnotated(PsiModifierListOwner, String, int)
@Deprecated public static boolean isAnnotated(PsiModifierListOwner listOwner, java.lang.String annotationFQN, boolean checkHierarchy, boolean skipExternal)
isAnnotated(PsiModifierListOwner, String, int)
public static java.util.List<PsiAnnotationMemberValue> arrayAttributeValues(PsiAnnotationMemberValue attributeValue)