Add CompilerConfiguration to JsConfig
Will be used to store common compiler options (such as source version, inline disabled, etc) as well as JS-specific options, to unify the logic of compiler option initialization between JS and JVM compilers
This commit is contained in:
@@ -119,7 +119,7 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
|
||||
|
||||
File outputFile = new File(arguments.outputFile);
|
||||
|
||||
JsConfig config = getConfig(arguments, project);
|
||||
JsConfig config = getConfig(project, configuration, arguments);
|
||||
if (config.checkLibFilesAndReportErrors(new Function1<String, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(String message) {
|
||||
@@ -245,7 +245,11 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static JsConfig getConfig(@NotNull K2JSCompilerArguments arguments, @NotNull Project project) {
|
||||
private static JsConfig getConfig(
|
||||
@NotNull Project project,
|
||||
@NotNull CompilerConfiguration configuration,
|
||||
@NotNull K2JSCompilerArguments arguments
|
||||
) {
|
||||
if (arguments.target != null) {
|
||||
assert arguments.target == "v5" : "Unsupported ECMA version: " + arguments.target;
|
||||
}
|
||||
@@ -262,7 +266,7 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
|
||||
ContainerUtil.addAllNotNull(libraryFiles, arguments.libraryFiles);
|
||||
}
|
||||
|
||||
return new LibrarySourcesConfig.Builder(project, moduleId, libraryFiles)
|
||||
return new LibrarySourcesConfig.Builder(project, configuration, moduleId, libraryFiles)
|
||||
.ecmaVersion(ecmaVersion)
|
||||
.sourceMap(arguments.sourceMap)
|
||||
.inlineEnabled(inlineEnabled)
|
||||
|
||||
+3
-1
@@ -40,7 +40,9 @@ public abstract class AbstractDiagnosticsTestWithJsStdLib extends AbstractDiagno
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
config = new LibrarySourcesConfig.Builder(getProject(), "module", LibrarySourcesConfig.JS_STDLIB).build();
|
||||
config = new LibrarySourcesConfig.Builder(
|
||||
getProject(), getEnvironment().getConfiguration(), "module", LibrarySourcesConfig.JS_STDLIB
|
||||
).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
-3
@@ -39,8 +39,8 @@ import org.jetbrains.kotlin.utils.sure
|
||||
import java.io.File
|
||||
|
||||
class KotlinJavascriptSerializerTest : TestCaseWithTmpdir() {
|
||||
private final val MODULE_NAME = "module"
|
||||
private final val BASE_DIR = "compiler/testData/serialization"
|
||||
private val MODULE_NAME = "module"
|
||||
private val BASE_DIR = "compiler/testData/serialization"
|
||||
|
||||
private fun doTest(fileName: String, metaFileDir: File = tmpdir) {
|
||||
val source = "$BASE_DIR/$fileName"
|
||||
@@ -68,7 +68,9 @@ class KotlinJavascriptSerializerTest : TestCaseWithTmpdir() {
|
||||
try {
|
||||
val environment = KotlinCoreEnvironment.createForTests(rootDisposable, configuration, EnvironmentConfigFiles.JS_CONFIG_FILES)
|
||||
val files = environment.getSourceFiles()
|
||||
val config = LibrarySourcesConfig.Builder(environment.project, MODULE_NAME, LibrarySourcesConfig.JS_STDLIB).build()
|
||||
val config = LibrarySourcesConfig.Builder(
|
||||
environment.project, environment.configuration, MODULE_NAME, LibrarySourcesConfig.JS_STDLIB
|
||||
).build()
|
||||
val analysisResult = TopDownAnalyzerFacadeForJS.analyzeFiles(files, config)
|
||||
FileUtil.writeToFile(metaFile, KotlinJavascriptSerializationUtil.metadataAsString(MODULE_NAME, analysisResult.moduleDescriptor))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user