[AllOpen] Reorganize module structure of AllOpen plugin
This scheme will be common for all compiler plugins with K1 and K2 support: - `plugin-common` contains classes shared with K1 and K2 implementations (if any) - `plugin-k1` contains implementation for K1 compiler - `plugin-k2` contains implementation for K2 compiler - `plugin-backend` contains implementation for backend extensions (if any) - `plugin-cli` is module for registration of plugin in CLI compiler - `plugin` is a root module with tests and all submodules embedded This structure is needed to distinguish parts related to different frontends, which is needed for proper dependencies settings for Kotlin IDE plugins
This commit is contained in:
committed by
teamcity
parent
22ebea8174
commit
2a7dc1cc0c
@@ -0,0 +1,23 @@
|
||||
description = "Kotlin AllOpen Compiler Plugin (K1)"
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("jps-compatible")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":compiler:plugin-api"))
|
||||
compileOnly(project(":compiler:frontend"))
|
||||
|
||||
compileOnly(intellijCore())
|
||||
runtimeOnly(kotlinStdlib())
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
"main" { projectDefault() }
|
||||
"test" { none() }
|
||||
}
|
||||
|
||||
runtimeJar()
|
||||
sourcesJar()
|
||||
javadocJar()
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.allopen
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.extensions.AnnotationBasedExtension
|
||||
import org.jetbrains.kotlin.extensions.DeclarationAttributeAltererExtension
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.KtModifierListOwner
|
||||
import org.jetbrains.kotlin.psi.psiUtil.isPrivate
|
||||
|
||||
class CliAllOpenDeclarationAttributeAltererExtension(
|
||||
private val allOpenAnnotationFqNames: List<String>
|
||||
) : AbstractAllOpenDeclarationAttributeAltererExtension() {
|
||||
override fun getAnnotationFqNames(modifierListOwner: KtModifierListOwner?) = allOpenAnnotationFqNames
|
||||
}
|
||||
|
||||
abstract class AbstractAllOpenDeclarationAttributeAltererExtension : DeclarationAttributeAltererExtension, AnnotationBasedExtension {
|
||||
companion object {
|
||||
val ANNOTATIONS_FOR_TESTS = listOf("AllOpen", "AllOpen2", "test.AllOpen")
|
||||
}
|
||||
|
||||
override fun refineDeclarationModality(
|
||||
modifierListOwner: KtModifierListOwner,
|
||||
declaration: DeclarationDescriptor?,
|
||||
containingDeclaration: DeclarationDescriptor?,
|
||||
currentModality: Modality,
|
||||
isImplicitModality: Boolean
|
||||
): Modality? {
|
||||
if (currentModality != Modality.FINAL) {
|
||||
return null
|
||||
}
|
||||
|
||||
val descriptor = declaration as? ClassDescriptor ?: containingDeclaration ?: return null
|
||||
if (descriptor.hasSpecialAnnotation(modifierListOwner)) {
|
||||
return if (!isImplicitModality && modifierListOwner.hasModifier(KtTokens.FINAL_KEYWORD))
|
||||
Modality.FINAL // Explicit final
|
||||
else
|
||||
Modality.OPEN
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user