[LC] add missing parent to implementsList and extendsList
^KT-56613
This commit is contained in:
committed by
Space Team
parent
58dc93da90
commit
9129235079
+14
-11
@@ -1,26 +1,29 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.asJava.classes
|
||||
|
||||
import com.intellij.lang.Language
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiJavaCodeReferenceElement
|
||||
import com.intellij.psi.PsiManager
|
||||
import com.intellij.psi.PsiReferenceList
|
||||
import com.intellij.psi.*
|
||||
import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.psi.KtSuperTypeList
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext
|
||||
|
||||
class KotlinSuperTypeListBuilder(kotlinOrigin: KtSuperTypeList?, manager: PsiManager, language: Language, role: PsiReferenceList.Role) :
|
||||
KotlinLightReferenceListBuilder(
|
||||
manager,
|
||||
language,
|
||||
role
|
||||
) {
|
||||
class KotlinSuperTypeListBuilder(
|
||||
private val parent: PsiClass,
|
||||
kotlinOrigin: KtSuperTypeList?,
|
||||
manager: PsiManager,
|
||||
language: Language,
|
||||
role: PsiReferenceList.Role,
|
||||
) : KotlinLightReferenceListBuilder(
|
||||
manager,
|
||||
language,
|
||||
role,
|
||||
) {
|
||||
override fun getParent(): PsiElement = parent
|
||||
|
||||
private val myKotlinOrigin: KtSuperTypeList? = kotlinOrigin
|
||||
|
||||
|
||||
+1
@@ -81,6 +81,7 @@ internal class SymbolLightClassForEnumEntry(
|
||||
} ?: return@lazyPub null
|
||||
|
||||
KotlinSuperTypeListBuilder(
|
||||
this,
|
||||
kotlinOrigin = enumClass.kotlinOrigin?.getSuperTypeList(),
|
||||
manager = manager,
|
||||
language = language,
|
||||
|
||||
+1
@@ -431,6 +431,7 @@ internal fun SymbolLightClassForClassLike<*>.createInheritanceList(
|
||||
val role = if (forExtendsList) PsiReferenceList.Role.EXTENDS_LIST else PsiReferenceList.Role.IMPLEMENTS_LIST
|
||||
|
||||
val listBuilder = KotlinSuperTypeListBuilder(
|
||||
this,
|
||||
kotlinOrigin = kotlinOrigin?.getSuperTypeList(),
|
||||
manager = manager,
|
||||
language = language,
|
||||
|
||||
+1
@@ -80,6 +80,7 @@ internal class SymbolLightTypeParameter private constructor(
|
||||
|
||||
private val _extendsList: PsiReferenceList by lazyPub {
|
||||
val listBuilder = KotlinSuperTypeListBuilder(
|
||||
this,
|
||||
kotlinOrigin = null,
|
||||
manager = manager,
|
||||
language = language,
|
||||
|
||||
+17
-13
@@ -46,11 +46,10 @@ open class AbstractSymbolLightClassesParentingTestBase(
|
||||
private val declarationStack = ArrayDeque<PsiElement>()
|
||||
|
||||
private fun <T : PsiElement> checkParentAndVisitChildren(
|
||||
declaration: T?,
|
||||
declaration: T,
|
||||
notCheckItself: Boolean = false,
|
||||
action: T.(visitor: JavaElementVisitor) -> Unit = {},
|
||||
) {
|
||||
if (declaration == null) return
|
||||
if (!notCheckItself) {
|
||||
checkDeclarationParent(declaration)
|
||||
}
|
||||
@@ -76,35 +75,42 @@ open class AbstractSymbolLightClassesParentingTestBase(
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitModifierList(list: PsiModifierList?) {
|
||||
override fun visitModifierList(list: PsiModifierList) {
|
||||
checkParentAndVisitChildren(list, notCheckItself = ignoreDecompiledClasses) { visitor ->
|
||||
annotations.forEach { it.accept(visitor) }
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitParameterList(list: PsiParameterList?) {
|
||||
override fun visitParameterList(list: PsiParameterList) {
|
||||
checkParentAndVisitChildren(list, notCheckItself = ignoreDecompiledClasses) { visitor ->
|
||||
parameters.forEach { it.accept(visitor) }
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitTypeParameterList(list: PsiTypeParameterList?) {
|
||||
override fun visitTypeParameterList(list: PsiTypeParameterList) {
|
||||
checkParentAndVisitChildren(list, notCheckItself = ignoreDecompiledClasses) { visitor ->
|
||||
typeParameters.forEach { it.accept(visitor) }
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitClass(aClass: PsiClass?) {
|
||||
override fun visitReferenceList(list: PsiReferenceList) {
|
||||
checkParentAndVisitChildren(list, notCheckItself = ignoreDecompiledClasses)
|
||||
}
|
||||
|
||||
override fun visitClass(aClass: PsiClass) {
|
||||
checkParentAndVisitChildren(aClass) { visitor ->
|
||||
annotations.forEach { it.accept(visitor) }
|
||||
|
||||
fields.forEach { it.accept(visitor) }
|
||||
methods.forEach { it.accept(visitor) }
|
||||
innerClasses.forEach { it.accept(visitor) }
|
||||
|
||||
implementsList?.accept(visitor)
|
||||
extendsList?.accept(visitor)
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitField(field: PsiField?) {
|
||||
override fun visitField(field: PsiField) {
|
||||
checkParentAndVisitChildren(field) { visitor ->
|
||||
annotations.forEach { it.accept(visitor) }
|
||||
|
||||
@@ -112,7 +118,7 @@ open class AbstractSymbolLightClassesParentingTestBase(
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitMethod(method: PsiMethod?) {
|
||||
override fun visitMethod(method: PsiMethod) {
|
||||
if (method is SyntheticElement) return
|
||||
|
||||
checkParentAndVisitChildren(method) { visitor ->
|
||||
@@ -122,13 +128,13 @@ open class AbstractSymbolLightClassesParentingTestBase(
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitParameter(parameter: PsiParameter?) {
|
||||
override fun visitParameter(parameter: PsiParameter) {
|
||||
checkParentAndVisitChildren(parameter) { visitor ->
|
||||
annotations.forEach { it.accept(visitor) }
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitTypeParameter(classParameter: PsiTypeParameter?) {
|
||||
override fun visitTypeParameter(classParameter: PsiTypeParameter) {
|
||||
checkParentAndVisitChildren(classParameter) { visitor ->
|
||||
annotations.forEach { it.accept(visitor) }
|
||||
}
|
||||
@@ -143,9 +149,7 @@ open class AbstractSymbolLightClassesParentingTestBase(
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitAnnotation(annotation: PsiAnnotation?) {
|
||||
if (annotation == null) return
|
||||
|
||||
override fun visitAnnotation(annotation: PsiAnnotation) {
|
||||
val owner = annotation.owner
|
||||
assertions.assertNotNull(owner)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -116,6 +116,7 @@ open class KtUltraLightClass(classOrObject: KtClassOrObject, internal val suppor
|
||||
}
|
||||
|
||||
val listBuilder = KotlinSuperTypeListBuilder(
|
||||
this,
|
||||
kotlinOrigin = kotlinOrigin.getSuperTypeList(),
|
||||
manager = manager,
|
||||
language = language,
|
||||
|
||||
Reference in New Issue
Block a user