[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.
|
* 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
|
package org.jetbrains.kotlin.asJava.classes
|
||||||
|
|
||||||
import com.intellij.lang.Language
|
import com.intellij.lang.Language
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.*
|
||||||
import com.intellij.psi.PsiJavaCodeReferenceElement
|
|
||||||
import com.intellij.psi.PsiManager
|
|
||||||
import com.intellij.psi.PsiReferenceList
|
|
||||||
import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap
|
import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap
|
||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
import org.jetbrains.kotlin.psi.KtSuperTypeList
|
import org.jetbrains.kotlin.psi.KtSuperTypeList
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext
|
import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext
|
||||||
|
|
||||||
class KotlinSuperTypeListBuilder(kotlinOrigin: KtSuperTypeList?, manager: PsiManager, language: Language, role: PsiReferenceList.Role) :
|
class KotlinSuperTypeListBuilder(
|
||||||
KotlinLightReferenceListBuilder(
|
private val parent: PsiClass,
|
||||||
manager,
|
kotlinOrigin: KtSuperTypeList?,
|
||||||
language,
|
manager: PsiManager,
|
||||||
role
|
language: Language,
|
||||||
) {
|
role: PsiReferenceList.Role,
|
||||||
|
) : KotlinLightReferenceListBuilder(
|
||||||
|
manager,
|
||||||
|
language,
|
||||||
|
role,
|
||||||
|
) {
|
||||||
|
override fun getParent(): PsiElement = parent
|
||||||
|
|
||||||
private val myKotlinOrigin: KtSuperTypeList? = kotlinOrigin
|
private val myKotlinOrigin: KtSuperTypeList? = kotlinOrigin
|
||||||
|
|
||||||
|
|||||||
+1
@@ -81,6 +81,7 @@ internal class SymbolLightClassForEnumEntry(
|
|||||||
} ?: return@lazyPub null
|
} ?: return@lazyPub null
|
||||||
|
|
||||||
KotlinSuperTypeListBuilder(
|
KotlinSuperTypeListBuilder(
|
||||||
|
this,
|
||||||
kotlinOrigin = enumClass.kotlinOrigin?.getSuperTypeList(),
|
kotlinOrigin = enumClass.kotlinOrigin?.getSuperTypeList(),
|
||||||
manager = manager,
|
manager = manager,
|
||||||
language = language,
|
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 role = if (forExtendsList) PsiReferenceList.Role.EXTENDS_LIST else PsiReferenceList.Role.IMPLEMENTS_LIST
|
||||||
|
|
||||||
val listBuilder = KotlinSuperTypeListBuilder(
|
val listBuilder = KotlinSuperTypeListBuilder(
|
||||||
|
this,
|
||||||
kotlinOrigin = kotlinOrigin?.getSuperTypeList(),
|
kotlinOrigin = kotlinOrigin?.getSuperTypeList(),
|
||||||
manager = manager,
|
manager = manager,
|
||||||
language = language,
|
language = language,
|
||||||
|
|||||||
+1
@@ -80,6 +80,7 @@ internal class SymbolLightTypeParameter private constructor(
|
|||||||
|
|
||||||
private val _extendsList: PsiReferenceList by lazyPub {
|
private val _extendsList: PsiReferenceList by lazyPub {
|
||||||
val listBuilder = KotlinSuperTypeListBuilder(
|
val listBuilder = KotlinSuperTypeListBuilder(
|
||||||
|
this,
|
||||||
kotlinOrigin = null,
|
kotlinOrigin = null,
|
||||||
manager = manager,
|
manager = manager,
|
||||||
language = language,
|
language = language,
|
||||||
|
|||||||
+17
-13
@@ -46,11 +46,10 @@ open class AbstractSymbolLightClassesParentingTestBase(
|
|||||||
private val declarationStack = ArrayDeque<PsiElement>()
|
private val declarationStack = ArrayDeque<PsiElement>()
|
||||||
|
|
||||||
private fun <T : PsiElement> checkParentAndVisitChildren(
|
private fun <T : PsiElement> checkParentAndVisitChildren(
|
||||||
declaration: T?,
|
declaration: T,
|
||||||
notCheckItself: Boolean = false,
|
notCheckItself: Boolean = false,
|
||||||
action: T.(visitor: JavaElementVisitor) -> Unit = {},
|
action: T.(visitor: JavaElementVisitor) -> Unit = {},
|
||||||
) {
|
) {
|
||||||
if (declaration == null) return
|
|
||||||
if (!notCheckItself) {
|
if (!notCheckItself) {
|
||||||
checkDeclarationParent(declaration)
|
checkDeclarationParent(declaration)
|
||||||
}
|
}
|
||||||
@@ -76,35 +75,42 @@ open class AbstractSymbolLightClassesParentingTestBase(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitModifierList(list: PsiModifierList?) {
|
override fun visitModifierList(list: PsiModifierList) {
|
||||||
checkParentAndVisitChildren(list, notCheckItself = ignoreDecompiledClasses) { visitor ->
|
checkParentAndVisitChildren(list, notCheckItself = ignoreDecompiledClasses) { visitor ->
|
||||||
annotations.forEach { it.accept(visitor) }
|
annotations.forEach { it.accept(visitor) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitParameterList(list: PsiParameterList?) {
|
override fun visitParameterList(list: PsiParameterList) {
|
||||||
checkParentAndVisitChildren(list, notCheckItself = ignoreDecompiledClasses) { visitor ->
|
checkParentAndVisitChildren(list, notCheckItself = ignoreDecompiledClasses) { visitor ->
|
||||||
parameters.forEach { it.accept(visitor) }
|
parameters.forEach { it.accept(visitor) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitTypeParameterList(list: PsiTypeParameterList?) {
|
override fun visitTypeParameterList(list: PsiTypeParameterList) {
|
||||||
checkParentAndVisitChildren(list, notCheckItself = ignoreDecompiledClasses) { visitor ->
|
checkParentAndVisitChildren(list, notCheckItself = ignoreDecompiledClasses) { visitor ->
|
||||||
typeParameters.forEach { it.accept(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 ->
|
checkParentAndVisitChildren(aClass) { visitor ->
|
||||||
annotations.forEach { it.accept(visitor) }
|
annotations.forEach { it.accept(visitor) }
|
||||||
|
|
||||||
fields.forEach { it.accept(visitor) }
|
fields.forEach { it.accept(visitor) }
|
||||||
methods.forEach { it.accept(visitor) }
|
methods.forEach { it.accept(visitor) }
|
||||||
innerClasses.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 ->
|
checkParentAndVisitChildren(field) { visitor ->
|
||||||
annotations.forEach { it.accept(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
|
if (method is SyntheticElement) return
|
||||||
|
|
||||||
checkParentAndVisitChildren(method) { visitor ->
|
checkParentAndVisitChildren(method) { visitor ->
|
||||||
@@ -122,13 +128,13 @@ open class AbstractSymbolLightClassesParentingTestBase(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitParameter(parameter: PsiParameter?) {
|
override fun visitParameter(parameter: PsiParameter) {
|
||||||
checkParentAndVisitChildren(parameter) { visitor ->
|
checkParentAndVisitChildren(parameter) { visitor ->
|
||||||
annotations.forEach { it.accept(visitor) }
|
annotations.forEach { it.accept(visitor) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitTypeParameter(classParameter: PsiTypeParameter?) {
|
override fun visitTypeParameter(classParameter: PsiTypeParameter) {
|
||||||
checkParentAndVisitChildren(classParameter) { visitor ->
|
checkParentAndVisitChildren(classParameter) { visitor ->
|
||||||
annotations.forEach { it.accept(visitor) }
|
annotations.forEach { it.accept(visitor) }
|
||||||
}
|
}
|
||||||
@@ -143,9 +149,7 @@ open class AbstractSymbolLightClassesParentingTestBase(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitAnnotation(annotation: PsiAnnotation?) {
|
override fun visitAnnotation(annotation: PsiAnnotation) {
|
||||||
if (annotation == null) return
|
|
||||||
|
|
||||||
val owner = annotation.owner
|
val owner = annotation.owner
|
||||||
assertions.assertNotNull(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.
|
* 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(
|
val listBuilder = KotlinSuperTypeListBuilder(
|
||||||
|
this,
|
||||||
kotlinOrigin = kotlinOrigin.getSuperTypeList(),
|
kotlinOrigin = kotlinOrigin.getSuperTypeList(),
|
||||||
manager = manager,
|
manager = manager,
|
||||||
language = language,
|
language = language,
|
||||||
|
|||||||
Reference in New Issue
Block a user