mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 11:50:54 +07:00
kotlin: use new reflection-less functions to work with compiler arguments
see 7480befe32
GitOrigin-RevId: 2f2bd2ef343ff92d1df8f44c5ccda6994f97e554
This commit is contained in:
committed by
intellij-monorepo-bot
parent
216d5ed19e
commit
a16b24fc6d
@@ -7,7 +7,6 @@ import com.intellij.icons.AllIcons
|
||||
import com.intellij.ide.actions.ShowSettingsUtilImpl
|
||||
import com.intellij.openapi.application.runWriteAction
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.project.RootsChangeRescanningInfo
|
||||
import com.intellij.openapi.ui.ComboBox
|
||||
import com.intellij.openapi.util.NlsSafe
|
||||
import com.intellij.ui.HoverHyperlinkLabel
|
||||
@@ -17,7 +16,6 @@ import org.jetbrains.kotlin.cli.common.arguments.*
|
||||
import org.jetbrains.kotlin.config.*
|
||||
import org.jetbrains.kotlin.idea.base.compilerPreferences.KotlinBaseCompilerConfigurationUiBundle
|
||||
import org.jetbrains.kotlin.idea.base.compilerPreferences.configuration.KotlinCompilerConfigurableTab
|
||||
import org.jetbrains.kotlin.idea.base.util.invalidateProjectRoots
|
||||
import org.jetbrains.kotlin.idea.base.util.onTextChange
|
||||
import org.jetbrains.kotlin.idea.compiler.configuration.*
|
||||
import org.jetbrains.kotlin.idea.facet.KotlinFacetConfiguration
|
||||
@@ -121,8 +119,11 @@ class KotlinFacetEditorGeneralTab(
|
||||
}
|
||||
|
||||
fun initialize() {
|
||||
class CommonCompilerArgumentsHolder: CommonCompilerArguments() {
|
||||
override fun copyOf(): Freezable = copyCommonCompilerArguments(this, CommonCompilerArgumentsHolder())
|
||||
}
|
||||
if (isMultiEditor) {
|
||||
editableCommonArguments = object : CommonCompilerArguments() {}
|
||||
editableCommonArguments = CommonCompilerArgumentsHolder()
|
||||
editableJvmArguments = K2JVMCompilerArguments()
|
||||
editableJsArguments = K2JSCompilerArguments()
|
||||
editableCompilerSettings = CompilerSettings()
|
||||
|
||||
@@ -52,15 +52,22 @@ fun KotlinFacetSettings.initializeIfNeeded(
|
||||
if (compilerArguments == null) {
|
||||
val targetPlatform = platform ?: getDefaultTargetPlatform(module, rootModel)
|
||||
|
||||
compilerArguments = targetPlatform.createArguments {
|
||||
val argumentsForPlatform = IdePlatformKindProjectStructure.getInstance(project)
|
||||
.getCompilerArguments(targetPlatform.idePlatformKind)
|
||||
val argumentsForPlatform = IdePlatformKindProjectStructure.getInstance(project)
|
||||
.getCompilerArguments(targetPlatform.idePlatformKind)
|
||||
|
||||
compilerArguments = targetPlatform.createArguments {
|
||||
if (argumentsForPlatform != null) {
|
||||
mergeBeans(argumentsForPlatform, this)
|
||||
when {
|
||||
argumentsForPlatform is K2JVMCompilerArguments &&
|
||||
this is K2JVMCompilerArguments -> copyK2JVMCompilerArguments(argumentsForPlatform, this)
|
||||
argumentsForPlatform is K2JSCompilerArguments &&
|
||||
this is K2JSCompilerArguments -> copyK2JSCompilerArguments(argumentsForPlatform, this)
|
||||
|
||||
else -> error("Unsupported copy arguments combination: ${argumentsForPlatform.javaClass.name} and ${javaClass.name}")
|
||||
}
|
||||
}
|
||||
|
||||
mergeBeans(commonArguments, this)
|
||||
copyCommonCompilerArguments(commonArguments, this)
|
||||
}
|
||||
|
||||
this.targetPlatform = targetPlatform
|
||||
@@ -144,7 +151,7 @@ fun applyCompilerArgumentsToFacet(
|
||||
with(kotlinFacet.configuration.settings) {
|
||||
val compilerArguments = this.compilerArguments ?: return
|
||||
|
||||
val defaultCompilerArguments = defaultArguments?.let { copyBean(it) } ?: compilerArguments::class.java.newInstance()
|
||||
val defaultCompilerArguments = defaultArguments?.copyOf() ?: compilerArguments::class.java.newInstance()
|
||||
defaultCompilerArguments.convertPathsToSystemIndependent()
|
||||
|
||||
val oldPluginOptions = compilerArguments.pluginOptions
|
||||
|
||||
@@ -13,6 +13,8 @@ import com.intellij.util.containers.ContainerUtil
|
||||
import org.jetbrains.kotlin.assignment.plugin.AssignmentPluginNames.ANNOTATION_OPTION_NAME
|
||||
import org.jetbrains.kotlin.assignment.plugin.AssignmentPluginNames.PLUGIN_ID
|
||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||
import org.jetbrains.kotlin.cli.common.arguments.Freezable
|
||||
import org.jetbrains.kotlin.cli.common.arguments.copyCommonCompilerArguments
|
||||
import org.jetbrains.kotlin.cli.common.arguments.parseCommandLineArguments
|
||||
import org.jetbrains.kotlin.idea.compilerPlugin.CachedAnnotationNames
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
@@ -73,7 +75,11 @@ internal class AssignmentAnnotationNamesCache(project: Project) {
|
||||
}
|
||||
|
||||
private fun ScriptDefinition.getSpecialAnnotations(annotationPrefix: String): List<String> {
|
||||
val arguments = object : CommonCompilerArguments() {}
|
||||
class CommonCompilerArgumentsHolder: CommonCompilerArguments() {
|
||||
override fun copyOf(): Freezable = copyCommonCompilerArguments(this, CommonCompilerArgumentsHolder())
|
||||
}
|
||||
|
||||
val arguments = CommonCompilerArgumentsHolder()
|
||||
parseCommandLineArguments(compilerOptions.toList(), arguments)
|
||||
return arguments.pluginOptions
|
||||
?.filter { it.startsWith(annotationPrefix) }
|
||||
|
||||
Reference in New Issue
Block a user