[FIR IDE] Fix KtSymbolKind for local symbols in AAPI/FE10
In Analysis API a callable declaration is local only if it is an immediate child of a callable declaration. Declarations inside anonymous objects are 'KtSymbolKind.CLASS_MEMBER'.
This commit is contained in:
+10
-4
@@ -46,10 +46,16 @@ import org.jetbrains.kotlin.types.checker.NewCapturedType
|
||||
import org.jetbrains.kotlin.types.checker.NewTypeVariableConstructor
|
||||
|
||||
internal val MemberDescriptor.ktSymbolKind: KtSymbolKind
|
||||
get() = when {
|
||||
containingDeclaration is PackageFragmentDescriptor -> KtSymbolKind.TOP_LEVEL
|
||||
DescriptorUtils.isLocal(this) -> KtSymbolKind.LOCAL
|
||||
else -> KtSymbolKind.CLASS_MEMBER
|
||||
get() {
|
||||
return when (this) {
|
||||
is PropertyAccessorDescriptor -> KtSymbolKind.ACCESSOR
|
||||
is SamConstructorDescriptor -> KtSymbolKind.SAM_CONSTRUCTOR
|
||||
else -> when (containingDeclaration) {
|
||||
is PackageFragmentDescriptor -> KtSymbolKind.TOP_LEVEL
|
||||
is ClassDescriptor -> KtSymbolKind.CLASS_MEMBER
|
||||
else -> KtSymbolKind.LOCAL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal val CallableMemberDescriptor.isExplicitOverride: Boolean
|
||||
|
||||
+15
-5
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.name.CallableId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
|
||||
import org.jetbrains.kotlin.psi.psiUtil.hasBody
|
||||
import org.jetbrains.kotlin.psi.psiUtil.isTopLevelInFileOrScript
|
||||
import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf
|
||||
@@ -62,11 +63,20 @@ internal val KtDeclaration.ktModality: Modality?
|
||||
}
|
||||
|
||||
internal val KtElement.ktSymbolKind: KtSymbolKind
|
||||
get() = when {
|
||||
this is KtPropertyAccessor -> KtSymbolKind.ACCESSOR
|
||||
isTopLevelInFileOrScript(this) -> KtSymbolKind.TOP_LEVEL
|
||||
this is KtDeclaration && !KtPsiUtil.isLocal(this) -> KtSymbolKind.CLASS_MEMBER
|
||||
else -> KtSymbolKind.LOCAL
|
||||
get() {
|
||||
if (this is KtPropertyAccessor) {
|
||||
return KtSymbolKind.ACCESSOR
|
||||
}
|
||||
|
||||
if (this is KtDeclaration) {
|
||||
return when (this.getParentOfType<KtDeclaration>(strict = true)) {
|
||||
null -> KtSymbolKind.TOP_LEVEL
|
||||
is KtCallableDeclaration, is KtPropertyAccessor -> KtSymbolKind.LOCAL
|
||||
else -> KtSymbolKind.CLASS_MEMBER
|
||||
}
|
||||
}
|
||||
|
||||
return KtSymbolKind.LOCAL
|
||||
}
|
||||
|
||||
internal val KtDeclaration.callableIdIfNonLocal: CallableId?
|
||||
|
||||
Reference in New Issue
Block a user