[SLC] AnnotationsBox: use PsiElement instead of PsiModifierList
Not only PsiModifierList can be the parent of an annotation, so we should make the restrictions less aggressive. ^KT-65112
This commit is contained in:
committed by
Space Team
parent
717dd08fd4
commit
ae8e9749c8
+16
-17
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.light.classes.symbol.annotations
|
||||
import com.intellij.psi.PsiAnnotation
|
||||
import com.intellij.psi.PsiClass
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiModifierList
|
||||
import org.jetbrains.kotlin.analysis.api.annotations.*
|
||||
import org.jetbrains.kotlin.builtins.StandardNames
|
||||
import org.jetbrains.kotlin.load.java.JvmAbi
|
||||
@@ -24,7 +23,7 @@ internal object AbstractClassAdditionalAnnotationsProvider : AdditionalAnnotatio
|
||||
override fun addAllAnnotations(
|
||||
currentRawAnnotations: MutableList<in PsiAnnotation>,
|
||||
foundQualifiers: MutableSet<String>,
|
||||
owner: PsiModifierList
|
||||
owner: PsiElement
|
||||
) {
|
||||
if (!owner.parent.isAnnotationClass()) return
|
||||
|
||||
@@ -34,7 +33,7 @@ internal object AbstractClassAdditionalAnnotationsProvider : AdditionalAnnotatio
|
||||
override fun findSpecialAnnotation(
|
||||
annotationsBox: GranularAnnotationsBox,
|
||||
qualifiedName: String,
|
||||
owner: PsiModifierList,
|
||||
owner: PsiElement,
|
||||
): PsiAnnotation? = if (owner.parent.isAnnotationClass())
|
||||
findAdditionalAnnotationFromAnnotationClass(annotationsBox, qualifiedName, owner)
|
||||
else
|
||||
@@ -48,7 +47,7 @@ private fun PsiElement.isAnnotationClass(): Boolean = this is PsiClass && isAnno
|
||||
private fun addAllAnnotationsFromAnnotationClass(
|
||||
currentRawAnnotations: MutableList<in PsiAnnotation>,
|
||||
foundQualifiers: MutableSet<String>,
|
||||
owner: PsiModifierList,
|
||||
owner: PsiElement,
|
||||
) {
|
||||
for (index in currentRawAnnotations.indices) {
|
||||
val currentAnnotation = currentRawAnnotations[index] as? SymbolLightLazyAnnotation ?: continue
|
||||
@@ -73,7 +72,7 @@ private fun addAllAnnotationsFromAnnotationClass(
|
||||
private fun findAdditionalAnnotationFromAnnotationClass(
|
||||
annotationsBox: GranularAnnotationsBox,
|
||||
qualifiedName: String,
|
||||
owner: PsiModifierList,
|
||||
owner: PsiElement,
|
||||
): PsiAnnotation? = annotationsBox.tryConvertToRetentionJavaAnnotation(qualifiedName, owner)
|
||||
?: annotationsBox.tryConvertToTargetJavaAnnotation(qualifiedName, owner)
|
||||
?: annotationsBox.tryConvertToDocumentedJavaAnnotation(qualifiedName, owner)
|
||||
@@ -82,7 +81,7 @@ private fun findAdditionalAnnotationFromAnnotationClass(
|
||||
|
||||
private fun GranularAnnotationsBox.tryConvertToDocumentedJavaAnnotation(
|
||||
qualifiedName: String,
|
||||
owner: PsiModifierList,
|
||||
owner: PsiElement,
|
||||
): PsiAnnotation? = tryConvertToJavaAnnotation(
|
||||
qualifiedName = qualifiedName,
|
||||
javaQualifier = JvmAnnotationNames.DOCUMENTED_ANNOTATION.asString(),
|
||||
@@ -91,7 +90,7 @@ private fun GranularAnnotationsBox.tryConvertToDocumentedJavaAnnotation(
|
||||
)
|
||||
|
||||
private fun SymbolLightLazyAnnotation.tryConvertToDocumentedJavaAnnotation(
|
||||
owner: PsiModifierList,
|
||||
owner: PsiElement,
|
||||
): PsiAnnotation? = tryConvertToJavaAnnotation(
|
||||
javaQualifier = JvmAnnotationNames.DOCUMENTED_ANNOTATION.asString(),
|
||||
kotlinQualifier = StandardNames.FqNames.mustBeDocumented.asString(),
|
||||
@@ -100,7 +99,7 @@ private fun SymbolLightLazyAnnotation.tryConvertToDocumentedJavaAnnotation(
|
||||
|
||||
private fun GranularAnnotationsBox.tryConvertToRetentionJavaAnnotation(
|
||||
qualifiedName: String,
|
||||
owner: PsiModifierList,
|
||||
owner: PsiElement,
|
||||
): PsiAnnotation? {
|
||||
val javaQualifier = JvmAnnotationNames.RETENTION_ANNOTATION.asString()
|
||||
return tryConvertToJavaAnnotation(
|
||||
@@ -113,7 +112,7 @@ private fun GranularAnnotationsBox.tryConvertToRetentionJavaAnnotation(
|
||||
}
|
||||
|
||||
private fun SymbolLightLazyAnnotation.tryConvertToRetentionJavaAnnotation(
|
||||
owner: PsiModifierList,
|
||||
owner: PsiElement,
|
||||
): PsiAnnotation? = tryConvertToJavaAnnotation(
|
||||
javaQualifier = JvmAnnotationNames.RETENTION_ANNOTATION.asString(),
|
||||
kotlinQualifier = StandardNames.FqNames.retention.asString(),
|
||||
@@ -133,7 +132,7 @@ private fun SymbolLightJavaAnnotation.computeJavaRetentionArguments(): List<KtNa
|
||||
return javaRetentionArguments(kotlinRetentionName)
|
||||
}
|
||||
|
||||
private fun createRetentionJavaAnnotation(owner: PsiModifierList): PsiAnnotation = SymbolLightSimpleAnnotation(
|
||||
private fun createRetentionJavaAnnotation(owner: PsiElement): PsiAnnotation = SymbolLightSimpleAnnotation(
|
||||
fqName = JvmAnnotationNames.RETENTION_ANNOTATION.asString(),
|
||||
parent = owner,
|
||||
arguments = javaRetentionArguments(kotlinRetentionName = null),
|
||||
@@ -159,7 +158,7 @@ private fun retentionMapping(name: String): String = when (name) {
|
||||
|
||||
private fun GranularAnnotationsBox.tryConvertToRepeatableJavaAnnotation(
|
||||
qualifiedName: String,
|
||||
owner: PsiModifierList,
|
||||
owner: PsiElement,
|
||||
): PsiAnnotation? = tryConvertToJavaAnnotation(
|
||||
qualifiedName = qualifiedName,
|
||||
javaQualifier = JvmAnnotationNames.REPEATABLE_ANNOTATION.asString(),
|
||||
@@ -169,7 +168,7 @@ private fun GranularAnnotationsBox.tryConvertToRepeatableJavaAnnotation(
|
||||
)
|
||||
|
||||
private fun SymbolLightLazyAnnotation.tryConvertToRepeatableJavaAnnotation(
|
||||
owner: PsiModifierList,
|
||||
owner: PsiElement,
|
||||
): PsiAnnotation? = tryConvertToJavaAnnotation(
|
||||
javaQualifier = JvmAnnotationNames.REPEATABLE_ANNOTATION.asString(),
|
||||
kotlinQualifier = StandardNames.FqNames.repeatable.asString(),
|
||||
@@ -193,7 +192,7 @@ private fun SymbolLightJavaAnnotation.computeRepeatableJavaAnnotationArguments()
|
||||
|
||||
private fun GranularAnnotationsBox.tryConvertToTargetJavaAnnotation(
|
||||
qualifiedName: String,
|
||||
owner: PsiModifierList,
|
||||
owner: PsiElement,
|
||||
): PsiAnnotation? = tryConvertToJavaAnnotation(
|
||||
qualifiedName = qualifiedName,
|
||||
javaQualifier = JvmAnnotationNames.TARGET_ANNOTATION.asString(),
|
||||
@@ -203,7 +202,7 @@ private fun GranularAnnotationsBox.tryConvertToTargetJavaAnnotation(
|
||||
)
|
||||
|
||||
private fun SymbolLightLazyAnnotation.tryConvertToTargetJavaAnnotation(
|
||||
owner: PsiModifierList,
|
||||
owner: PsiElement,
|
||||
): PsiAnnotation? = tryConvertToJavaAnnotation(
|
||||
javaQualifier = JvmAnnotationNames.TARGET_ANNOTATION.asString(),
|
||||
kotlinQualifier = StandardNames.FqNames.target.asString(),
|
||||
@@ -262,7 +261,7 @@ private fun GranularAnnotationsBox.tryConvertToJavaAnnotation(
|
||||
qualifiedName: String,
|
||||
javaQualifier: String,
|
||||
kotlinQualifier: String,
|
||||
owner: PsiModifierList,
|
||||
owner: PsiElement,
|
||||
argumentsComputer: SymbolLightJavaAnnotation.() -> List<KtNamedAnnotationValue> = { emptyList() },
|
||||
): PsiAnnotation? {
|
||||
if (qualifiedName != javaQualifier) return null
|
||||
@@ -285,7 +284,7 @@ private fun GranularAnnotationsBox.tryConvertToJavaAnnotation(
|
||||
private fun SymbolLightLazyAnnotation.tryConvertToJavaAnnotation(
|
||||
javaQualifier: String,
|
||||
kotlinQualifier: String,
|
||||
owner: PsiModifierList,
|
||||
owner: PsiElement,
|
||||
argumentsComputer: SymbolLightJavaAnnotation.() -> List<KtNamedAnnotationValue> = { emptyList() },
|
||||
): PsiAnnotation? {
|
||||
if (qualifiedName != kotlinQualifier) return null
|
||||
|
||||
+6
-6
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.light.classes.symbol.annotations
|
||||
|
||||
import com.intellij.psi.PsiAnnotation
|
||||
import com.intellij.psi.PsiModifierList
|
||||
import com.intellij.psi.PsiElement
|
||||
|
||||
/**
|
||||
* This class provides more annotation in addition to [AnnotationsProvider].
|
||||
@@ -27,7 +27,7 @@ internal sealed interface AdditionalAnnotationsProvider {
|
||||
* @param foundQualifiers a list of already presented qualifiers. Used to optimize computation
|
||||
* @param owner an owner for new annotations
|
||||
*/
|
||||
fun addAllAnnotations(currentRawAnnotations: MutableList<in PsiAnnotation>, foundQualifiers: MutableSet<String>, owner: PsiModifierList)
|
||||
fun addAllAnnotations(currentRawAnnotations: MutableList<in PsiAnnotation>, foundQualifiers: MutableSet<String>, owner: PsiElement)
|
||||
|
||||
/**
|
||||
* @return **true** if this qualifier should be treated as a **special** in [GranularAnnotationsBox.findAnnotation]
|
||||
@@ -44,7 +44,7 @@ internal sealed interface AdditionalAnnotationsProvider {
|
||||
*
|
||||
* @return a new annotation with [qualifiedName]
|
||||
*/
|
||||
fun findSpecialAnnotation(annotationsBox: GranularAnnotationsBox, qualifiedName: String, owner: PsiModifierList): PsiAnnotation?
|
||||
fun findSpecialAnnotation(annotationsBox: GranularAnnotationsBox, qualifiedName: String, owner: PsiElement): PsiAnnotation?
|
||||
|
||||
/**
|
||||
* Adds a new annotation with [qualifier] name to [currentRawAnnotations] and [foundQualifiers] if not already present
|
||||
@@ -53,7 +53,7 @@ internal sealed interface AdditionalAnnotationsProvider {
|
||||
qualifier: String,
|
||||
currentRawAnnotations: MutableList<in PsiAnnotation>,
|
||||
foundQualifiers: MutableSet<String>,
|
||||
owner: PsiModifierList,
|
||||
owner: PsiElement,
|
||||
) {
|
||||
val isNewQualifier = foundQualifiers.add(qualifier)
|
||||
if (!isNewQualifier) return
|
||||
@@ -64,6 +64,6 @@ internal sealed interface AdditionalAnnotationsProvider {
|
||||
fun createSimpleAnnotationIfMatches(
|
||||
qualifier: String,
|
||||
expectedQualifier: String,
|
||||
owner: PsiModifierList,
|
||||
owner: PsiElement,
|
||||
): PsiAnnotation? = if (qualifier == expectedQualifier) SymbolLightSimpleAnnotation(expectedQualifier, owner) else null
|
||||
}
|
||||
|
||||
+5
-5
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.light.classes.symbol.annotations
|
||||
|
||||
import com.intellij.psi.PsiAnnotation
|
||||
import com.intellij.psi.PsiModifierList
|
||||
import com.intellij.psi.PsiElement
|
||||
|
||||
/**
|
||||
* This class is used as a proxy for [com.intellij.psi.PsiAnnotationOwner].
|
||||
@@ -18,7 +18,7 @@ import com.intellij.psi.PsiModifierList
|
||||
* @see org.jetbrains.kotlin.light.classes.symbol.modifierLists.SymbolLightModifierList
|
||||
*/
|
||||
internal sealed interface AnnotationsBox {
|
||||
fun annotationsArray(owner: PsiModifierList): Array<PsiAnnotation>
|
||||
fun findAnnotation(owner: PsiModifierList, qualifiedName: String): PsiAnnotation?
|
||||
fun hasAnnotation(owner: PsiModifierList, qualifiedName: String): Boolean = findAnnotation(owner, qualifiedName) != null
|
||||
fun annotationsArray(owner: PsiElement): Array<PsiAnnotation>
|
||||
fun findAnnotation(owner: PsiElement, qualifiedName: String): PsiAnnotation?
|
||||
fun hasAnnotation(owner: PsiElement, qualifiedName: String): Boolean = findAnnotation(owner, qualifiedName) != null
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.light.classes.symbol.annotations
|
||||
|
||||
import com.intellij.psi.PsiAnnotation
|
||||
import com.intellij.psi.PsiModifierList
|
||||
import com.intellij.psi.PsiElement
|
||||
|
||||
internal class CollectionAdditionalAnnotationsProvider(
|
||||
private val additionalAnnotationQualifiers: Collection<String>,
|
||||
@@ -16,7 +16,7 @@ internal class CollectionAdditionalAnnotationsProvider(
|
||||
override fun addAllAnnotations(
|
||||
currentRawAnnotations: MutableList<in PsiAnnotation>,
|
||||
foundQualifiers: MutableSet<String>,
|
||||
owner: PsiModifierList,
|
||||
owner: PsiElement,
|
||||
) {
|
||||
additionalAnnotationQualifiers.forEach { qualifiedName ->
|
||||
addSimpleAnnotationIfMissing(qualifiedName, currentRawAnnotations, foundQualifiers, owner)
|
||||
@@ -26,7 +26,7 @@ internal class CollectionAdditionalAnnotationsProvider(
|
||||
override fun findSpecialAnnotation(
|
||||
annotationsBox: GranularAnnotationsBox,
|
||||
qualifiedName: String,
|
||||
owner: PsiModifierList,
|
||||
owner: PsiElement,
|
||||
): PsiAnnotation? {
|
||||
if (qualifiedName !in additionalAnnotationQualifiers) return null
|
||||
|
||||
|
||||
+4
-4
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.light.classes.symbol.annotations
|
||||
|
||||
import com.intellij.psi.PsiAnnotation
|
||||
import com.intellij.psi.PsiModifierList
|
||||
import com.intellij.psi.PsiElement
|
||||
|
||||
internal class CompositeAdditionalAnnotationsProvider(val providers: List<AdditionalAnnotationsProvider>) : AdditionalAnnotationsProvider {
|
||||
constructor(vararg providers: AdditionalAnnotationsProvider) : this(providers.toList())
|
||||
@@ -14,7 +14,7 @@ internal class CompositeAdditionalAnnotationsProvider(val providers: List<Additi
|
||||
override fun addAllAnnotations(
|
||||
currentRawAnnotations: MutableList<in PsiAnnotation>,
|
||||
foundQualifiers: MutableSet<String>,
|
||||
owner: PsiModifierList,
|
||||
owner: PsiElement,
|
||||
) {
|
||||
providers.forEach { provider ->
|
||||
provider.addAllAnnotations(currentRawAnnotations, foundQualifiers, owner)
|
||||
@@ -24,7 +24,7 @@ internal class CompositeAdditionalAnnotationsProvider(val providers: List<Additi
|
||||
override fun findSpecialAnnotation(
|
||||
annotationsBox: GranularAnnotationsBox,
|
||||
qualifiedName: String,
|
||||
owner: PsiModifierList,
|
||||
owner: PsiElement,
|
||||
): PsiAnnotation? = providers.firstNotNullOfOrNull { provider -> provider.findSpecialAnnotation(annotationsBox, qualifiedName, owner) }
|
||||
|
||||
override fun isSpecialQualifier(qualifiedName: String): Boolean = providers.any { it.isSpecialQualifier(qualifiedName) }
|
||||
|
||||
+6
-6
@@ -1,22 +1,22 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.light.classes.symbol.annotations
|
||||
|
||||
import com.intellij.psi.PsiAnnotation
|
||||
import com.intellij.psi.PsiModifierList
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.light.classes.symbol.toArrayIfNotEmptyOrDefault
|
||||
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
|
||||
internal class ComputeAllAtOnceAnnotationsBox(
|
||||
private val annotationsComputer: (PsiModifierList) -> Collection<PsiAnnotation>,
|
||||
private val annotationsComputer: (PsiElement) -> Collection<PsiAnnotation>,
|
||||
) : AnnotationsBox {
|
||||
@Volatile
|
||||
private var cachedAnnotations: Collection<PsiAnnotation>? = null
|
||||
|
||||
private fun getOrComputeAnnotations(owner: PsiModifierList): Collection<PsiAnnotation> {
|
||||
private fun getOrComputeAnnotations(owner: PsiElement): Collection<PsiAnnotation> {
|
||||
cachedAnnotations?.let { return it }
|
||||
|
||||
val nonCachedAnnotations = annotationsComputer(owner)
|
||||
@@ -26,11 +26,11 @@ internal class ComputeAllAtOnceAnnotationsBox(
|
||||
}
|
||||
|
||||
override fun annotationsArray(
|
||||
owner: PsiModifierList,
|
||||
owner: PsiElement,
|
||||
): Array<PsiAnnotation> = getOrComputeAnnotations(owner).toArrayIfNotEmptyOrDefault(PsiAnnotation.EMPTY_ARRAY)
|
||||
|
||||
override fun findAnnotation(
|
||||
owner: PsiModifierList,
|
||||
owner: PsiElement,
|
||||
qualifiedName: String,
|
||||
): PsiAnnotation? = getOrComputeAnnotations(owner).find { it.qualifiedName == qualifiedName }
|
||||
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -7,14 +7,14 @@ package org.jetbrains.kotlin.light.classes.symbol.annotations
|
||||
|
||||
import com.intellij.psi.PsiAnnotation
|
||||
import com.intellij.psi.PsiDocCommentOwner
|
||||
import com.intellij.psi.PsiModifierList
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
||||
|
||||
internal object DeprecatedAdditionalAnnotationsProvider : AdditionalAnnotationsProvider {
|
||||
override fun addAllAnnotations(
|
||||
currentRawAnnotations: MutableList<in PsiAnnotation>,
|
||||
foundQualifiers: MutableSet<String>,
|
||||
owner: PsiModifierList
|
||||
owner: PsiElement
|
||||
) {
|
||||
if ((owner.parent as? PsiDocCommentOwner)?.isDeprecated == true) {
|
||||
addSimpleAnnotationIfMissing(JvmAnnotationNames.DEPRECATED_ANNOTATION.asString(), currentRawAnnotations, foundQualifiers, owner)
|
||||
@@ -26,7 +26,7 @@ internal object DeprecatedAdditionalAnnotationsProvider : AdditionalAnnotationsP
|
||||
override fun findSpecialAnnotation(
|
||||
annotationsBox: GranularAnnotationsBox,
|
||||
qualifiedName: String,
|
||||
owner: PsiModifierList
|
||||
owner: PsiElement
|
||||
): PsiAnnotation? = if ((owner.parent as? PsiDocCommentOwner)?.isDeprecated == true)
|
||||
createSimpleAnnotationIfMatches(
|
||||
qualifier = qualifiedName,
|
||||
|
||||
+4
-4
@@ -1,24 +1,24 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.light.classes.symbol.annotations
|
||||
|
||||
import com.intellij.psi.PsiAnnotation
|
||||
import com.intellij.psi.PsiModifierList
|
||||
import com.intellij.psi.PsiElement
|
||||
|
||||
internal object EmptyAdditionalAnnotationsProvider : AdditionalAnnotationsProvider {
|
||||
override fun addAllAnnotations(
|
||||
currentRawAnnotations: MutableList<in PsiAnnotation>,
|
||||
foundQualifiers: MutableSet<String>,
|
||||
owner: PsiModifierList,
|
||||
owner: PsiElement,
|
||||
) = Unit
|
||||
|
||||
override fun findSpecialAnnotation(
|
||||
annotationsBox: GranularAnnotationsBox,
|
||||
qualifiedName: String,
|
||||
owner: PsiModifierList,
|
||||
owner: PsiElement,
|
||||
): PsiAnnotation? = null
|
||||
|
||||
override fun isSpecialQualifier(qualifiedName: String): Boolean = false
|
||||
|
||||
+4
-4
@@ -1,14 +1,14 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.light.classes.symbol.annotations
|
||||
|
||||
import com.intellij.psi.PsiAnnotation
|
||||
import com.intellij.psi.PsiModifierList
|
||||
import com.intellij.psi.PsiElement
|
||||
|
||||
internal object EmptyAnnotationsBox : AnnotationsBox {
|
||||
override fun annotationsArray(owner: PsiModifierList): Array<PsiAnnotation> = PsiAnnotation.EMPTY_ARRAY
|
||||
override fun findAnnotation(owner: PsiModifierList, qualifiedName: String): PsiAnnotation? = null
|
||||
override fun annotationsArray(owner: PsiElement): Array<PsiAnnotation> = PsiAnnotation.EMPTY_ARRAY
|
||||
override fun findAnnotation(owner: PsiElement, qualifiedName: String): PsiAnnotation? = null
|
||||
}
|
||||
|
||||
+9
-9
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.light.classes.symbol.annotations
|
||||
|
||||
import com.intellij.psi.PsiAnnotation
|
||||
import com.intellij.psi.PsiModifierList
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.light.classes.symbol.toArrayIfNotEmptyOrDefault
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.JvmStandardClassIds
|
||||
@@ -22,7 +22,7 @@ internal class GranularAnnotationsBox(
|
||||
@Volatile
|
||||
private var cachedAnnotations: Collection<PsiAnnotation>? = null
|
||||
|
||||
private fun getOrComputeCachedAnnotations(owner: PsiModifierList): Collection<PsiAnnotation> {
|
||||
private fun getOrComputeCachedAnnotations(owner: PsiElement): Collection<PsiAnnotation> {
|
||||
cachedAnnotations?.let { return it }
|
||||
|
||||
val annotations = annotationsProvider.annotationInfos().mapNotNullTo(SmartList<PsiAnnotation>()) { applicationInfo ->
|
||||
@@ -40,16 +40,16 @@ internal class GranularAnnotationsBox(
|
||||
return getOrComputeCachedAnnotations(owner)
|
||||
}
|
||||
|
||||
override fun annotationsArray(owner: PsiModifierList): Array<PsiAnnotation> {
|
||||
override fun annotationsArray(owner: PsiElement): Array<PsiAnnotation> {
|
||||
return getOrComputeCachedAnnotations(owner).toArrayIfNotEmptyOrDefault(PsiAnnotation.EMPTY_ARRAY)
|
||||
}
|
||||
|
||||
override fun findAnnotation(
|
||||
owner: PsiModifierList,
|
||||
owner: PsiElement,
|
||||
qualifiedName: String,
|
||||
): PsiAnnotation? = findAnnotation(owner, qualifiedName, withAdditionalAnnotations = true)
|
||||
|
||||
fun findAnnotation(owner: PsiModifierList, qualifiedName: String, withAdditionalAnnotations: Boolean): PsiAnnotation? {
|
||||
fun findAnnotation(owner: PsiElement, qualifiedName: String, withAdditionalAnnotations: Boolean): PsiAnnotation? {
|
||||
if (!annotationFilter.isAllowed(qualifiedName)) return null
|
||||
|
||||
cachedAnnotations?.let { annotations ->
|
||||
@@ -68,7 +68,7 @@ internal class GranularAnnotationsBox(
|
||||
return getOrComputeCachedAnnotations(owner).find { it.qualifiedName == qualifiedName }
|
||||
}
|
||||
|
||||
override fun hasAnnotation(owner: PsiModifierList, qualifiedName: String): Boolean {
|
||||
override fun hasAnnotation(owner: PsiElement, qualifiedName: String): Boolean {
|
||||
if (!annotationFilter.isAllowed(qualifiedName)) return false
|
||||
|
||||
cachedAnnotations?.let { annotations ->
|
||||
@@ -93,14 +93,14 @@ internal class GranularAnnotationsBox(
|
||||
/**
|
||||
* We can safety reduce resolve only for annotations without arguments
|
||||
*
|
||||
* @see org.jetbrains.kotlin.fir.resolve.transformers.plugin.CompilerRequiredAnnotationsHelper
|
||||
* @see org.jetbrains.kotlin.fir.declarations.FirAnnotationsPlatformSpecificSupportComponent
|
||||
*/
|
||||
private val specialAnnotationsListWithSafeArgumentsResolve: Map<String, ClassId> = listOf(
|
||||
JvmStandardClassIds.Annotations.JvmRecord,
|
||||
).associateBy { it.asFqNameString() }
|
||||
|
||||
/**
|
||||
* @see org.jetbrains.kotlin.fir.resolve.transformers.plugin.CompilerRequiredAnnotationsHelper
|
||||
* @see org.jetbrains.kotlin.fir.declarations.FirAnnotationsPlatformSpecificSupportComponent
|
||||
*/
|
||||
private val specialAnnotationsList: Map<String, ClassId> = listOf(
|
||||
StandardClassIds.Annotations.Deprecated,
|
||||
|
||||
+3
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.light.classes.symbol.annotations
|
||||
|
||||
import com.intellij.psi.PsiAnnotation
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiModifierList
|
||||
import org.jetbrains.kotlin.light.classes.symbol.methods.SymbolLightMethodBase
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
||||
|
||||
@@ -15,7 +14,7 @@ internal object MethodAdditionalAnnotationsProvider : AdditionalAnnotationsProvi
|
||||
override fun addAllAnnotations(
|
||||
currentRawAnnotations: MutableList<in PsiAnnotation>,
|
||||
foundQualifiers: MutableSet<String>,
|
||||
owner: PsiModifierList,
|
||||
owner: PsiElement,
|
||||
) {
|
||||
if (owner.parent.isMethodWithOverride()) {
|
||||
addSimpleAnnotationIfMissing(JvmAnnotationNames.OVERRIDE_ANNOTATION.asString(), currentRawAnnotations, foundQualifiers, owner)
|
||||
@@ -25,7 +24,7 @@ internal object MethodAdditionalAnnotationsProvider : AdditionalAnnotationsProvi
|
||||
override fun findSpecialAnnotation(
|
||||
annotationsBox: GranularAnnotationsBox,
|
||||
qualifiedName: String,
|
||||
owner: PsiModifierList,
|
||||
owner: PsiElement,
|
||||
): PsiAnnotation? = if (owner.parent.isMethodWithOverride())
|
||||
createSimpleAnnotationIfMatches(
|
||||
qualifier = qualifiedName,
|
||||
|
||||
+4
-4
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.light.classes.symbol.annotations
|
||||
|
||||
import com.intellij.psi.PsiAnnotation
|
||||
import com.intellij.psi.PsiModifierList
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.asJava.classes.lazyPub
|
||||
import org.jetbrains.kotlin.light.classes.symbol.NullabilityType
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
||||
@@ -17,7 +17,7 @@ internal class NullabilityAnnotationsProvider(private val lazyNullabilityType: L
|
||||
override fun addAllAnnotations(
|
||||
currentRawAnnotations: MutableList<in PsiAnnotation>,
|
||||
foundQualifiers: MutableSet<String>,
|
||||
owner: PsiModifierList
|
||||
owner: PsiElement
|
||||
) {
|
||||
val qualifier = lazyNullabilityType.qualifier ?: return
|
||||
addSimpleAnnotationIfMissing(qualifier, currentRawAnnotations, foundQualifiers, owner)
|
||||
@@ -26,7 +26,7 @@ internal class NullabilityAnnotationsProvider(private val lazyNullabilityType: L
|
||||
override fun findSpecialAnnotation(
|
||||
annotationsBox: GranularAnnotationsBox,
|
||||
qualifiedName: String,
|
||||
owner: PsiModifierList,
|
||||
owner: PsiElement,
|
||||
): PsiAnnotation? {
|
||||
if (!qualifiedName.isNullOrNotNullQualifiedName) {
|
||||
return null
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@
|
||||
package org.jetbrains.kotlin.light.classes.symbol.annotations
|
||||
|
||||
import com.intellij.psi.PsiAnnotationParameterList
|
||||
import com.intellij.psi.PsiModifierList
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.analysis.api.annotations.KtNamedAnnotationValue
|
||||
import org.jetbrains.kotlin.asJava.classes.lazyPub
|
||||
import org.jetbrains.kotlin.psi.KtCallElement
|
||||
@@ -14,7 +14,7 @@ import org.jetbrains.kotlin.psi.KtCallElement
|
||||
internal open class SymbolLightJavaAnnotation(
|
||||
val originalLightAnnotation: SymbolLightLazyAnnotation,
|
||||
private val javaQualifier: String,
|
||||
owner: PsiModifierList,
|
||||
owner: PsiElement,
|
||||
private val argumentsComputer: SymbolLightJavaAnnotation.() -> List<KtNamedAnnotationValue>,
|
||||
) : SymbolLightAbstractAnnotation(owner) {
|
||||
override fun createReferenceInformationProvider(): ReferenceInformationProvider = ReferenceInformationHolder(
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@
|
||||
package org.jetbrains.kotlin.light.classes.symbol.annotations
|
||||
|
||||
import com.intellij.psi.PsiAnnotationParameterList
|
||||
import com.intellij.psi.PsiModifierList
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.analysis.api.annotations.KtAnnotationApplication
|
||||
import org.jetbrains.kotlin.analysis.api.annotations.KtAnnotationApplicationWithArgumentsInfo
|
||||
import org.jetbrains.kotlin.asJava.classes.lazyPub
|
||||
@@ -18,7 +18,7 @@ import org.jetbrains.kotlin.psi.KtCallElement
|
||||
internal class SymbolLightLazyAnnotation(
|
||||
val annotationsProvider: AnnotationsProvider,
|
||||
private val annotationApplication: KtAnnotationApplication,
|
||||
owner: PsiModifierList,
|
||||
owner: PsiElement,
|
||||
) : SymbolLightAbstractAnnotation(owner) {
|
||||
init {
|
||||
requireNotNull(annotationApplication.classId)
|
||||
|
||||
Reference in New Issue
Block a user