[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 copy(): SymbolLightAnnotationClass =
|
||||
SymbolLightAnnotationClass(classOrObjectDeclaration, classOrObjectSymbolPointer, ktModule, manager)
|
||||
override fun copy(): SymbolLightAnnotationClass = SymbolLightAnnotationClass(
|
||||
classOrObjectDeclaration = classOrObjectDeclaration,
|
||||
classOrObjectSymbolPointer = classOrObjectSymbolPointer,
|
||||
ktModule = ktModule,
|
||||
manager = manager,
|
||||
)
|
||||
}
|
||||
|
||||
+5
-5
@@ -51,7 +51,7 @@ internal open class SymbolLightClass : SymbolLightClassForNamedClassOrObject {
|
||||
ktAnalysisSession: KtAnalysisSession,
|
||||
ktModule: KtModule,
|
||||
classOrObjectSymbol: KtNamedClassOrObjectSymbol,
|
||||
manager: PsiManager
|
||||
manager: PsiManager,
|
||||
) : super(
|
||||
ktAnalysisSession = ktAnalysisSession,
|
||||
ktModule = ktModule,
|
||||
@@ -137,8 +137,7 @@ internal open class SymbolLightClass : SymbolLightClassForNamedClassOrObject {
|
||||
|
||||
val visibleDeclarations = declaredMemberScope.getCallableSymbols().applyIf(isEnum) {
|
||||
filterNot { function ->
|
||||
function is KtFunctionSymbol &&
|
||||
(function.name == ENUM_VALUES || function.name == ENUM_VALUE_OF)
|
||||
function is KtFunctionSymbol && (function.name == ENUM_VALUES || function.name == ENUM_VALUE_OF)
|
||||
}
|
||||
}.applyIf(isObject) {
|
||||
filterNot {
|
||||
@@ -239,7 +238,7 @@ internal open class SymbolLightClass : SymbolLightClassForNamedClassOrObject {
|
||||
METHOD_INDEX_FOR_NON_ORIGIN_METHOD,
|
||||
false,
|
||||
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)
|
||||
filter { containingClass?.isInterface == true && !it.hasJvmFieldAnnotation() }
|
||||
}
|
||||
|
||||
val propertyGroups = propertySymbols.groupBy { it.isFromPrimaryConstructor }
|
||||
|
||||
val nameGenerator = SymbolLightField.FieldNameGenerator()
|
||||
@@ -337,7 +337,7 @@ internal open class SymbolLightClass : SymbolLightClassForNamedClassOrObject {
|
||||
SymbolLightFieldForEnumEntry(
|
||||
enumEntry = enumEntry,
|
||||
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(
|
||||
myClass = this@SymbolLightClassBase,
|
||||
dependencies = listOf(manager.project.createProjectWideOutOfBlockModificationTracker()),
|
||||
lazyCreator = SymbolLightClassesLazyCreator(project)
|
||||
lazyCreator = SymbolLightClassesLazyCreator(project),
|
||||
)
|
||||
|
||||
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 findFieldByName(name: String, checkBases: Boolean) =
|
||||
myInnersCache.findFieldByName(name, checkBases)
|
||||
override fun findFieldByName(name: String, checkBases: Boolean) = myInnersCache.findFieldByName(name, checkBases)
|
||||
|
||||
override fun findMethodsByName(name: String, checkBases: Boolean): Array<PsiMethod> =
|
||||
myInnersCache.findMethodsByName(name, checkBases)
|
||||
override fun findMethodsByName(name: String, checkBases: Boolean): Array<PsiMethod> = myInnersCache.findMethodsByName(name, checkBases)
|
||||
|
||||
override fun findInnerClassByName(name: String, checkBases: Boolean): PsiClass? =
|
||||
myInnersCache.findInnerClassByName(name, checkBases)
|
||||
override fun findInnerClassByName(name: String, checkBases: Boolean): PsiClass? = myInnersCache.findInnerClassByName(name, checkBases)
|
||||
|
||||
override fun processDeclarations(
|
||||
processor: PsiScopeProcessor, state: ResolveState, lastParent: PsiElement?, place: PsiElement
|
||||
): Boolean {
|
||||
return PsiClassImplUtil.processDeclarationsInClass(
|
||||
this,
|
||||
processor,
|
||||
state,
|
||||
null,
|
||||
lastParent,
|
||||
place,
|
||||
PsiUtil.getLanguageLevel(place),
|
||||
false
|
||||
)
|
||||
}
|
||||
): Boolean = PsiClassImplUtil.processDeclarationsInClass(
|
||||
/* aClass = */ this,
|
||||
/* processor = */ processor,
|
||||
/* state = */ state,
|
||||
/* visited = */ null,
|
||||
/* last = */ lastParent,
|
||||
/* place = */ place,
|
||||
/* languageLevel = */ PsiUtil.getLanguageLevel(place),
|
||||
/* isRaw = */ false,
|
||||
)
|
||||
|
||||
override fun isInheritor(baseClass: PsiClass, checkDeep: Boolean): Boolean {
|
||||
if (manager.areElementsEquivalent(baseClass, this)) return false
|
||||
@@ -161,9 +156,8 @@ abstract class SymbolLightClassBase protected constructor(val ktModule: KtModule
|
||||
|
||||
override fun findMethodsAndTheirSubstitutorsByName(
|
||||
@NonNls name: String?,
|
||||
checkBases: Boolean
|
||||
): List<Pair<PsiMethod?, PsiSubstitutor?>?> =
|
||||
PsiClassImplUtil.findMethodsAndTheirSubstitutorsByName(this, name, checkBases)
|
||||
checkBases: Boolean,
|
||||
): List<Pair<PsiMethod?, PsiSubstitutor?>?> = PsiClassImplUtil.findMethodsAndTheirSubstitutorsByName(this, name, checkBases)
|
||||
|
||||
override fun getAllMethodsAndTheirSubstitutors(): List<Pair<PsiMethod?, PsiSubstitutor?>?> {
|
||||
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 getElementIcon(flags: Int): Icon? =
|
||||
throw UnsupportedOperationException("This should be done by KotlinIconProvider")
|
||||
override fun getElementIcon(flags: Int): Icon? = throw UnsupportedOperationException("This should be done by KotlinIconProvider")
|
||||
|
||||
override fun getVisibleSignatures(): MutableCollection<HierarchicalMethodSignature> = PsiSuperMethodImplUtil.getVisibleSignatures(this)
|
||||
|
||||
|
||||
+5
-4
@@ -6,8 +6,6 @@
|
||||
package org.jetbrains.kotlin.light.classes.symbol.classes
|
||||
|
||||
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.project.structure.KtModule
|
||||
import org.jetbrains.kotlin.asJava.classes.KotlinSuperTypeListBuilder
|
||||
@@ -24,9 +22,7 @@ internal class SymbolLightClassForEnumEntry(
|
||||
ktModule: KtModule,
|
||||
) : SymbolLightClass(
|
||||
enumConstant.kotlinOrigin,
|
||||
symbolPointer<KtNamedClassOrObjectSymbol> { null },
|
||||
ktModule,
|
||||
enumClass.manager,
|
||||
), PsiEnumConstantInitializer {
|
||||
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 equals(other: Any?): Boolean = this === other ||
|
||||
other is SymbolLightClassForEnumEntry && other.enumConstant == enumConstant
|
||||
|
||||
override fun hashCode(): Int = enumConstant.hashCode()
|
||||
|
||||
override fun toString(): String = "SymbolLightClassForEnumEntry:$name"
|
||||
|
||||
private val _modifierList: PsiModifierList by lazy {
|
||||
|
||||
+2
-4
@@ -69,11 +69,9 @@ abstract class SymbolLightClassForNamedClassOrObject : SymbolLightClassForClassO
|
||||
}
|
||||
}
|
||||
|
||||
private val KtPropertySymbol.isConstOrJvmField: Boolean
|
||||
get() = isConst || hasJvmFieldAnnotation()
|
||||
private val KtPropertySymbol.isConstOrJvmField: Boolean get() = isConst || hasJvmFieldAnnotation()
|
||||
|
||||
private val KtPropertySymbol.isConst: Boolean
|
||||
get() = (this as? KtKotlinPropertySymbol)?.isConst == true
|
||||
private val KtPropertySymbol.isConst: Boolean get() = (this as? KtKotlinPropertySymbol)?.isConst == true
|
||||
|
||||
context(ktAnalysisSession@KtAnalysisSession)
|
||||
protected fun addFieldsFromCompanionIfNeeded(
|
||||
|
||||
+2
-4
@@ -169,15 +169,13 @@ internal class SymbolLightFieldForProperty private constructor(
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
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) {
|
||||
return kotlinOrigin == other.kotlinOrigin && ktModule == other.ktModule
|
||||
return kotlinOrigin == other.kotlinOrigin
|
||||
}
|
||||
|
||||
return other.kotlinOrigin == null &&
|
||||
fieldName == other.fieldName &&
|
||||
containingClass == other.containingClass &&
|
||||
ktModule == other.ktModule &&
|
||||
compareSymbolPointers(ktModule, propertySymbolPointer, other.propertySymbolPointer)
|
||||
}
|
||||
|
||||
|
||||
+3
-5
@@ -222,14 +222,12 @@ internal class SymbolLightAccessorMethod private constructor(
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
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) {
|
||||
return propertyAccessorDeclaration == other.propertyAccessorDeclaration && ktModule == other.ktModule
|
||||
return propertyAccessorDeclaration == other.propertyAccessorDeclaration
|
||||
}
|
||||
|
||||
return isGetter == other.isGetter &&
|
||||
other.propertyAccessorDeclaration == null &&
|
||||
ktModule == other.ktModule &&
|
||||
return other.propertyAccessorDeclaration == null &&
|
||||
compareSymbolPointers(ktModule, propertyAccessorSymbolPointer, other.propertyAccessorSymbolPointer)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ internal class SymbolLightConstructor(
|
||||
lightMemberOrigin = lightMemberOrigin,
|
||||
containingClass = containingClass,
|
||||
methodIndex = methodIndex,
|
||||
argumentsSkipMask = argumentsSkipMask
|
||||
argumentsSkipMask = argumentsSkipMask,
|
||||
) {
|
||||
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 {
|
||||
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) {
|
||||
return functionDeclaration == other.functionDeclaration && fieldsEquals(other)
|
||||
return functionDeclaration == other.functionDeclaration
|
||||
}
|
||||
|
||||
return other.functionDeclaration == null &&
|
||||
fieldsEquals(other) &&
|
||||
containingClass == other.containingClass &&
|
||||
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()
|
||||
}
|
||||
|
||||
+3
-3
@@ -90,13 +90,13 @@ internal abstract class SymbolLightParameterCommon(
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is SymbolLightParameterCommon) return false
|
||||
if (other !is SymbolLightParameterCommon || other.ktModule != ktModule) return false
|
||||
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user