Convert to Kotlin: JpsKotlinCompilerSettings.java
This commit is contained in:
@@ -14,98 +14,71 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.jps;
|
package org.jetbrains.kotlin.jps
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.jps.model.JpsProject
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments;
|
import org.jetbrains.jps.model.ex.JpsElementBase
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments;
|
import org.jetbrains.jps.model.ex.JpsElementChildRoleBase
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments;
|
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||||
import org.jetbrains.jps.model.JpsElementChildRole;
|
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
|
||||||
import org.jetbrains.jps.model.JpsProject;
|
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
||||||
import org.jetbrains.jps.model.ex.JpsElementBase;
|
import org.jetbrains.kotlin.config.CompilerSettings
|
||||||
import org.jetbrains.jps.model.ex.JpsElementChildRoleBase;
|
|
||||||
import org.jetbrains.kotlin.config.CompilerSettings;
|
|
||||||
|
|
||||||
public class JpsKotlinCompilerSettings extends JpsElementBase<JpsKotlinCompilerSettings> {
|
class JpsKotlinCompilerSettings : JpsElementBase<JpsKotlinCompilerSettings>() {
|
||||||
static final JpsElementChildRole<JpsKotlinCompilerSettings> ROLE = JpsElementChildRoleBase.create("Kotlin Compiler Settings");
|
private var commonCompilerArguments: CommonCompilerArguments = CommonCompilerArguments.DummyImpl()
|
||||||
|
private var k2JvmCompilerArguments = K2JVMCompilerArguments()
|
||||||
|
private var k2JsCompilerArguments = K2JSCompilerArguments()
|
||||||
|
private var compilerSettings = CompilerSettings()
|
||||||
|
|
||||||
@NotNull
|
override fun createCopy(): JpsKotlinCompilerSettings {
|
||||||
private CommonCompilerArguments commonCompilerArguments = new CommonCompilerArguments.DummyImpl();
|
val copy = JpsKotlinCompilerSettings()
|
||||||
@NotNull
|
copy.commonCompilerArguments = this.commonCompilerArguments
|
||||||
private K2JVMCompilerArguments k2JvmCompilerArguments = new K2JVMCompilerArguments();
|
copy.k2JvmCompilerArguments = this.k2JvmCompilerArguments
|
||||||
@NotNull
|
copy.k2JsCompilerArguments = this.k2JsCompilerArguments
|
||||||
private K2JSCompilerArguments k2JsCompilerArguments = new K2JSCompilerArguments();
|
copy.compilerSettings = this.compilerSettings
|
||||||
@NotNull
|
return copy
|
||||||
private CompilerSettings compilerSettings = new CompilerSettings();
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public JpsKotlinCompilerSettings createCopy() {
|
|
||||||
JpsKotlinCompilerSettings copy = new JpsKotlinCompilerSettings();
|
|
||||||
copy.commonCompilerArguments = this.commonCompilerArguments;
|
|
||||||
copy.k2JvmCompilerArguments = this.k2JvmCompilerArguments;
|
|
||||||
copy.k2JsCompilerArguments = this.k2JsCompilerArguments;
|
|
||||||
copy.compilerSettings = this.compilerSettings;
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
override fun applyChanges(modified: JpsKotlinCompilerSettings) {
|
||||||
public void applyChanges(@NotNull JpsKotlinCompilerSettings modified) {
|
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
companion object {
|
||||||
public static JpsKotlinCompilerSettings getSettings(@NotNull JpsProject project) {
|
internal val ROLE = JpsElementChildRoleBase.create<JpsKotlinCompilerSettings>("Kotlin Compiler Settings")
|
||||||
JpsKotlinCompilerSettings settings = project.getContainer().getChild(ROLE);
|
|
||||||
if (settings == null) {
|
fun getSettings(project: JpsProject) = project.container.getChild(ROLE) ?: JpsKotlinCompilerSettings()
|
||||||
settings = new JpsKotlinCompilerSettings();
|
|
||||||
|
fun getOrCreateSettings(project: JpsProject): JpsKotlinCompilerSettings {
|
||||||
|
var settings = project.container.getChild(ROLE)
|
||||||
|
if (settings == null) {
|
||||||
|
settings = JpsKotlinCompilerSettings()
|
||||||
|
project.container.setChild(ROLE, settings)
|
||||||
|
}
|
||||||
|
return settings
|
||||||
}
|
}
|
||||||
return settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
fun getCommonCompilerArguments(project: JpsProject) = getSettings(project).commonCompilerArguments
|
||||||
public static JpsKotlinCompilerSettings getOrCreateSettings(@NotNull JpsProject project) {
|
|
||||||
JpsKotlinCompilerSettings settings = project.getContainer().getChild(ROLE);
|
fun setCommonCompilerArguments(project: JpsProject, commonCompilerSettings: CommonCompilerArguments) {
|
||||||
if (settings == null) {
|
getOrCreateSettings(project).commonCompilerArguments = commonCompilerSettings
|
||||||
settings = new JpsKotlinCompilerSettings();
|
|
||||||
project.getContainer().setChild(ROLE, settings);
|
|
||||||
}
|
}
|
||||||
return settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
fun getK2JvmCompilerArguments(project: JpsProject) = getSettings(project).k2JvmCompilerArguments
|
||||||
public static CommonCompilerArguments getCommonCompilerArguments(@NotNull JpsProject project) {
|
|
||||||
return getSettings(project).commonCompilerArguments;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setCommonCompilerArguments(@NotNull JpsProject project, @NotNull CommonCompilerArguments commonCompilerSettings) {
|
fun setK2JvmCompilerArguments(project: JpsProject, k2JvmCompilerArguments: K2JVMCompilerArguments) {
|
||||||
getOrCreateSettings(project).commonCompilerArguments = commonCompilerSettings;
|
getOrCreateSettings(project).k2JvmCompilerArguments = k2JvmCompilerArguments
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
fun getK2JsCompilerArguments(project: JpsProject) = getSettings(project).k2JsCompilerArguments
|
||||||
public static K2JVMCompilerArguments getK2JvmCompilerArguments(@NotNull JpsProject project) {
|
|
||||||
return getSettings(project).k2JvmCompilerArguments;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setK2JvmCompilerArguments(@NotNull JpsProject project, @NotNull K2JVMCompilerArguments k2JvmCompilerArguments) {
|
fun setK2JsCompilerArguments(project: JpsProject, k2JsCompilerArguments: K2JSCompilerArguments) {
|
||||||
getOrCreateSettings(project).k2JvmCompilerArguments = k2JvmCompilerArguments;
|
getOrCreateSettings(project).k2JsCompilerArguments = k2JsCompilerArguments
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
fun getCompilerSettings(project: JpsProject) = getSettings(project).compilerSettings
|
||||||
public static K2JSCompilerArguments getK2JsCompilerArguments(@NotNull JpsProject project) {
|
|
||||||
return getSettings(project).k2JsCompilerArguments;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setK2JsCompilerArguments(@NotNull JpsProject project, @NotNull K2JSCompilerArguments k2JsCompilerArguments) {
|
fun setCompilerSettings(project: JpsProject, compilerSettings: CompilerSettings) {
|
||||||
getOrCreateSettings(project).k2JsCompilerArguments = k2JsCompilerArguments;
|
getOrCreateSettings(project).compilerSettings = compilerSettings
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public static CompilerSettings getCompilerSettings(@NotNull JpsProject project) {
|
|
||||||
return getSettings(project).compilerSettings;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setCompilerSettings(@NotNull JpsProject project, @NotNull CompilerSettings compilerSettings) {
|
|
||||||
getOrCreateSettings(project).compilerSettings = compilerSettings;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -39,7 +39,7 @@ class Kotlin2JsCompilerArgumentsSerializer extends JpsProjectExtensionSerializer
|
|||||||
settings = new K2JSCompilerArguments();
|
settings = new K2JSCompilerArguments();
|
||||||
}
|
}
|
||||||
|
|
||||||
JpsKotlinCompilerSettings.setK2JsCompilerArguments(project, settings);
|
JpsKotlinCompilerSettings.Companion.setK2JsCompilerArguments(project, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+1
-1
@@ -39,7 +39,7 @@ class Kotlin2JvmCompilerArgumentsSerializer extends JpsProjectExtensionSerialize
|
|||||||
settings = new K2JVMCompilerArguments();
|
settings = new K2JVMCompilerArguments();
|
||||||
}
|
}
|
||||||
|
|
||||||
JpsKotlinCompilerSettings.setK2JvmCompilerArguments(project, settings);
|
JpsKotlinCompilerSettings.Companion.setK2JvmCompilerArguments(project, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+1
-1
@@ -39,7 +39,7 @@ class KotlinCommonCompilerArgumentsSerializer extends JpsProjectExtensionSeriali
|
|||||||
settings = new CommonCompilerArguments.DummyImpl();
|
settings = new CommonCompilerArguments.DummyImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
JpsKotlinCompilerSettings.setCommonCompilerArguments(project, settings);
|
JpsKotlinCompilerSettings.Companion.setCommonCompilerArguments(project, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class KotlinCompilerSettingsSerializer extends JpsProjectExtensionSerializer {
|
|||||||
settings = new CompilerSettings();
|
settings = new CompilerSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
JpsKotlinCompilerSettings.setCompilerSettings(project, settings);
|
JpsKotlinCompilerSettings.Companion.setCompilerSettings(project, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user