diff --git a/README.md b/README.md index 0e40199f..9f8a18e0 100644 --- a/README.md +++ b/README.md @@ -27,10 +27,6 @@ dependencies { ## React -#### Props - -Seskar checks if interfaces that inherit from the `Props` interface are external. - #### Dependencies When a project uses the Kotlin/JS IR compiler, `value classes` are autoboxed. If a `value class` is used as a dependency diff --git a/seskar/seskar-compiler-plugin/src/main/kotlin/seskar/compiler/props/backend/Props.kt b/seskar/seskar-compiler-plugin/src/main/kotlin/seskar/compiler/props/backend/Props.kt deleted file mode 100644 index c9cde973..00000000 --- a/seskar/seskar-compiler-plugin/src/main/kotlin/seskar/compiler/props/backend/Props.kt +++ /dev/null @@ -1,28 +0,0 @@ -package seskar.compiler.props.backend - -import org.jetbrains.kotlin.descriptors.ClassDescriptor -import org.jetbrains.kotlin.name.FqName -import org.jetbrains.kotlin.name.Name.identifier -import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe -import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperInterfaces - -private val REACT_PACKAGE_ID = identifier("react") -private val REACT_PACKAGE = FqName(REACT_PACKAGE_ID.identifier) -private val PROPS = REACT_PACKAGE.child(identifier("Props")) - -private val ClassDescriptor.isProps: Boolean - get() = isExternal && fqNameSafe == PROPS - -internal val ClassDescriptor.implementsPropsDirectly: Boolean - get() = getSuperInterfaces() - .any { it.isProps } - -internal val ClassDescriptor.implementsProps: Boolean - get() { - if (implementsPropsDirectly) { - return true - } - - return getSuperInterfaces() - .any { it.implementsProps } - } diff --git a/seskar/seskar-compiler-plugin/src/main/kotlin/seskar/compiler/props/backend/PropsDeclarationChecker.kt b/seskar/seskar-compiler-plugin/src/main/kotlin/seskar/compiler/props/backend/PropsDeclarationChecker.kt deleted file mode 100644 index 0f044560..00000000 --- a/seskar/seskar-compiler-plugin/src/main/kotlin/seskar/compiler/props/backend/PropsDeclarationChecker.kt +++ /dev/null @@ -1,27 +0,0 @@ -package seskar.compiler.props.backend - -import org.jetbrains.kotlin.descriptors.ClassDescriptor -import org.jetbrains.kotlin.descriptors.ClassKind -import org.jetbrains.kotlin.descriptors.DeclarationDescriptor -import org.jetbrains.kotlin.psi.KtClassOrObject -import org.jetbrains.kotlin.psi.KtDeclaration -import org.jetbrains.kotlin.resolve.checkers.DeclarationChecker -import org.jetbrains.kotlin.resolve.checkers.DeclarationCheckerContext -import org.jetbrains.kotlin.resolve.descriptorUtil.isEffectivelyExternal -import seskar.compiler.props.diagnostic.PropsErrors - -internal object PropsDeclarationChecker : DeclarationChecker { - override fun check( - declaration: KtDeclaration, - descriptor: DeclarationDescriptor, - context: DeclarationCheckerContext, - ) { - if (declaration !is KtClassOrObject) return - if (descriptor !is ClassDescriptor) return - if (descriptor.kind != ClassKind.INTERFACE) return - if (descriptor.isEffectivelyExternal()) return - if (!descriptor.implementsProps) return - - context.trace.report(PropsErrors.NON_EXTERNAL_PROPS.on(declaration)) - } -} diff --git a/seskar/seskar-compiler-plugin/src/main/kotlin/seskar/compiler/props/diagnostic/PropsErrors.kt b/seskar/seskar-compiler-plugin/src/main/kotlin/seskar/compiler/props/diagnostic/PropsErrors.kt deleted file mode 100644 index 23d4fb6d..00000000 --- a/seskar/seskar-compiler-plugin/src/main/kotlin/seskar/compiler/props/diagnostic/PropsErrors.kt +++ /dev/null @@ -1,25 +0,0 @@ -package seskar.compiler.props.diagnostic - -import org.jetbrains.kotlin.diagnostics.DiagnosticFactory0 -import org.jetbrains.kotlin.diagnostics.Errors -import org.jetbrains.kotlin.diagnostics.Severity.ERROR -import org.jetbrains.kotlin.psi.KtClassOrObject -import org.jetbrains.kotlin.psi.KtElement -import kotlin.reflect.KClass - -private fun errorDiagnosticFactory(): DiagnosticFactory0 = - DiagnosticFactory0.create(ERROR) - -private fun initialize(klass: KClass<*>) { - Errors.Initializer.initializeFactoryNamesAndDefaultErrorMessages(klass.java, PropsMessagesExtension) -} - -internal object PropsErrors { - @JvmField - val NON_EXTERNAL_PROPS: DiagnosticFactory0 = - errorDiagnosticFactory() - - init { - initialize(PropsErrors::class) - } -} diff --git a/seskar/seskar-compiler-plugin/src/main/kotlin/seskar/compiler/props/diagnostic/PropsMessagesExtension.kt b/seskar/seskar-compiler-plugin/src/main/kotlin/seskar/compiler/props/diagnostic/PropsMessagesExtension.kt deleted file mode 100644 index 52779730..00000000 --- a/seskar/seskar-compiler-plugin/src/main/kotlin/seskar/compiler/props/diagnostic/PropsMessagesExtension.kt +++ /dev/null @@ -1,18 +0,0 @@ -package seskar.compiler.props.diagnostic - -import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages -import org.jetbrains.kotlin.diagnostics.rendering.DiagnosticFactoryToRendererMap - -private val DIAGNOSTIC_FACTORY_TO_RENDERER by lazy { - DiagnosticFactoryToRendererMap("seskar.props").apply { - put( - PropsErrors.NON_EXTERNAL_PROPS, - "Non-external props are unsupported. Please add `external` modifier." - ) - } -} - -internal object PropsMessagesExtension : DefaultErrorMessages.Extension { - override fun getMap(): DiagnosticFactoryToRendererMap = - DIAGNOSTIC_FACTORY_TO_RENDERER -} diff --git a/seskar/seskar-compiler-plugin/src/main/kotlin/seskar/compiler/props/extensions/PropsRegistrar.kt b/seskar/seskar-compiler-plugin/src/main/kotlin/seskar/compiler/props/extensions/PropsRegistrar.kt deleted file mode 100644 index f4d300d4..00000000 --- a/seskar/seskar-compiler-plugin/src/main/kotlin/seskar/compiler/props/extensions/PropsRegistrar.kt +++ /dev/null @@ -1,17 +0,0 @@ -package seskar.compiler.props.extensions - -import org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar -import org.jetbrains.kotlin.config.CompilerConfiguration -import org.jetbrains.kotlin.extensions.StorageComponentContainerContributor - -class PropsRegistrar : CompilerPluginRegistrar() { - override val supportsK2: Boolean = false - - override fun ExtensionStorage.registerExtensions( - configuration: CompilerConfiguration, - ) { - StorageComponentContainerContributor.registerExtension( - extension = PropsStorageComponentContainerContributor(), - ) - } -} diff --git a/seskar/seskar-compiler-plugin/src/main/kotlin/seskar/compiler/props/extensions/PropsStorageComponentContainerContributor.kt b/seskar/seskar-compiler-plugin/src/main/kotlin/seskar/compiler/props/extensions/PropsStorageComponentContainerContributor.kt deleted file mode 100644 index d8b01073..00000000 --- a/seskar/seskar-compiler-plugin/src/main/kotlin/seskar/compiler/props/extensions/PropsStorageComponentContainerContributor.kt +++ /dev/null @@ -1,18 +0,0 @@ -package seskar.compiler.props.extensions - -import org.jetbrains.kotlin.container.StorageComponentContainer -import org.jetbrains.kotlin.container.useInstance -import org.jetbrains.kotlin.descriptors.ModuleDescriptor -import org.jetbrains.kotlin.extensions.StorageComponentContainerContributor -import org.jetbrains.kotlin.platform.TargetPlatform -import seskar.compiler.props.backend.PropsDeclarationChecker - -class PropsStorageComponentContainerContributor : StorageComponentContainerContributor { - override fun registerModuleComponents( - container: StorageComponentContainer, - platform: TargetPlatform, - moduleDescriptor: ModuleDescriptor, - ) { - container.useInstance(PropsDeclarationChecker) - } -} diff --git a/seskar/seskar-compiler-plugin/src/main/resources/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar b/seskar/seskar-compiler-plugin/src/main/resources/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar index 4db68c06..1be26d7d 100644 --- a/seskar/seskar-compiler-plugin/src/main/resources/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar +++ b/seskar/seskar-compiler-plugin/src/main/resources/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar @@ -1,5 +1,4 @@ seskar.compiler.env.extensions.EnvRegistrar seskar.compiler.memo.extensions.MemoRegistrar -seskar.compiler.props.extensions.PropsRegistrar seskar.compiler.union.extensions.UnionRegistrar seskar.compiler.value.extensions.ValueRegistrar