[FIR] Split FirAnnotation into FirAnnotation and FirAnnotationCall

FirAnnotation represents simple annotation placed on some element.
  This element contains only annotation type ref and simple argument
  mapping

FirAnnotationCall is a element for call of annotation (`@Ann(args)`)
  which was written in user code. FirAnnotationCall is a resolvable call
This commit is contained in:
Dmitriy Novozhilov
2021-09-07 12:35:18 +03:00
committed by teamcityserver
parent 52e339593e
commit 31a7d8d5a4
17 changed files with 399 additions and 62 deletions
@@ -108,13 +108,14 @@ object BuilderConfigurator : AbstractBuilderConfigurator<FirTreeBuilder>(FirTree
withCopy()
}
builder(annotation) {
builder(annotationCall) {
parents += callBuilder
default("argumentList") {
value = "FirEmptyArgumentList"
}
default("resolveStatus", "FirAnnotationResolveStatus.Unresolved")
useTypes(emptyArgumentListType)
default("argumentMapping", "FirEmptyAnnotationArgumentMapping")
default("annotationTypeRef", "FirImplicitTypeRefImpl(null)")
useTypes(emptyArgumentListType, emptyAnnotationArgumentMappingType, implicitTypeRefType)
}
builder(arrayOfCall) {
@@ -89,7 +89,9 @@ object FirTreeBuilder : AbstractFirTreeBuilder() {
val typeProjectionWithVariance by element(TypeRef, typeProjection)
val argumentList by element(Expression)
val call by sealedElement(Expression, statement) // TODO: may smth like `CallWithArguments` or `ElementWithArguments`?
val annotation by element(Expression, expression, call, resolvable)
val annotation by element(Expression, expression)
val annotationCall by element(Expression, annotation, call, resolvable)
val annotationArgumentMapping by element(Expression)
val comparisonExpression by element(Expression, expression)
val typeOperatorCall by element(Expression, expression, call)
val assignmentOperatorStatement by element(Expression, statement)
@@ -73,13 +73,25 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
delegateFields(listOf("aliasName", "importedFqName", "isAllUnder", "source"), "delegate")
}
impl(annotation) {
fun ImplementationContext.commonAnnotationConfig(): Unit {
defaultEmptyList("annotations")
default("typeRef") {
value = "annotationTypeRef"
withGetter = true
}
}
impl(annotation) {
commonAnnotationConfig()
}
impl(annotationCall) {
commonAnnotationConfig()
default("argumentMapping") {
needAcceptAndTransform = false
}
}
impl(arrayOfCall)
impl(callableReferenceAccess)
@@ -501,6 +513,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
}
noImpl(argumentList)
noImpl(annotationArgumentMapping)
val implementationsWithoutStatusAndTypeParameters = listOf(
"FirAnonymousFunctionImpl",
@@ -447,7 +447,15 @@ object NodeConfigurator : AbstractFieldConfigurator<FirTreeBuilder>(FirTreeBuild
annotation.configure {
+field("useSiteTarget", annotationUseSiteTargetType, nullable = true)
+field("annotationTypeRef", typeRef).withTransform()
+field("resolveStatus", annotationResolveStatusType, withReplace = true)
+field("argumentMapping", annotationArgumentMapping, withReplace = true)
}
annotationCall.configure {
+field("argumentMapping", annotationArgumentMapping, withReplace = true)
}
annotationArgumentMapping.configure {
+field("mapping", type("Map") to listOf(nameType, expression))
}
augmentedArraySetCall.configure {
@@ -83,7 +83,6 @@ val dslBuilderAnnotationType = generatedType("builder", "FirBuilderDsl")
val firImplementationDetailType = generatedType("FirImplementationDetail")
val declarationOriginType = generatedType("declarations", "FirDeclarationOrigin")
val declarationAttributesType = generatedType("declarations", "FirDeclarationAttributes")
val annotationResolveStatusType = generatedType("expressions", "FirAnnotationResolveStatus")
val exhaustivenessStatusType = generatedType("expressions", "ExhaustivenessStatus")
@@ -94,6 +93,7 @@ val functionCallOrigin = type("fir.expressions", "FirFunctionCallOrigin")
val resolvedDeclarationStatusImplType = type("fir.declarations.impl", "FirResolvedDeclarationStatusImpl")
val deprecationsPerUseSiteType = type("fir.declarations", "DeprecationsPerUseSite")
val emptyAnnotationArgumentMappingType = type("fir.expressions.impl", "FirEmptyAnnotationArgumentMapping")
val firPropertySymbolType = type("fir.symbols.impl", "FirPropertySymbol")