Override/Implement Members: Copy @Experimental-annotated annotations
#KT-22922 Fixed
This commit is contained in:
+36
-22
@@ -28,11 +28,11 @@ import com.intellij.psi.search.ProjectScope
|
||||
import com.intellij.testFramework.LightProjectDescriptor
|
||||
import com.intellij.testFramework.LoggedErrorProcessor
|
||||
import org.apache.log4j.Logger
|
||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||
import org.jetbrains.kotlin.cli.common.arguments.parseCommandLineArguments
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
||||
import org.jetbrains.kotlin.config.*
|
||||
import org.jetbrains.kotlin.idea.KotlinFileType
|
||||
import org.jetbrains.kotlin.idea.actions.internal.KotlinInternalMode
|
||||
import org.jetbrains.kotlin.idea.facet.KotlinFacet
|
||||
import org.jetbrains.kotlin.idea.facet.configureFacet
|
||||
import org.jetbrains.kotlin.idea.facet.getOrCreateFacet
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
@@ -186,30 +186,44 @@ fun configureCompilerOptions(fileText: String, project: Project, module: Module)
|
||||
val version = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// LANGUAGE_VERSION: ")
|
||||
val jvmTarget = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// JVM_TARGET: ")
|
||||
val options = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// COMPILER_ARGUMENTS: ")
|
||||
if (version != null || jvmTarget != null || options != null) {
|
||||
val accessToken = WriteAction.start()
|
||||
try {
|
||||
val modelsProvider = IdeModifiableModelsProviderImpl(project)
|
||||
val facet = module.getOrCreateFacet(modelsProvider, useProjectSettings = false)
|
||||
|
||||
facet.configureFacet(
|
||||
version ?: LanguageVersion.LATEST_STABLE.versionString,
|
||||
LanguageFeature.State.DISABLED,
|
||||
if (jvmTarget != null) TargetPlatformKind.Jvm(JvmTarget.fromString(jvmTarget)!!) else null,
|
||||
modelsProvider
|
||||
)
|
||||
if (options != null) {
|
||||
val compilerSettings = facet.configuration.settings.compilerSettings ?: CompilerSettings().also {
|
||||
facet.configuration.settings.compilerSettings = it
|
||||
}
|
||||
compilerSettings.additionalArguments = options
|
||||
facet.configuration.settings.updateMergedArguments()
|
||||
if (version != null || jvmTarget != null || options != null) {
|
||||
configureLanguageAndApiVersion(project, module, version ?: LanguageVersion.LATEST_STABLE.versionString)
|
||||
|
||||
val facetSettings = KotlinFacet.get(module)!!.configuration.settings
|
||||
|
||||
if (jvmTarget != null) {
|
||||
(facetSettings.compilerArguments as K2JVMCompilerArguments).jvmTarget = jvmTarget
|
||||
}
|
||||
|
||||
if (options != null) {
|
||||
val compilerSettings = facetSettings.compilerSettings ?: CompilerSettings().also {
|
||||
facetSettings.compilerSettings = it
|
||||
}
|
||||
modelsProvider.commit()
|
||||
compilerSettings.additionalArguments = options
|
||||
facetSettings.updateMergedArguments()
|
||||
}
|
||||
finally {
|
||||
accessToken.finish()
|
||||
}
|
||||
}
|
||||
|
||||
fun configureLanguageAndApiVersion(
|
||||
project: Project,
|
||||
module: Module,
|
||||
languageVersion: String,
|
||||
apiVersion: String? = null
|
||||
) {
|
||||
val accessToken = WriteAction.start()
|
||||
try {
|
||||
val modelsProvider = IdeModifiableModelsProviderImpl(project)
|
||||
val facet = module.getOrCreateFacet(modelsProvider, useProjectSettings = false)
|
||||
facet.configureFacet(languageVersion, LanguageFeature.State.DISABLED, null, modelsProvider)
|
||||
if (apiVersion != null) {
|
||||
facet.configuration.settings.apiLevel = LanguageVersion.fromVersionString(apiVersion)
|
||||
}
|
||||
modelsProvider.commit()
|
||||
}
|
||||
finally {
|
||||
accessToken.finish()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+37
-23
@@ -28,11 +28,11 @@ import com.intellij.psi.search.ProjectScope
|
||||
import com.intellij.testFramework.LightProjectDescriptor
|
||||
import com.intellij.testFramework.LoggedErrorProcessor
|
||||
import org.apache.log4j.Logger
|
||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||
import org.jetbrains.kotlin.cli.common.arguments.parseCommandLineArguments
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
||||
import org.jetbrains.kotlin.config.*
|
||||
import org.jetbrains.kotlin.idea.KotlinFileType
|
||||
import org.jetbrains.kotlin.idea.actions.internal.KotlinInternalMode
|
||||
import org.jetbrains.kotlin.idea.facet.KotlinFacet
|
||||
import org.jetbrains.kotlin.idea.facet.configureFacet
|
||||
import org.jetbrains.kotlin.idea.facet.getOrCreateFacet
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
@@ -185,30 +185,44 @@ fun configureCompilerOptions(fileText: String, project: Project, module: Module)
|
||||
val version = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// LANGUAGE_VERSION: ")
|
||||
val jvmTarget = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// JVM_TARGET: ")
|
||||
val options = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// COMPILER_ARGUMENTS: ")
|
||||
if (version != null || jvmTarget != null || options != null) {
|
||||
val accessToken = WriteAction.start()
|
||||
try {
|
||||
val modelsProvider = IdeModifiableModelsProviderImpl(project)
|
||||
val facet = module.getOrCreateFacet(modelsProvider, useProjectSettings = false)
|
||||
|
||||
facet.configureFacet(
|
||||
version ?: LanguageVersion.LATEST_STABLE.versionString,
|
||||
LanguageFeature.State.DISABLED,
|
||||
if (jvmTarget != null) TargetPlatformKind.Jvm(JvmTarget.fromString(jvmTarget)!!) else null,
|
||||
modelsProvider
|
||||
)
|
||||
if (options != null) {
|
||||
val compilerSettings = facet.configuration.settings.compilerSettings ?: CompilerSettings().also {
|
||||
facet.configuration.settings.compilerSettings = it
|
||||
}
|
||||
compilerSettings.additionalArguments = options
|
||||
facet.configuration.settings.updateMergedArguments()
|
||||
}
|
||||
modelsProvider.commit()
|
||||
if (version != null) {
|
||||
configureLanguageAndApiVersion(project, module, version)
|
||||
}
|
||||
|
||||
val facetSettings = KotlinFacet.get(module)!!.configuration.settings
|
||||
|
||||
if (jvmTarget != null) {
|
||||
(facetSettings.compilerArguments as K2JVMCompilerArguments).jvmTarget = jvmTarget
|
||||
}
|
||||
|
||||
if (options != null) {
|
||||
val compilerSettings = facetSettings.compilerSettings ?: CompilerSettings().also {
|
||||
facetSettings.compilerSettings = it
|
||||
}
|
||||
finally {
|
||||
accessToken.finish()
|
||||
compilerSettings.additionalArguments = options
|
||||
facetSettings.updateMergedArguments()
|
||||
}
|
||||
}
|
||||
|
||||
fun configureLanguageAndApiVersion(
|
||||
project: Project,
|
||||
module: Module,
|
||||
languageVersion: String,
|
||||
apiVersion: String? = null
|
||||
) {
|
||||
val accessToken = WriteAction.start()
|
||||
try {
|
||||
val modelsProvider = IdeModifiableModelsProviderImpl(project)
|
||||
val facet = module.getOrCreateFacet(modelsProvider, useProjectSettings = false)
|
||||
facet.configureFacet(languageVersion, LanguageFeature.State.DISABLED, null, modelsProvider)
|
||||
if (apiVersion != null) {
|
||||
facet.configuration.settings.apiLevel = LanguageVersion.fromVersionString(apiVersion)
|
||||
}
|
||||
modelsProvider.commit()
|
||||
}
|
||||
finally {
|
||||
accessToken.finish()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.jetbrains.kotlin.idea.decompiler.KotlinDecompiledFileViewProvider
|
||||
import org.jetbrains.kotlin.idea.decompiler.KtDecompiledFile
|
||||
import org.jetbrains.kotlin.idea.util.application.runWriteAction
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||
import java.util.*
|
||||
|
||||
enum class ModuleKind {
|
||||
@@ -73,6 +74,8 @@ fun Module.configureAs(kind: ModuleKind) {
|
||||
}
|
||||
|
||||
fun KtFile.dumpTextWithErrors(): String {
|
||||
val text = text
|
||||
if (InTextDirectivesUtils.isDirectiveDefined(text, "// DISABLE-ERRORS")) return text
|
||||
val diagnostics = analyzeWithContent().diagnostics
|
||||
val errors = diagnostics.filter { it.severity == Severity.ERROR }
|
||||
if (errors.isEmpty()) return text
|
||||
|
||||
Reference in New Issue
Block a user