[SLC] cleanup code
^KT-54051
This commit is contained in:
committed by
Space Team
parent
207212e5b8
commit
1b185bc263
+6
-2
@@ -70,6 +70,10 @@ internal class SymbolLightAnnotationClass : SymbolLightInterfaceOrAnnotationClas
|
|||||||
|
|
||||||
override fun getExtendsList(): PsiReferenceList? = null
|
override fun getExtendsList(): PsiReferenceList? = null
|
||||||
|
|
||||||
override fun copy(): SymbolLightAnnotationClass =
|
override fun copy(): SymbolLightAnnotationClass = SymbolLightAnnotationClass(
|
||||||
SymbolLightAnnotationClass(classOrObjectDeclaration, classOrObjectSymbolPointer, ktModule, manager)
|
classOrObjectDeclaration = classOrObjectDeclaration,
|
||||||
|
classOrObjectSymbolPointer = classOrObjectSymbolPointer,
|
||||||
|
ktModule = ktModule,
|
||||||
|
manager = manager,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -51,7 +51,7 @@ internal open class SymbolLightClass : SymbolLightClassForNamedClassOrObject {
|
|||||||
ktAnalysisSession: KtAnalysisSession,
|
ktAnalysisSession: KtAnalysisSession,
|
||||||
ktModule: KtModule,
|
ktModule: KtModule,
|
||||||
classOrObjectSymbol: KtNamedClassOrObjectSymbol,
|
classOrObjectSymbol: KtNamedClassOrObjectSymbol,
|
||||||
manager: PsiManager
|
manager: PsiManager,
|
||||||
) : super(
|
) : super(
|
||||||
ktAnalysisSession = ktAnalysisSession,
|
ktAnalysisSession = ktAnalysisSession,
|
||||||
ktModule = ktModule,
|
ktModule = ktModule,
|
||||||
@@ -137,8 +137,7 @@ internal open class SymbolLightClass : SymbolLightClassForNamedClassOrObject {
|
|||||||
|
|
||||||
val visibleDeclarations = declaredMemberScope.getCallableSymbols().applyIf(isEnum) {
|
val visibleDeclarations = declaredMemberScope.getCallableSymbols().applyIf(isEnum) {
|
||||||
filterNot { function ->
|
filterNot { function ->
|
||||||
function is KtFunctionSymbol &&
|
function is KtFunctionSymbol && (function.name == ENUM_VALUES || function.name == ENUM_VALUE_OF)
|
||||||
(function.name == ENUM_VALUES || function.name == ENUM_VALUE_OF)
|
|
||||||
}
|
}
|
||||||
}.applyIf(isObject) {
|
}.applyIf(isObject) {
|
||||||
filterNot {
|
filterNot {
|
||||||
@@ -239,7 +238,7 @@ internal open class SymbolLightClass : SymbolLightClassForNamedClassOrObject {
|
|||||||
METHOD_INDEX_FOR_NON_ORIGIN_METHOD,
|
METHOD_INDEX_FOR_NON_ORIGIN_METHOD,
|
||||||
false,
|
false,
|
||||||
argumentsSkipMask = null,
|
argumentsSkipMask = null,
|
||||||
suppressStatic = false
|
suppressStatic = false,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -282,6 +281,7 @@ internal open class SymbolLightClass : SymbolLightClassForNamedClassOrObject {
|
|||||||
// Probably, the same should work for const vals but it doesn't at the moment (see KT-28294)
|
// Probably, the same should work for const vals but it doesn't at the moment (see KT-28294)
|
||||||
filter { containingClass?.isInterface == true && !it.hasJvmFieldAnnotation() }
|
filter { containingClass?.isInterface == true && !it.hasJvmFieldAnnotation() }
|
||||||
}
|
}
|
||||||
|
|
||||||
val propertyGroups = propertySymbols.groupBy { it.isFromPrimaryConstructor }
|
val propertyGroups = propertySymbols.groupBy { it.isFromPrimaryConstructor }
|
||||||
|
|
||||||
val nameGenerator = SymbolLightField.FieldNameGenerator()
|
val nameGenerator = SymbolLightField.FieldNameGenerator()
|
||||||
@@ -337,7 +337,7 @@ internal open class SymbolLightClass : SymbolLightClassForNamedClassOrObject {
|
|||||||
SymbolLightFieldForEnumEntry(
|
SymbolLightFieldForEnumEntry(
|
||||||
enumEntry = enumEntry,
|
enumEntry = enumEntry,
|
||||||
enumEntryName = name,
|
enumEntryName = name,
|
||||||
containingClass = this@SymbolLightClass,
|
containingClass = this,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-24
@@ -51,7 +51,7 @@ abstract class SymbolLightClassBase protected constructor(val ktModule: KtModule
|
|||||||
private val myInnersCache = KotlinClassInnerStuffCache(
|
private val myInnersCache = KotlinClassInnerStuffCache(
|
||||||
myClass = this@SymbolLightClassBase,
|
myClass = this@SymbolLightClassBase,
|
||||||
dependencies = listOf(manager.project.createProjectWideOutOfBlockModificationTracker()),
|
dependencies = listOf(manager.project.createProjectWideOutOfBlockModificationTracker()),
|
||||||
lazyCreator = SymbolLightClassesLazyCreator(project)
|
lazyCreator = SymbolLightClassesLazyCreator(project),
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun getFields(): Array<PsiField> = myInnersCache.fields
|
override fun getFields(): Array<PsiField> = myInnersCache.fields
|
||||||
@@ -68,29 +68,24 @@ abstract class SymbolLightClassBase protected constructor(val ktModule: KtModule
|
|||||||
|
|
||||||
override fun getAllInnerClasses(): Array<PsiClass> = PsiClassImplUtil.getAllInnerClasses(this)
|
override fun getAllInnerClasses(): Array<PsiClass> = PsiClassImplUtil.getAllInnerClasses(this)
|
||||||
|
|
||||||
override fun findFieldByName(name: String, checkBases: Boolean) =
|
override fun findFieldByName(name: String, checkBases: Boolean) = myInnersCache.findFieldByName(name, checkBases)
|
||||||
myInnersCache.findFieldByName(name, checkBases)
|
|
||||||
|
|
||||||
override fun findMethodsByName(name: String, checkBases: Boolean): Array<PsiMethod> =
|
override fun findMethodsByName(name: String, checkBases: Boolean): Array<PsiMethod> = myInnersCache.findMethodsByName(name, checkBases)
|
||||||
myInnersCache.findMethodsByName(name, checkBases)
|
|
||||||
|
|
||||||
override fun findInnerClassByName(name: String, checkBases: Boolean): PsiClass? =
|
override fun findInnerClassByName(name: String, checkBases: Boolean): PsiClass? = myInnersCache.findInnerClassByName(name, checkBases)
|
||||||
myInnersCache.findInnerClassByName(name, checkBases)
|
|
||||||
|
|
||||||
override fun processDeclarations(
|
override fun processDeclarations(
|
||||||
processor: PsiScopeProcessor, state: ResolveState, lastParent: PsiElement?, place: PsiElement
|
processor: PsiScopeProcessor, state: ResolveState, lastParent: PsiElement?, place: PsiElement
|
||||||
): Boolean {
|
): Boolean = PsiClassImplUtil.processDeclarationsInClass(
|
||||||
return PsiClassImplUtil.processDeclarationsInClass(
|
/* aClass = */ this,
|
||||||
this,
|
/* processor = */ processor,
|
||||||
processor,
|
/* state = */ state,
|
||||||
state,
|
/* visited = */ null,
|
||||||
null,
|
/* last = */ lastParent,
|
||||||
lastParent,
|
/* place = */ place,
|
||||||
place,
|
/* languageLevel = */ PsiUtil.getLanguageLevel(place),
|
||||||
PsiUtil.getLanguageLevel(place),
|
/* isRaw = */ false,
|
||||||
false
|
)
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun isInheritor(baseClass: PsiClass, checkDeep: Boolean): Boolean {
|
override fun isInheritor(baseClass: PsiClass, checkDeep: Boolean): Boolean {
|
||||||
if (manager.areElementsEquivalent(baseClass, this)) return false
|
if (manager.areElementsEquivalent(baseClass, this)) return false
|
||||||
@@ -161,9 +156,8 @@ abstract class SymbolLightClassBase protected constructor(val ktModule: KtModule
|
|||||||
|
|
||||||
override fun findMethodsAndTheirSubstitutorsByName(
|
override fun findMethodsAndTheirSubstitutorsByName(
|
||||||
@NonNls name: String?,
|
@NonNls name: String?,
|
||||||
checkBases: Boolean
|
checkBases: Boolean,
|
||||||
): List<Pair<PsiMethod?, PsiSubstitutor?>?> =
|
): List<Pair<PsiMethod?, PsiSubstitutor?>?> = PsiClassImplUtil.findMethodsAndTheirSubstitutorsByName(this, name, checkBases)
|
||||||
PsiClassImplUtil.findMethodsAndTheirSubstitutorsByName(this, name, checkBases)
|
|
||||||
|
|
||||||
override fun getAllMethodsAndTheirSubstitutors(): List<Pair<PsiMethod?, PsiSubstitutor?>?> {
|
override fun getAllMethodsAndTheirSubstitutors(): List<Pair<PsiMethod?, PsiSubstitutor?>?> {
|
||||||
return PsiClassImplUtil.getAllWithSubstitutorsByMap(this, PsiClassImplUtil.MemberType.METHOD)
|
return PsiClassImplUtil.getAllWithSubstitutorsByMap(this, PsiClassImplUtil.MemberType.METHOD)
|
||||||
@@ -175,8 +169,7 @@ abstract class SymbolLightClassBase protected constructor(val ktModule: KtModule
|
|||||||
|
|
||||||
override fun getInitializers(): Array<PsiClassInitializer> = PsiClassInitializer.EMPTY_ARRAY
|
override fun getInitializers(): Array<PsiClassInitializer> = PsiClassInitializer.EMPTY_ARRAY
|
||||||
|
|
||||||
override fun getElementIcon(flags: Int): Icon? =
|
override fun getElementIcon(flags: Int): Icon? = throw UnsupportedOperationException("This should be done by KotlinIconProvider")
|
||||||
throw UnsupportedOperationException("This should be done by KotlinIconProvider")
|
|
||||||
|
|
||||||
override fun getVisibleSignatures(): MutableCollection<HierarchicalMethodSignature> = PsiSuperMethodImplUtil.getVisibleSignatures(this)
|
override fun getVisibleSignatures(): MutableCollection<HierarchicalMethodSignature> = PsiSuperMethodImplUtil.getVisibleSignatures(this)
|
||||||
|
|
||||||
|
|||||||
+5
-4
@@ -6,8 +6,6 @@
|
|||||||
package org.jetbrains.kotlin.light.classes.symbol.classes
|
package org.jetbrains.kotlin.light.classes.symbol.classes
|
||||||
|
|
||||||
import com.intellij.psi.*
|
import com.intellij.psi.*
|
||||||
import org.jetbrains.kotlin.analysis.api.symbols.KtNamedClassOrObjectSymbol
|
|
||||||
import org.jetbrains.kotlin.analysis.api.symbols.pointers.symbolPointer
|
|
||||||
import org.jetbrains.kotlin.analysis.api.types.KtTypeMappingMode
|
import org.jetbrains.kotlin.analysis.api.types.KtTypeMappingMode
|
||||||
import org.jetbrains.kotlin.analysis.project.structure.KtModule
|
import org.jetbrains.kotlin.analysis.project.structure.KtModule
|
||||||
import org.jetbrains.kotlin.asJava.classes.KotlinSuperTypeListBuilder
|
import org.jetbrains.kotlin.asJava.classes.KotlinSuperTypeListBuilder
|
||||||
@@ -24,9 +22,7 @@ internal class SymbolLightClassForEnumEntry(
|
|||||||
ktModule: KtModule,
|
ktModule: KtModule,
|
||||||
) : SymbolLightClass(
|
) : SymbolLightClass(
|
||||||
enumConstant.kotlinOrigin,
|
enumConstant.kotlinOrigin,
|
||||||
symbolPointer<KtNamedClassOrObjectSymbol> { null },
|
|
||||||
ktModule,
|
ktModule,
|
||||||
enumClass.manager,
|
|
||||||
), PsiEnumConstantInitializer {
|
), PsiEnumConstantInitializer {
|
||||||
override fun getBaseClassType(): PsiClassType = enumConstant.type as PsiClassType //???TODO
|
override fun getBaseClassType(): PsiClassType = enumConstant.type as PsiClassType //???TODO
|
||||||
|
|
||||||
@@ -41,6 +37,11 @@ internal class SymbolLightClassForEnumEntry(
|
|||||||
|
|
||||||
override fun copy() = SymbolLightClassForEnumEntry(enumConstant, enumClass, ktModule)
|
override fun copy() = SymbolLightClassForEnumEntry(enumConstant, enumClass, ktModule)
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean = this === other ||
|
||||||
|
other is SymbolLightClassForEnumEntry && other.enumConstant == enumConstant
|
||||||
|
|
||||||
|
override fun hashCode(): Int = enumConstant.hashCode()
|
||||||
|
|
||||||
override fun toString(): String = "SymbolLightClassForEnumEntry:$name"
|
override fun toString(): String = "SymbolLightClassForEnumEntry:$name"
|
||||||
|
|
||||||
private val _modifierList: PsiModifierList by lazy {
|
private val _modifierList: PsiModifierList by lazy {
|
||||||
|
|||||||
+2
-4
@@ -69,11 +69,9 @@ abstract class SymbolLightClassForNamedClassOrObject : SymbolLightClassForClassO
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val KtPropertySymbol.isConstOrJvmField: Boolean
|
private val KtPropertySymbol.isConstOrJvmField: Boolean get() = isConst || hasJvmFieldAnnotation()
|
||||||
get() = isConst || hasJvmFieldAnnotation()
|
|
||||||
|
|
||||||
private val KtPropertySymbol.isConst: Boolean
|
private val KtPropertySymbol.isConst: Boolean get() = (this as? KtKotlinPropertySymbol)?.isConst == true
|
||||||
get() = (this as? KtKotlinPropertySymbol)?.isConst == true
|
|
||||||
|
|
||||||
context(ktAnalysisSession@KtAnalysisSession)
|
context(ktAnalysisSession@KtAnalysisSession)
|
||||||
protected fun addFieldsFromCompanionIfNeeded(
|
protected fun addFieldsFromCompanionIfNeeded(
|
||||||
|
|||||||
+2
-4
@@ -169,15 +169,13 @@ internal class SymbolLightFieldForProperty private constructor(
|
|||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
if (this === other) return true
|
if (this === other) return true
|
||||||
if (other !is SymbolLightFieldForProperty) return false
|
if (other !is SymbolLightFieldForProperty || other.ktModule != ktModule || other.fieldName != fieldName) return false
|
||||||
if (kotlinOrigin != null) {
|
if (kotlinOrigin != null) {
|
||||||
return kotlinOrigin == other.kotlinOrigin && ktModule == other.ktModule
|
return kotlinOrigin == other.kotlinOrigin
|
||||||
}
|
}
|
||||||
|
|
||||||
return other.kotlinOrigin == null &&
|
return other.kotlinOrigin == null &&
|
||||||
fieldName == other.fieldName &&
|
|
||||||
containingClass == other.containingClass &&
|
containingClass == other.containingClass &&
|
||||||
ktModule == other.ktModule &&
|
|
||||||
compareSymbolPointers(ktModule, propertySymbolPointer, other.propertySymbolPointer)
|
compareSymbolPointers(ktModule, propertySymbolPointer, other.propertySymbolPointer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-5
@@ -222,14 +222,12 @@ internal class SymbolLightAccessorMethod private constructor(
|
|||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
if (this === other) return true
|
if (this === other) return true
|
||||||
if (other !is SymbolLightAccessorMethod) return false
|
if (other !is SymbolLightAccessorMethod || other.ktModule != ktModule || other.isGetter != isGetter) return false
|
||||||
if (propertyAccessorDeclaration != null) {
|
if (propertyAccessorDeclaration != null) {
|
||||||
return propertyAccessorDeclaration == other.propertyAccessorDeclaration && ktModule == other.ktModule
|
return propertyAccessorDeclaration == other.propertyAccessorDeclaration
|
||||||
}
|
}
|
||||||
|
|
||||||
return isGetter == other.isGetter &&
|
return other.propertyAccessorDeclaration == null &&
|
||||||
other.propertyAccessorDeclaration == null &&
|
|
||||||
ktModule == other.ktModule &&
|
|
||||||
compareSymbolPointers(ktModule, propertyAccessorSymbolPointer, other.propertyAccessorSymbolPointer)
|
compareSymbolPointers(ktModule, propertyAccessorSymbolPointer, other.propertyAccessorSymbolPointer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@ internal class SymbolLightConstructor(
|
|||||||
lightMemberOrigin = lightMemberOrigin,
|
lightMemberOrigin = lightMemberOrigin,
|
||||||
containingClass = containingClass,
|
containingClass = containingClass,
|
||||||
methodIndex = methodIndex,
|
methodIndex = methodIndex,
|
||||||
argumentsSkipMask = argumentsSkipMask
|
argumentsSkipMask = argumentsSkipMask,
|
||||||
) {
|
) {
|
||||||
private val _name: String? = containingClass.name
|
private val _name: String? = containingClass.name
|
||||||
|
|
||||||
|
|||||||
+6
-9
@@ -125,23 +125,20 @@ internal abstract class SymbolLightMethod<FType : KtFunctionLikeSymbol> private
|
|||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
if (this === other) return true
|
if (this === other) return true
|
||||||
if (other !is SymbolLightMethod<*>) return false
|
if (other !is SymbolLightMethod<*> ||
|
||||||
|
other.methodIndex != methodIndex ||
|
||||||
|
other.ktModule != ktModule ||
|
||||||
|
other.argumentsSkipMask != argumentsSkipMask
|
||||||
|
) return false
|
||||||
|
|
||||||
if (functionDeclaration != null) {
|
if (functionDeclaration != null) {
|
||||||
return functionDeclaration == other.functionDeclaration && fieldsEquals(other)
|
return functionDeclaration == other.functionDeclaration
|
||||||
}
|
}
|
||||||
|
|
||||||
return other.functionDeclaration == null &&
|
return other.functionDeclaration == null &&
|
||||||
fieldsEquals(other) &&
|
|
||||||
containingClass == other.containingClass &&
|
containingClass == other.containingClass &&
|
||||||
compareSymbolPointers(ktModule, functionSymbolPointer, other.functionSymbolPointer)
|
compareSymbolPointers(ktModule, functionSymbolPointer, other.functionSymbolPointer)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun fieldsEquals(other: SymbolLightMethod<*>): Boolean {
|
|
||||||
return methodIndex == other.methodIndex &&
|
|
||||||
ktModule == other.ktModule &&
|
|
||||||
argumentsSkipMask == other.argumentsSkipMask
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun hashCode(): Int = kotlinOrigin.hashCode()
|
override fun hashCode(): Int = kotlinOrigin.hashCode()
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -90,13 +90,13 @@ internal abstract class SymbolLightParameterCommon(
|
|||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
if (this === other) return true
|
if (this === other) return true
|
||||||
if (other !is SymbolLightParameterCommon) return false
|
if (other !is SymbolLightParameterCommon || other.ktModule != ktModule) return false
|
||||||
|
|
||||||
if (parameterDeclaration != null) {
|
if (parameterDeclaration != null) {
|
||||||
return parameterDeclaration == other.parameterDeclaration && ktModule == other.ktModule
|
return parameterDeclaration == other.parameterDeclaration
|
||||||
}
|
}
|
||||||
|
|
||||||
return ktModule == other.ktModule && compareSymbolPointers(ktModule, parameterSymbolPointer, other.parameterSymbolPointer)
|
return other.parameterDeclaration == null && compareSymbolPointers(ktModule, parameterSymbolPointer, other.parameterSymbolPointer)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun hashCode(): Int = parameterDeclaration?.hashCode() ?: _name.hashCode()
|
override fun hashCode(): Int = parameterDeclaration?.hashCode() ?: _name.hashCode()
|
||||||
|
|||||||
Reference in New Issue
Block a user