mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
[kotlin] don't decompile java to check inheritance
^KTIJ-31361 fixed GitOrigin-RevId: 7fb0abe46944a2b147a6ba77c2d5ac03b9e09e7c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
972996f72e
commit
77de0ee50e
@@ -11,6 +11,7 @@ import com.intellij.psi.PsiClass
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiJavaFile
|
||||
import com.intellij.psi.impl.compiled.ClsFileImpl
|
||||
import com.intellij.psi.impl.compiled.ClsJavaCodeReferenceElementImpl
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.psi.search.PsiShortNamesCache
|
||||
import com.intellij.psi.util.CachedValueProvider
|
||||
@@ -159,16 +160,21 @@ class KotlinJUnit3Framework: JUnit3Framework(), KotlinPsiBasedTestFramework {
|
||||
// circular dependency detected
|
||||
val superShortName = superClass.name
|
||||
if (superShortName == null || !visitedShortNames.add(superShortName)) return NO
|
||||
if (checkNameMatch(psiJavaFile, TEST_CLASS_FQN, superShortName)) {
|
||||
if (checkNameMatch(psiJavaFile, psiClass, TEST_CLASS_FQN, superShortName)) {
|
||||
return YES
|
||||
}
|
||||
|
||||
return checkJUnit3TestClass(superClass, shortNamesCache, resolveScope, visitedShortNames)
|
||||
}
|
||||
|
||||
private fun checkNameMatch(file: PsiJavaFile, fqNames: Set<String>, shortName: String): Boolean {
|
||||
private fun checkNameMatch(file: PsiJavaFile, psiClass: PsiClass, fqNames: Set<String>, shortName: String): Boolean {
|
||||
if (shortName in fqNames || "${file.packageName}.$shortName" in fqNames) return true
|
||||
val importStatements = (file.importList ?: ((file as? ClsFileImpl)?.decompiledPsiFile as? PsiJavaFile)?.importList)?.importStatements ?: return false
|
||||
if (file is ClsFileImpl) {
|
||||
val referenceElements = psiClass.extendsList?.referenceElements?.takeIf { it.size > 0 } ?: return false
|
||||
val referenceElement = referenceElements[0] as? ClsJavaCodeReferenceElementImpl ?: return false
|
||||
return referenceElement.qualifiedName in fqNames
|
||||
}
|
||||
val importStatements = file.importList?.importStatements ?: return false
|
||||
for (importStatement in importStatements) {
|
||||
val importedFqName = importStatement.qualifiedName ?: continue
|
||||
if (importedFqName.endsWith(".$shortName") && importedFqName in fqNames) {
|
||||
|
||||
Reference in New Issue
Block a user