[FIR] Remove AllOpen prefixes from fir plugin prototype entities
This commit is contained in:
committed by
TeamCityServer
parent
b4d955838e
commit
7f836ee6c3
+1
-1
@@ -40,5 +40,5 @@ class AllOpenStatusTransformer(session: FirSession) : FirStatusTransformerExtens
|
||||
}
|
||||
|
||||
override val key: FirPluginKey
|
||||
get() = AllOpenPluginKey
|
||||
get() = SomePluginKey
|
||||
}
|
||||
|
||||
+2
-2
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
class AllOpenVisibilityTransformer(session: FirSession) : FirStatusTransformerExtension(session) {
|
||||
class AllPublicVisibilityTransformer(session: FirSession) : FirStatusTransformerExtension(session) {
|
||||
companion object {
|
||||
private val AllPublicClassId = ClassId(FqName("org.jetbrains.kotlin.fir.plugin"), Name.identifier("AllPublic"))
|
||||
private val VisibilityClassId = ClassId(FqName("org.jetbrains.kotlin.fir.plugin"), Name.identifier("Visibility"))
|
||||
@@ -81,5 +81,5 @@ class AllOpenVisibilityTransformer(session: FirSession) : FirStatusTransformerEx
|
||||
}
|
||||
|
||||
override val key: FirPluginKey
|
||||
get() = AllOpenPluginKey
|
||||
get() = SomePluginKey
|
||||
}
|
||||
+6
-6
@@ -12,14 +12,14 @@ import org.jetbrains.kotlin.fir.plugin.types.FirNumberSignAttributeExtension
|
||||
class FirAllOpenComponentRegistrar : FirExtensionRegistrar() {
|
||||
override fun ExtensionRegistrarContext.configurePlugin() {
|
||||
+::AllOpenStatusTransformer
|
||||
+::AllOpenVisibilityTransformer
|
||||
+::AllOpenSupertypeGenerator
|
||||
+::AllOpenAdditionalCheckers
|
||||
+::AllPublicVisibilityTransformer
|
||||
+::SomeAdditionalSupertypeGenerator
|
||||
+::PluginAdditionalCheckers
|
||||
+::FirNumberSignAttributeExtension
|
||||
|
||||
// Declaration generators
|
||||
+::AllOpenTopLevelDeclarationsGenerator
|
||||
+::AllOpenClassGenerator
|
||||
+::AllOpenMembersGenerator
|
||||
+::TopLevelDeclarationsGenerator
|
||||
+::ExternalClassGenerator
|
||||
+::AdditionalMembersGenerator
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -15,9 +15,9 @@ import org.jetbrains.kotlin.fir.declarations.FirPluginKey
|
||||
import org.jetbrains.kotlin.fir.plugin.checkers.DummyNameChecker
|
||||
import org.jetbrains.kotlin.fir.plugin.checkers.SignedNumberCallChecker
|
||||
|
||||
class AllOpenAdditionalCheckers(session: FirSession) : FirAdditionalCheckersExtension(session) {
|
||||
class PluginAdditionalCheckers(session: FirSession) : FirAdditionalCheckersExtension(session) {
|
||||
override val key: FirPluginKey
|
||||
get() = AllOpenPluginKey
|
||||
get() = SomePluginKey
|
||||
|
||||
override val declarationCheckers: DeclarationCheckers = object : DeclarationCheckers() {
|
||||
override val simpleFunctionCheckers: Set<FirSimpleFunctionChecker>
|
||||
+2
-2
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.name.Name
|
||||
/*
|
||||
* Adds MyInterface supertype for all classes annotated with @D
|
||||
*/
|
||||
class AllOpenSupertypeGenerator(session: FirSession) : FirSupertypeGenerationExtension(session) {
|
||||
class SomeAdditionalSupertypeGenerator(session: FirSession) : FirSupertypeGenerationExtension(session) {
|
||||
companion object {
|
||||
private val myInterfaceClassId = ClassId(FqName("foo"), Name.identifier("MyInterface"))
|
||||
private val PREDICATE: DeclarationPredicate = has("D".fqn())
|
||||
@@ -44,7 +44,7 @@ class AllOpenSupertypeGenerator(session: FirSession) : FirSupertypeGenerationExt
|
||||
}
|
||||
|
||||
override val key: FirPluginKey
|
||||
get() = AllOpenPluginKey
|
||||
get() = SomePluginKey
|
||||
|
||||
override fun needTransformSupertypes(declaration: FirClassLikeDeclaration): Boolean {
|
||||
return session.predicateBasedProvider.matches(PREDICATE, declaration)
|
||||
+1
-1
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.fir.plugin
|
||||
|
||||
import org.jetbrains.kotlin.fir.declarations.FirPluginKey
|
||||
|
||||
object AllOpenPluginKey : FirPluginKey() {
|
||||
object SomePluginKey : FirPluginKey() {
|
||||
override fun toString(): String {
|
||||
return "AllOpenPlugin"
|
||||
}
|
||||
+1
-2
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.fir.plugin.checkers
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirSimpleFunctionChecker
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.reportOn
|
||||
import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction
|
||||
|
||||
@@ -16,7 +15,7 @@ object DummyNameChecker : FirSimpleFunctionChecker() {
|
||||
override fun check(declaration: FirSimpleFunction, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
val name = declaration.name.asString()
|
||||
if (name == "dummy") {
|
||||
reporter.reportOn(declaration.source, AllOpenErrors.FUNCTION_WITH_DUMMY_NAME, name, context)
|
||||
reporter.reportOn(declaration.source, PluginErrors.FUNCTION_WITH_DUMMY_NAME, name, context)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.SourceElementPositioningStr
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.error2
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.warning1
|
||||
|
||||
object AllOpenErrors {
|
||||
object PluginErrors {
|
||||
val FUNCTION_WITH_DUMMY_NAME by warning1<PsiElement, String>(SourceElementPositioningStrategies.DECLARATION_NAME)
|
||||
val ILLEGAL_NUMBER_SIGN by error2<PsiElement, String, String>()
|
||||
}
|
||||
+1
-1
@@ -26,7 +26,7 @@ object SignedNumberCallChecker : FirFunctionCallChecker() {
|
||||
val actualSign = argument.typeRef.coneType.attributes.numberSign
|
||||
if (expectedSign != actualSign) {
|
||||
withSuppressedDiagnostics(argument, context) {
|
||||
reporter.reportOn(argument.source, AllOpenErrors.ILLEGAL_NUMBER_SIGN, expectedSign.asString(), actualSign.asString(), it)
|
||||
reporter.reportOn(argument.source, PluginErrors.ILLEGAL_NUMBER_SIGN, expectedSign.asString(), actualSign.asString(), it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ import org.jetbrains.kotlin.name.Name
|
||||
* - member fun materialize(): ClassName
|
||||
* - nested class Nested with default constructor
|
||||
*/
|
||||
class AllOpenMembersGenerator(session: FirSession) : FirDeclarationGenerationExtension(session) {
|
||||
class AdditionalMembersGenerator(session: FirSession) : FirDeclarationGenerationExtension(session) {
|
||||
companion object {
|
||||
private val MATERIALIZE_NAME = Name.identifier("materialize")
|
||||
private val NESTED_NAME = Name.identifier("Nested")
|
||||
+1
-1
@@ -38,7 +38,7 @@ import org.jetbrains.kotlin.name.Name
|
||||
*
|
||||
* If there are no annotated classes then AllOpenGenerated class is not generated
|
||||
*/
|
||||
class AllOpenClassGenerator(session: FirSession) : FirDeclarationGenerationExtension(session) {
|
||||
class ExternalClassGenerator(session: FirSession) : FirDeclarationGenerationExtension(session) {
|
||||
companion object {
|
||||
private val FOO_PACKAGE = FqName.topLevel(Name.identifier("foo"))
|
||||
private val GENERATED_CLASS_ID = ClassId(FOO_PACKAGE, Name.identifier("AllOpenGenerated"))
|
||||
+4
-4
@@ -19,7 +19,7 @@ import org.jetbrains.kotlin.fir.extensions.predicate.DeclarationPredicate
|
||||
import org.jetbrains.kotlin.fir.extensions.predicate.has
|
||||
import org.jetbrains.kotlin.fir.extensions.predicateBasedProvider
|
||||
import org.jetbrains.kotlin.fir.moduleData
|
||||
import org.jetbrains.kotlin.fir.plugin.AllOpenPluginKey
|
||||
import org.jetbrains.kotlin.fir.plugin.SomePluginKey
|
||||
import org.jetbrains.kotlin.fir.plugin.fqn
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
|
||||
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.name.Name
|
||||
/*
|
||||
* Generates `dummyClassName(value: ClassName): String` function for each class annotated with @A
|
||||
*/
|
||||
class AllOpenTopLevelDeclarationsGenerator(session: FirSession) : FirDeclarationGenerationExtension(session) {
|
||||
class TopLevelDeclarationsGenerator(session: FirSession) : FirDeclarationGenerationExtension(session) {
|
||||
companion object {
|
||||
private val PREDICATE: DeclarationPredicate = has("A".fqn())
|
||||
}
|
||||
@@ -90,8 +90,8 @@ class AllOpenTopLevelDeclarationsGenerator(session: FirSession) : FirDeclaration
|
||||
}
|
||||
}
|
||||
|
||||
override val key: AllOpenPluginKey
|
||||
get() = AllOpenPluginKey
|
||||
override val key: SomePluginKey
|
||||
get() = SomePluginKey
|
||||
|
||||
override fun needToGenerateAdditionalMembersInClass(klass: FirClass): Boolean {
|
||||
return false
|
||||
+2
-2
@@ -11,7 +11,7 @@ import org.jetbrains.kotlin.fir.expressions.FirAnnotation
|
||||
import org.jetbrains.kotlin.fir.expressions.builder.buildAnnotation
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirEmptyAnnotationArgumentMapping
|
||||
import org.jetbrains.kotlin.fir.extensions.FirTypeAttributeExtension
|
||||
import org.jetbrains.kotlin.fir.plugin.AllOpenPluginKey
|
||||
import org.jetbrains.kotlin.fir.plugin.SomePluginKey
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl
|
||||
import org.jetbrains.kotlin.fir.types.ConeAttribute
|
||||
import org.jetbrains.kotlin.fir.types.ConeClassLikeType
|
||||
@@ -31,7 +31,7 @@ class FirNumberSignAttributeExtension(session: FirSession) : FirTypeAttributeExt
|
||||
}
|
||||
|
||||
override val key: FirPluginKey
|
||||
get() = AllOpenPluginKey
|
||||
get() = SomePluginKey
|
||||
|
||||
override fun extractAttributeFromAnnotation(annotation: FirAnnotation): ConeAttribute<*>? {
|
||||
val sign = when (annotation.annotationTypeRef.coneTypeSafe<ConeClassLikeType>()?.classId) {
|
||||
|
||||
+3
-3
@@ -8,7 +8,7 @@ package org.jetbrains.kotlin.ir.plugin
|
||||
import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension
|
||||
import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
|
||||
import org.jetbrains.kotlin.fir.backend.IrPluginDeclarationOrigin
|
||||
import org.jetbrains.kotlin.fir.plugin.generators.AllOpenClassGenerator
|
||||
import org.jetbrains.kotlin.fir.plugin.generators.ExternalClassGenerator
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrConstructorCallImpl
|
||||
@@ -41,7 +41,7 @@ private class Transformer(val context: IrPluginContext) : IrElementVisitorVoid {
|
||||
|
||||
override fun visitSimpleFunction(declaration: IrSimpleFunction) {
|
||||
val origin = declaration.origin
|
||||
if (origin !is IrPluginDeclarationOrigin || origin.pluginKey != AllOpenClassGenerator.Key) return
|
||||
if (origin !is IrPluginDeclarationOrigin || origin.pluginKey != ExternalClassGenerator.Key) return
|
||||
require(declaration.body == null)
|
||||
val constructedType = declaration.returnType as? IrSimpleType ?: return
|
||||
val constructedClassSymbol = constructedType.classifier
|
||||
@@ -62,7 +62,7 @@ private class Transformer(val context: IrPluginContext) : IrElementVisitorVoid {
|
||||
|
||||
override fun visitConstructor(declaration: IrConstructor) {
|
||||
val origin = declaration.origin
|
||||
if (origin !is IrPluginDeclarationOrigin || origin.pluginKey != AllOpenClassGenerator.Key) return
|
||||
if (origin !is IrPluginDeclarationOrigin || origin.pluginKey != ExternalClassGenerator.Key) return
|
||||
require(declaration.body == null)
|
||||
val type = declaration.returnType as? IrSimpleType ?: return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user