[Analysis API] Treat inapplicable declarations safely (KTIJ-23458)

Make 'getClassOrObjectSymbol()' and 'getNamedClassOrObjectSymbol()'
return 'null' for inapplicable PSI declarations.
This commit is contained in:
Yan Zhulanow
2022-11-01 19:23:56 +09:00
committed by teamcity
parent 0a8b9c821c
commit 4d41ac09df
7 changed files with 30 additions and 20 deletions
@@ -87,8 +87,10 @@ internal class KtFe10SymbolProvider(
return KtFe10PsiAnonymousObjectSymbol(psi.objectDeclaration, analysisContext)
}
override fun getClassOrObjectSymbol(psi: KtClassOrObject): KtClassOrObjectSymbol {
return if (psi is KtObjectDeclaration && psi.isObjectLiteral()) {
override fun getClassOrObjectSymbol(psi: KtClassOrObject): KtClassOrObjectSymbol? {
return if (psi is KtEnumEntry) {
null
} else if (psi is KtObjectDeclaration && psi.isObjectLiteral()) {
KtFe10PsiAnonymousObjectSymbol(psi, analysisContext)
} else {
KtFe10PsiNamedClassOrObjectSymbol(psi, analysisContext)