mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[kotlin] Clean up
#KTIJ-34403 GitOrigin-RevId: c527c46531aa9827d93376da2a88178fba6095f4
This commit is contained in:
committed by
intellij-monorepo-bot
parent
47d79bcea1
commit
666f6f44c6
+2
-1
@@ -99,13 +99,14 @@ abstract class KotlinLanguageInjectionContributorBase : LanguageInjectionContrib
|
||||
|
||||
val project = ktHost.project
|
||||
val modificationCount = PsiManager.getInstance(project).modificationTracker.modificationCount
|
||||
val configuration = Configuration.getProjectInstance(project)
|
||||
|
||||
return when {
|
||||
kotlinCachedInjection != null && (modificationCount == kotlinCachedInjection.modificationCount) ->
|
||||
// Cache is up-to-date
|
||||
kotlinCachedInjection.baseInjection
|
||||
else -> {
|
||||
val configuration = Configuration.getProjectInstance(project)
|
||||
|
||||
fun computeAndCache(): BaseInjection {
|
||||
val computedInjection = computeBaseInjection(ktHost, containingFile, configuration, support) ?: absentKotlinInjection
|
||||
ktHost.cachedInjectionWithModification = KotlinCachedInjection(modificationCount, computedInjection)
|
||||
|
||||
+9
-6
@@ -19,6 +19,7 @@ import org.jetbrains.kotlin.idea.base.injection.KotlinLanguageInjectionContribut
|
||||
import org.jetbrains.kotlin.idea.references.KtReference
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.name.CallableId
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.KtCallExpression
|
||||
@@ -50,7 +51,7 @@ internal class K2KotlinLanguageInjectionContributor : KotlinLanguageInjectionCon
|
||||
null
|
||||
} else {
|
||||
analyze(callableDeclaration) {
|
||||
val annotation = callableDeclaration.symbol.findAnnotation<LanguageAnnotation>() ?: return null
|
||||
val annotation = callableDeclaration.symbol.findAnnotation() ?: return null
|
||||
injectionInfoByAnnotation(annotation)
|
||||
}
|
||||
}
|
||||
@@ -72,8 +73,8 @@ internal class K2KotlinLanguageInjectionContributor : KotlinLanguageInjectionCon
|
||||
// For a parameter of a primary constructor, there are multiple possible locations for the annotation in the generated Java
|
||||
// bytecode e.g., getter. Thus, we cannot get annotations of the parameter symbol itself. We have to check its use-site targets.
|
||||
// We first check its generated property here.
|
||||
val annotationForParameter = parameterSymbol.generatedPrimaryConstructorProperty?.findAnnotation<LanguageAnnotation>()
|
||||
?: parameterSymbol.findAnnotation<LanguageAnnotation>() ?: return null
|
||||
val annotationForParameter = parameterSymbol.generatedPrimaryConstructorProperty?.findAnnotation()
|
||||
?: parameterSymbol.findAnnotation() ?: return null
|
||||
injectionInfoByAnnotation(annotationForParameter)
|
||||
}
|
||||
}
|
||||
@@ -87,9 +88,11 @@ internal class K2KotlinLanguageInjectionContributor : KotlinLanguageInjectionCon
|
||||
}
|
||||
}
|
||||
|
||||
context(KaSession)
|
||||
private inline fun <reified T : Annotation> KaAnnotatedSymbol.findAnnotation(): KaAnnotation? =
|
||||
annotations.find { it.classId?.asFqNameString() == T::class.java.name }
|
||||
private val languageAnnotationClassId =
|
||||
ClassId(FqName(LanguageAnnotation::class.java.packageName), FqName(LanguageAnnotation::class.java.simpleName), false)
|
||||
|
||||
private inline fun KaAnnotatedSymbol.findAnnotation(annotationClassId: ClassId = languageAnnotationClassId): KaAnnotation? =
|
||||
annotations.firstOrNull { it.classId == annotationClassId }
|
||||
|
||||
context(KaSession)
|
||||
private fun KaAnnotation.getStringValueOfArgument(argumentName: String): String? {
|
||||
|
||||
Reference in New Issue
Block a user