[SLC] introduce SymbolLightEmptyAnnotationParameterList
^KT-56046
This commit is contained in:
committed by
Space Team
parent
aa9e7444c9
commit
48ed72c391
+29
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2023 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.PsiAnnotationParameterList
|
||||||
|
import org.jetbrains.kotlin.analysis.api.annotations.KtNamedAnnotationValue
|
||||||
|
import org.jetbrains.kotlin.asJava.elements.KtLightElementBase
|
||||||
|
import org.jetbrains.kotlin.psi.KtElement
|
||||||
|
|
||||||
|
internal sealed class SymbolLightAbstractAnnotationParameterList(
|
||||||
|
parent: SymbolLightAbstractAnnotation,
|
||||||
|
) : KtLightElementBase(parent), PsiAnnotationParameterList {
|
||||||
|
override val kotlinOrigin: KtElement?
|
||||||
|
get() = (parent as SymbolLightAbstractAnnotation).kotlinOrigin?.valueArgumentList
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean = other === this || other is SymbolLightLazyAnnotationParameterList && other.parent == parent
|
||||||
|
override fun hashCode(): Int = parent.hashCode()
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun SymbolLightAbstractAnnotation.symbolLightAnnotationParameterList(
|
||||||
|
arguments: List<KtNamedAnnotationValue> = emptyList(),
|
||||||
|
): SymbolLightAbstractAnnotationParameterList = if (arguments.isNotEmpty()) {
|
||||||
|
SymbolLightLazyAnnotationParameterList(this, lazyOf(arguments))
|
||||||
|
} else {
|
||||||
|
SymbolLightEmptyAnnotationParameterList(this)
|
||||||
|
}
|
||||||
+1
-1
@@ -19,7 +19,7 @@ internal class SymbolLightAnnotationForAnnotationCall(
|
|||||||
parent: PsiModifierList,
|
parent: PsiModifierList,
|
||||||
) : SymbolLightAbstractAnnotation(parent) {
|
) : SymbolLightAbstractAnnotation(parent) {
|
||||||
private val _parameterList: PsiAnnotationParameterList by lazyPub {
|
private val _parameterList: PsiAnnotationParameterList by lazyPub {
|
||||||
SymbolLightLazyAnnotationParameterList(this, lazyOf(annotationCall.arguments))
|
symbolLightAnnotationParameterList(annotationCall.arguments)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getParameterList(): PsiAnnotationParameterList = _parameterList
|
override fun getParameterList(): PsiAnnotationParameterList = _parameterList
|
||||||
|
|||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2023 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.PsiNameValuePair
|
||||||
|
|
||||||
|
internal class SymbolLightEmptyAnnotationParameterList(
|
||||||
|
parent: SymbolLightAbstractAnnotation,
|
||||||
|
) : SymbolLightAbstractAnnotationParameterList(parent) {
|
||||||
|
override fun getAttributes(): Array<PsiNameValuePair> = PsiNameValuePair.EMPTY_ARRAY
|
||||||
|
}
|
||||||
+5
-1
@@ -64,7 +64,11 @@ internal class SymbolLightLazyAnnotation private constructor(
|
|||||||
override fun getQualifiedName(): String = fqName.asString()
|
override fun getQualifiedName(): String = fqName.asString()
|
||||||
|
|
||||||
private val _parameterList: PsiAnnotationParameterList by lazyPub {
|
private val _parameterList: PsiAnnotationParameterList by lazyPub {
|
||||||
SymbolLightLazyAnnotationParameterList(this, lazyPub { annotationApplication.value.arguments })
|
if (annotationOverview?.hasArguments == true || !specialAnnotationApplication?.arguments.isNullOrEmpty()) {
|
||||||
|
SymbolLightLazyAnnotationParameterList(this, lazyPub { annotationApplication.value.arguments })
|
||||||
|
} else {
|
||||||
|
SymbolLightEmptyAnnotationParameterList(this)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getParameterList(): PsiAnnotationParameterList = _parameterList
|
override fun getParameterList(): PsiAnnotationParameterList = _parameterList
|
||||||
|
|||||||
+1
-11
@@ -5,21 +5,14 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.light.classes.symbol.annotations
|
package org.jetbrains.kotlin.light.classes.symbol.annotations
|
||||||
|
|
||||||
import com.intellij.psi.PsiAnnotationParameterList
|
|
||||||
import com.intellij.psi.PsiNameValuePair
|
import com.intellij.psi.PsiNameValuePair
|
||||||
import org.jetbrains.kotlin.analysis.api.annotations.KtNamedAnnotationValue
|
import org.jetbrains.kotlin.analysis.api.annotations.KtNamedAnnotationValue
|
||||||
import org.jetbrains.kotlin.asJava.classes.lazyPub
|
import org.jetbrains.kotlin.asJava.classes.lazyPub
|
||||||
import org.jetbrains.kotlin.asJava.elements.KtLightElementBase
|
|
||||||
import org.jetbrains.kotlin.psi.KtElement
|
|
||||||
|
|
||||||
internal class SymbolLightLazyAnnotationParameterList(
|
internal class SymbolLightLazyAnnotationParameterList(
|
||||||
parent: SymbolLightAbstractAnnotation,
|
parent: SymbolLightAbstractAnnotation,
|
||||||
private val lazyArguments: Lazy<List<KtNamedAnnotationValue>>,
|
private val lazyArguments: Lazy<List<KtNamedAnnotationValue>>,
|
||||||
) : KtLightElementBase(parent),
|
) : SymbolLightAbstractAnnotationParameterList(parent) {
|
||||||
PsiAnnotationParameterList {
|
|
||||||
override val kotlinOrigin: KtElement?
|
|
||||||
get() = (parent as SymbolLightAbstractAnnotation).kotlinOrigin?.valueArgumentList
|
|
||||||
|
|
||||||
private val _attributes: Array<PsiNameValuePair> by lazyPub {
|
private val _attributes: Array<PsiNameValuePair> by lazyPub {
|
||||||
val attributes = lazyArguments.value.map {
|
val attributes = lazyArguments.value.map {
|
||||||
SymbolNameValuePairForAnnotationArgument(it, this)
|
SymbolNameValuePairForAnnotationArgument(it, this)
|
||||||
@@ -29,7 +22,4 @@ internal class SymbolLightLazyAnnotationParameterList(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getAttributes(): Array<PsiNameValuePair> = _attributes
|
override fun getAttributes(): Array<PsiNameValuePair> = _attributes
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean = other === this || other is SymbolLightLazyAnnotationParameterList && other.parent == parent
|
|
||||||
override fun hashCode(): Int = parent.hashCode()
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -29,9 +29,8 @@ internal class SymbolLightSimpleAnnotation(
|
|||||||
override fun hashCode(): Int = fqName.hashCode()
|
override fun hashCode(): Int = fqName.hashCode()
|
||||||
|
|
||||||
private val _parameterList: PsiAnnotationParameterList by lazyPub {
|
private val _parameterList: PsiAnnotationParameterList by lazyPub {
|
||||||
SymbolLightLazyAnnotationParameterList(this, lazyOf(arguments))
|
symbolLightAnnotationParameterList(arguments)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getParameterList(): PsiAnnotationParameterList = _parameterList
|
override fun getParameterList(): PsiAnnotationParameterList = _parameterList
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user