[LL FIR] FirElementBuilder: support KtAnnotation in file annotations
^KT-65780
This commit is contained in:
committed by
Space Team
parent
ba92fc97f9
commit
16878ca20d
+3
-3
@@ -159,10 +159,10 @@ internal class FirElementBuilder(private val moduleComponents: LLFirModuleResolv
|
|||||||
return findElementInside(firElement = anchorFir, element = element, stopAt = anchorElement)
|
return findElementInside(firElement = anchorFir, element = element, stopAt = anchorElement)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun KtAnnotationEntry.owner(): KtAnnotated? {
|
private fun PsiElement.annotationOwner(): KtAnnotated? {
|
||||||
val modifierList = when (val parent = parent) {
|
val modifierList = when (val parent = parent) {
|
||||||
is KtModifierList -> parent
|
is KtModifierList -> parent
|
||||||
is KtAnnotation -> parent.parent as? KtModifierList
|
is KtAnnotation -> return parent.annotationOwner()
|
||||||
is KtFileAnnotationList -> return parent.parent as? KtFile
|
is KtFileAnnotationList -> return parent.parent as? KtFile
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
@@ -175,7 +175,7 @@ internal class FirElementBuilder(private val moduleComponents: LLFirModuleResolv
|
|||||||
): FirElement? = getFirForNonBodyElement<KtAnnotationEntry, KtAnnotated>(
|
): FirElement? = getFirForNonBodyElement<KtAnnotationEntry, KtAnnotated>(
|
||||||
element = element,
|
element = element,
|
||||||
anchorElementProvider = { it.parentOfType<KtAnnotationEntry>(withSelf = true) },
|
anchorElementProvider = { it.parentOfType<KtAnnotationEntry>(withSelf = true) },
|
||||||
elementOwnerProvider = { it.owner() },
|
elementOwnerProvider = { it.annotationOwner() },
|
||||||
resolveAndFindFirForAnchor = { declaration, anchor -> declaration.resolveAndFindAnnotation(anchor, goDeep = true) },
|
resolveAndFindFirForAnchor = { declaration, anchor -> declaration.resolveAndFindAnnotation(anchor, goDeep = true) },
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -6,5 +6,5 @@ FIR element rendered:
|
|||||||
@FILE:R|kotlin/Suppress|[Types](names = vararg(String()))
|
@FILE:R|kotlin/Suppress|[Types](names = vararg(String()))
|
||||||
|
|
||||||
FIR FILE:
|
FIR FILE:
|
||||||
FILE: [ResolvedTo(BODY_RESOLVE)] fileAnnotation2.kt
|
FILE: [ResolvedTo(ANNOTATION_ARGUMENTS)] fileAnnotation2.kt
|
||||||
@FILE:R|kotlin/Suppress|[Types](names = vararg(String()))
|
@FILE:R|kotlin/Suppress|[Types](names = vararg(String()))
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ FIR element rendered:
|
|||||||
@FILE:R|kotlin/Suppress|[Types](names = vararg(String()))
|
@FILE:R|kotlin/Suppress|[Types](names = vararg(String()))
|
||||||
|
|
||||||
FIR FILE:
|
FIR FILE:
|
||||||
FILE: [ResolvedTo(BODY_RESOLVE)] fileAnnotation2Script.kts
|
FILE: [ResolvedTo(ANNOTATION_ARGUMENTS)] fileAnnotation2Script.kts
|
||||||
@FILE:R|kotlin/Suppress|[Types](names = vararg(String()))
|
@FILE:R|kotlin/Suppress|[Types](names = vararg(String()))
|
||||||
context(<script>@kotlin.script.templates.standard.ScriptTemplateWithArgs)
|
context(<script>@kotlin.script.templates.standard.ScriptTemplateWithArgs)
|
||||||
SCRIPT: [ResolvedTo(RAW_FIR)] <script-fileAnnotation2Script.kts>
|
SCRIPT: [ResolvedTo(RAW_FIR)] <script-fileAnnotation2Script.kts>
|
||||||
|
|||||||
Reference in New Issue
Block a user