Java Code Examples for com.intellij.psi.PsiAnnotation#getQualifiedName()
The following examples show how to use
com.intellij.psi.PsiAnnotation#getQualifiedName() .
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: PsiAnnotationExtractor.java From litho with Apache License 2.0 | 6 votes |
/** * We consider an annotation to be valid for extraction if it's not an internal annotation (i.e. * is in the <code>com.facebook.litho</code> package and is not a source-only annotation. * * @return Whether or not to extract the given annotation. */ private static boolean isValidAnnotation(Project project, PsiAnnotation psiAnnotation) { final String text = psiAnnotation.getQualifiedName(); if (text.startsWith("com.facebook.")) { return false; } PsiClass annotationClass = PsiSearchUtils.findClass(project, psiAnnotation.getQualifiedName()); if (annotationClass == null) { throw new RuntimeException("Annotation class not found, text is: " + text); } final Retention retention = PsiAnnotationProxyUtils.findAnnotationInHierarchy(annotationClass, Retention.class); return retention == null || retention.value() != RetentionPolicy.SOURCE; }
Example 2
Source File: SqliteMagicInspection.java From sqlitemagic with Apache License 2.0 | 6 votes |
@Override public void visitAnnotation(PsiAnnotation annotation) { super.visitAnnotation(annotation); final String qualifiedName = annotation.getQualifiedName(); if (StringUtils.isNotBlank(qualifiedName) && allProblemHandlers.containsKey(qualifiedName)) { final Collection<SqliteMagicProblem> problems = new HashSet<SqliteMagicProblem>(); for (Processor inspector : allProblemHandlers.get(qualifiedName)) { problems.addAll(inspector.verifyAnnotation(annotation)); } for (SqliteMagicProblem problem : problems) { holder.registerProblem(annotation, problem.getMessage(), problem.getHighlightType(), problem.getQuickFixes()); } } }
Example 3
Source File: DeprecatedLombokAnnotationInspection.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void checkFor(String deprecatedAnnotationFQN, String newAnnotationFQN, PsiAnnotation psiAnnotation) { final String annotationQualifiedName = psiAnnotation.getQualifiedName(); if (Objects.equals(deprecatedAnnotationFQN, annotationQualifiedName)) { final PsiModifierListOwner listOwner = PsiTreeUtil.getParentOfType(psiAnnotation, PsiModifierListOwner.class, false); if (null != listOwner) { holder.registerProblem(psiAnnotation, "Lombok annotation '" + deprecatedAnnotationFQN + "' is deprecated and " + "not supported by lombok-plugin any more. Use '" + newAnnotationFQN + "' instead.", ProblemHighlightType.ERROR, new AddAnnotationFix(newAnnotationFQN, listOwner, psiAnnotation.getParameterList().getAttributes(), deprecatedAnnotationFQN)); } } }
Example 4
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 5
Source File: Utils.java From OkHttpParamsGet with Apache License 2.0 | 5 votes |
@Nullable public static PsiAnnotation getAnnotation(@NotNull PsiAnnotation[] annotations, @NotNull String name, boolean match) { for (PsiAnnotation psiAnnotation : annotations) { String allName = psiAnnotation.getQualifiedName(); if (allName == null || allName.length() == 0) { continue; } if ((!match && allName.endsWith(name)) || (match && allName.equals(name))) { return psiAnnotation; } } return null; }
Example 6
Source File: JavaCamelIdeaUtils.java From camel-idea-plugin with Apache License 2.0 | 5 votes |
@Override public boolean isConsumerEndpoint(PsiElement element) { if (getIdeaUtils().isFromJavaMethodCall(element, true, CONSUMER_ENDPOINT)) { return true; } // annotation PsiAnnotation annotation = PsiTreeUtil.getParentOfType(element, PsiAnnotation.class); if (annotation != null && annotation.getQualifiedName() != null) { return annotation.getQualifiedName().equals("org.apache.camel.Consume"); } return false; }
Example 7
Source File: JavaCamelIdeaUtils.java From camel-idea-plugin with Apache License 2.0 | 5 votes |
@Override public boolean isProducerEndpoint(PsiElement element) { if (getIdeaUtils().isFromJavaMethodCall(element, true, PRODUCER_ENDPOINT)) { return true; } // annotation PsiAnnotation annotation = PsiTreeUtil.getParentOfType(element, PsiAnnotation.class); if (annotation != null && annotation.getQualifiedName() != null) { return annotation.getQualifiedName().equals("org.apache.camel.Produce"); } return false; }
Example 8
Source File: TestSizeFinder.java From intellij with Apache License 2.0 | 5 votes |
@Nullable private static TestSize getTestSize(PsiAnnotation[] annotations) { for (PsiAnnotation annotation : annotations) { String qualifiedName = annotation.getQualifiedName(); TestSize testSize = ANNOTATION_TO_TEST_SIZE.get(qualifiedName); if (testSize != null) { return testSize; } } return null; }
Example 9
Source File: PsiAnnotationSearchUtil.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Nullable private static String getAndCacheFQN(@NotNull PsiAnnotation annotation, @Nullable String referenceName) { String annotationQualifiedName = annotation.getCopyableUserData(LOMBOK_ANNOTATION_FQN_KEY); // if not cached or cache is not up to date (because existing annotation was renamed for example) if (null == annotationQualifiedName || (null != referenceName && !annotationQualifiedName.endsWith(".".concat(referenceName)))) { annotationQualifiedName = annotation.getQualifiedName(); if (null != annotationQualifiedName && annotationQualifiedName.indexOf('.') > -1) { annotation.putCopyableUserData(LOMBOK_ANNOTATION_FQN_KEY, annotationQualifiedName); } } return annotationQualifiedName; }
Example 10
Source File: LombokProcessorProvider.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 4 votes |
@NotNull public Collection<Processor> getProcessors(@NotNull PsiAnnotation psiAnnotation) { final String qualifiedName = psiAnnotation.getQualifiedName(); final Collection<Processor> result = qualifiedName == null ? null : lombokProcessors.get(qualifiedName); return result == null ? Collections.emptySet() : result; }