Java Code Examples for com.intellij.psi.PsiModifierListOwner#getModifierList()
The following examples show how to use
com.intellij.psi.PsiModifierListOwner#getModifierList() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnnotationDetector.java From here-be-dragons with MIT License | 7 votes |
static PsiAnnotation findAnnotation(PsiElement element, String annotationName) { if (element instanceof PsiModifierListOwner) { PsiModifierListOwner listOwner = (PsiModifierListOwner) element; PsiModifierList modifierList = listOwner.getModifierList(); if (modifierList != null) { for (PsiAnnotation psiAnnotation : modifierList.getAnnotations()) { if (annotationName.equals(psiAnnotation.getQualifiedName())) { return psiAnnotation; } } } } return null; }
Example 2
Source File: PsiConsultantImpl.java From dagger-intellij-plugin with Apache License 2.0 | 6 votes |
public static Set<String> getQualifierAnnotations(PsiElement element) { Set<String> qualifiedClasses = new HashSet<String>(); if (element instanceof PsiModifierListOwner) { PsiModifierListOwner listOwner = (PsiModifierListOwner) element; PsiModifierList modifierList = listOwner.getModifierList(); if (modifierList != null) { for (PsiAnnotation psiAnnotation : modifierList.getAnnotations()) { if (psiAnnotation != null && psiAnnotation.getQualifiedName() != null) { JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(element.getProject()); PsiClass psiClass = psiFacade.findClass(psiAnnotation.getQualifiedName(), GlobalSearchScope.projectScope(element.getProject())); if (hasAnnotation(psiClass, CLASS_QUALIFIER)) { qualifiedClasses.add(psiAnnotation.getQualifiedName()); } } } } } return qualifiedClasses; }
Example 3
Source File: PsiAnnotationSearchUtil.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static boolean isAnnotatedWith(@NotNull PsiModifierListOwner psiModifierListOwner, @NotNull final Pattern annotationPattern) { final PsiModifierList psiModifierList = psiModifierListOwner.getModifierList(); if (psiModifierList != null) { for (PsiAnnotation psiAnnotation : psiModifierList.getAnnotations()) { final String suspect = getSimpleNameOf(psiAnnotation); if (annotationPattern.matcher(suspect).matches()) { return true; } } } return false; }
Example 4
Source File: PsiAnnotationSearchUtil.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static boolean checkAnnotationsSimpleNameExistsIn(@NotNull PsiModifierListOwner modifierListOwner, @NotNull Collection<String> annotationNames) { final PsiModifierList modifierList = modifierListOwner.getModifierList(); if (null != modifierList) { for (PsiAnnotation psiAnnotation : modifierList.getAnnotations()) { final String simpleName = getSimpleNameOf(psiAnnotation); if (annotationNames.contains(simpleName)) { return true; } } } return false; }
Example 5
Source File: LombokProcessorUtil.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 5 votes |
@NotNull public static PsiAnnotation createAnnotationWithAccessLevel(@NotNull Class<? extends Annotation> annotationClass, @NotNull PsiModifierListOwner psiModifierListOwner) { String value = ""; final PsiModifierList modifierList = psiModifierListOwner.getModifierList(); if (null != modifierList) { final int accessLevelCode = PsiUtil.getAccessLevel(modifierList); final AccessLevel accessLevel = ACCESS_LEVEL_MAP.get(accessLevelCode); if (null != accessLevel && !AccessLevel.PUBLIC.equals(accessLevel)) { value = AccessLevel.class.getName() + "." + accessLevel; } } return PsiAnnotationUtil.createPsiAnnotation(psiModifierListOwner, annotationClass, value); }
Example 6
Source File: PsiConsultantImpl.java From dagger-intellij-plugin with Apache License 2.0 | 5 votes |
static PsiAnnotation findAnnotation(PsiElement element, String annotationName) { if (element instanceof PsiModifierListOwner) { PsiModifierListOwner listOwner = (PsiModifierListOwner) element; PsiModifierList modifierList = listOwner.getModifierList(); if (modifierList != null) { for (PsiAnnotation psiAnnotation : modifierList.getAnnotations()) { if (annotationName.equals(psiAnnotation.getQualifiedName())) { return psiAnnotation; } } } } return null; }