mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-196862 - added meta annotations processing
GitOrigin-RevId: c9cc025971ab76606d5d670efe9a472b3c9bd067
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5575a15b95
commit
173a2a03e1
+8
-3
@@ -506,9 +506,14 @@ public abstract class EntryPointsManagerBase extends EntryPointsManager implemen
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return AnnotationUtil.checkAnnotatedUsingPatterns(owner, ADDITIONAL_ANNOTATIONS) ||
|
||||
AnnotationUtil.checkAnnotatedUsingPatterns(owner, getAdditionalAnnotations());
|
||||
boolean annotationsMatch = AnnotationUtil.checkAnnotatedUsingPatterns(owner, ADDITIONAL_ANNOTATIONS) ||
|
||||
AnnotationUtil.checkAnnotatedUsingPatterns(owner, getAdditionalAnnotations());
|
||||
if (annotationsMatch) return true;
|
||||
for (PsiAnnotation annotation : owner.getAnnotations()) {
|
||||
PsiClass annClass = annotation.resolveAnnotationType();
|
||||
if (AnnotationUtil.checkAnnotatedUsingPatterns(annClass, ADDITIONAL_ANNOTATIONS)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isAcceptedByPattern(@NotNull PsiClass element, String qualifiedName, ClassPattern pattern, Set<? super PsiClass> visited) {
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>MetaAnnotation.java</file>
|
||||
<line>50</line>
|
||||
<description>Class is not instantiated.</description>
|
||||
</problem>
|
||||
</problems>
|
||||
|
||||
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
import java.lang.annotation.*;
|
||||
|
||||
// definition
|
||||
|
||||
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface RequestMapping {
|
||||
@SuppressWarnings("unused") // suppress warning as we test another thing
|
||||
RequestMethod[] method() default {};
|
||||
}
|
||||
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@interface GetMapping {
|
||||
}
|
||||
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
@interface PostMapping {
|
||||
}
|
||||
|
||||
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface Ann1 {
|
||||
}
|
||||
|
||||
enum RequestMethod {
|
||||
GET, POST
|
||||
}
|
||||
|
||||
// test
|
||||
|
||||
class Controller {
|
||||
@GetMapping
|
||||
public int get() {
|
||||
return 111;
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public void post() {
|
||||
}
|
||||
}
|
||||
|
||||
@Ann1
|
||||
class A {
|
||||
}
|
||||
|
||||
@RequestMapping
|
||||
class B {
|
||||
}
|
||||
@@ -5,6 +5,8 @@ import com.intellij.codeInspection.ex.EntryPointsManagerBase;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class UnusedDeclarationTest extends AbstractUnusedDeclarationTest {
|
||||
|
||||
public void testSCR6067() {
|
||||
@@ -97,13 +99,13 @@ public class UnusedDeclarationTest extends AbstractUnusedDeclarationTest {
|
||||
}
|
||||
|
||||
public void testAdditionalAnnotations() {
|
||||
final String testAnnotation = "Annotated";
|
||||
EntryPointsManagerBase.getInstance(getProject()).ADDITIONAL_ANNOTATIONS.add(testAnnotation);
|
||||
final List<String> testAnnotations = List.of("Annotated", "RequestMapping");
|
||||
EntryPointsManagerBase.getInstance(getProject()).ADDITIONAL_ANNOTATIONS.addAll(testAnnotations);
|
||||
try {
|
||||
doTest();
|
||||
}
|
||||
finally {
|
||||
EntryPointsManagerBase.getInstance(getProject()).ADDITIONAL_ANNOTATIONS.remove(testAnnotation);
|
||||
EntryPointsManagerBase.getInstance(getProject()).ADDITIONAL_ANNOTATIONS.removeAll(testAnnotations);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user