mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[jvm] IDEA-300174 Check for parameter resolver in hierarchy
GitOrigin-RevId: d72eb7768d84ee5a530a000aeacc3f76a88ef654
This commit is contained in:
committed by
intellij-monorepo-bot
parent
1c0768754b
commit
bad1488cd1
@@ -5,7 +5,6 @@ import com.intellij.lang.Language;
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
@@ -284,6 +283,24 @@ public abstract class MetaAnnotationUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Stream<PsiAnnotation> findMetaAnnotationsInHierarchy(
|
||||
@NotNull PsiModifierListOwner listOwner,
|
||||
@NotNull Collection<String> annotations
|
||||
) {
|
||||
Stream<PsiAnnotation> stream = findMetaAnnotations(listOwner, annotations);
|
||||
if (listOwner instanceof PsiClass) {
|
||||
for (PsiClass superClass : ((PsiClass)listOwner).getSupers()) {
|
||||
stream = Stream.concat(stream, findMetaAnnotations(superClass, annotations));
|
||||
}
|
||||
}
|
||||
else if (listOwner instanceof PsiMethod) {
|
||||
for (PsiMethod method : ((PsiMethod)listOwner).findSuperMethods()) {
|
||||
stream = Stream.concat(stream, findMetaAnnotations(method, annotations));
|
||||
}
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static PsiAnnotation metaAnnotationCached(PsiClass subjectAnnotation, String annotationToFind) {
|
||||
return CachedValuesManager.getCachedValue(subjectAnnotation, () -> {
|
||||
|
||||
+1
-2
@@ -37,7 +37,6 @@ import org.jetbrains.uast.*
|
||||
import org.jetbrains.uast.visitor.AbstractUastNonRecursiveVisitor
|
||||
import javax.swing.JComponent
|
||||
import kotlin.streams.asSequence
|
||||
import kotlin.streams.toList
|
||||
|
||||
class JUnitMalformedDeclarationInspection : AbstractBaseUastLocalInspectionTool() {
|
||||
@JvmField
|
||||
@@ -204,7 +203,7 @@ private class JUnitMalformedSignatureVisitor(
|
||||
val sourcePsi = this.sourcePsi ?: return false
|
||||
val alternatives = UastFacade.convertToAlternatives(sourcePsi, arrayOf(UMethod::class.java))
|
||||
val extension = alternatives.mapNotNull { it.javaPsi.containingClass }.flatMap {
|
||||
MetaAnnotationUtil.findMetaAnnotations(it, listOf(ORG_JUNIT_JUPITER_API_EXTENSION_EXTEND_WITH)).asSequence()
|
||||
MetaAnnotationUtil.findMetaAnnotationsInHierarchy(it, listOf(ORG_JUNIT_JUPITER_API_EXTENSION_EXTEND_WITH)).asSequence()
|
||||
}.firstOrNull()?.findAttributeValue("value")?.toUElement() ?: return false
|
||||
if (extension is UClassLiteralExpression) return InheritanceUtil.isInheritor(extension.type,
|
||||
ORG_JUNIT_JUPITER_API_EXTENSION_PARAMETER_RESOLVER)
|
||||
|
||||
+10
-2
@@ -663,7 +663,15 @@ class KotlinJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationI
|
||||
@org.junit.jupiter.api.BeforeAll
|
||||
fun beforeAll(foo: String) { println(foo) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@org.junit.jupiter.api.extension.ExtendWith(TestParameterResolver::class)
|
||||
open class AbstractTest { }
|
||||
|
||||
class TestImplementation: AbstractTest() {
|
||||
@org.junit.jupiter.api.BeforeEach
|
||||
fun beforeEach(valueBox : String){ }
|
||||
}
|
||||
|
||||
@org.junit.jupiter.api.extension.ExtendWith(TestParameterResolver::class)
|
||||
annotation class CustomTestAnnotation
|
||||
@@ -675,7 +683,7 @@ class KotlinJUnitMalformedDeclarationInspectionTest : JUnitMalformedDeclarationI
|
||||
@org.junit.jupiter.api.BeforeAll
|
||||
fun beforeAll(foo: String) { println(foo) }
|
||||
}
|
||||
}
|
||||
}
|
||||
""".trimIndent())
|
||||
}
|
||||
fun `test malformed before class method that is non-static`() {
|
||||
|
||||
Reference in New Issue
Block a user