JS: add metaInfo attribute to Config
This commit is contained in:
@@ -245,7 +245,7 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
|
||||
ContainerUtil.addAllNotNull(libraryFiles, arguments.libraryFiles);
|
||||
}
|
||||
|
||||
return new LibrarySourcesConfig(project, moduleId, libraryFiles, ecmaVersion, arguments.sourceMap, inlineEnabled);
|
||||
return new LibrarySourcesConfig(project, moduleId, libraryFiles, ecmaVersion, arguments.sourceMap, inlineEnabled, arguments.metaInfo);
|
||||
}
|
||||
|
||||
public static MainCallParameters createMainCallParameters(String main) {
|
||||
|
||||
@@ -52,6 +52,8 @@ public abstract class Config {
|
||||
private final String moduleId;
|
||||
|
||||
private final boolean sourcemap;
|
||||
@Nullable
|
||||
private final String metaInfo;
|
||||
|
||||
@NotNull
|
||||
protected final List<KotlinJavascriptMetadata> metadata = new SmartList<KotlinJavascriptMetadata>();
|
||||
@@ -66,19 +68,26 @@ public abstract class Config {
|
||||
@NotNull String moduleId,
|
||||
@NotNull EcmaVersion ecmaVersion,
|
||||
boolean sourcemap,
|
||||
boolean inlineEnabled
|
||||
boolean inlineEnabled,
|
||||
@Nullable String metaInfo
|
||||
) {
|
||||
this.project = project;
|
||||
this.target = ecmaVersion;
|
||||
this.moduleId = moduleId;
|
||||
this.sourcemap = sourcemap;
|
||||
this.inlineEnabled = inlineEnabled;
|
||||
this.metaInfo = metaInfo;
|
||||
}
|
||||
|
||||
public boolean isSourcemap() {
|
||||
return sourcemap;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getMetaInfo() {
|
||||
return metaInfo;
|
||||
}
|
||||
|
||||
public boolean isInlineEnabled() {
|
||||
return inlineEnabled;
|
||||
}
|
||||
|
||||
@@ -61,9 +61,10 @@ public class LibrarySourcesConfig extends Config {
|
||||
@NotNull List<String> files,
|
||||
@NotNull EcmaVersion ecmaVersion,
|
||||
boolean sourcemap,
|
||||
boolean inlineEnabled
|
||||
boolean inlineEnabled,
|
||||
@Nullable String metaInfo
|
||||
) {
|
||||
super(project, moduleId, ecmaVersion, sourcemap, inlineEnabled);
|
||||
super(project, moduleId, ecmaVersion, sourcemap, inlineEnabled, metaInfo);
|
||||
this.files = files;
|
||||
}
|
||||
|
||||
|
||||
+15
-2
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.js.config;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.util.SmartList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.psi.JetFile;
|
||||
import org.jetbrains.kotlin.utils.KotlinJavascriptMetadata;
|
||||
import org.jetbrains.kotlin.utils.PathUtil;
|
||||
@@ -34,6 +35,19 @@ public class LibrarySourcesConfigWithCaching extends LibrarySourcesConfig {
|
||||
|
||||
private final boolean isUnitTestConfig;
|
||||
|
||||
public LibrarySourcesConfigWithCaching(
|
||||
@NotNull Project project,
|
||||
@NotNull String moduleId,
|
||||
@NotNull EcmaVersion ecmaVersion,
|
||||
boolean sourcemap,
|
||||
boolean inlineEnabled,
|
||||
boolean isUnitTestConfig,
|
||||
@Nullable String metaInfo
|
||||
) {
|
||||
super(project, moduleId, JS_STDLIB, ecmaVersion, sourcemap, inlineEnabled, metaInfo);
|
||||
this.isUnitTestConfig = isUnitTestConfig;
|
||||
}
|
||||
|
||||
public LibrarySourcesConfigWithCaching(
|
||||
@NotNull Project project,
|
||||
@NotNull String moduleId,
|
||||
@@ -42,8 +56,7 @@ public class LibrarySourcesConfigWithCaching extends LibrarySourcesConfig {
|
||||
boolean inlineEnabled,
|
||||
boolean isUnitTestConfig
|
||||
) {
|
||||
super(project, moduleId, JS_STDLIB, ecmaVersion, sourcemap, inlineEnabled);
|
||||
this.isUnitTestConfig = isUnitTestConfig;
|
||||
this(project, moduleId, ecmaVersion, sourcemap, inlineEnabled, isUnitTestConfig, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -204,6 +204,11 @@ public abstract class BasicTest extends KotlinTestWithEnvironment {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected String getMetaInfo(@NotNull String moduleId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void processJsProgram(@NotNull JsProgram program) throws Exception { }
|
||||
|
||||
protected void runRhinoTests(
|
||||
@@ -279,10 +284,10 @@ public abstract class BasicTest extends KotlinTestWithEnvironment {
|
||||
@NotNull
|
||||
private Config createConfig(@NotNull Project project, @NotNull String moduleId, @NotNull EcmaVersion ecmaVersion, @Nullable List<String> libraries) {
|
||||
if (libraries == null) {
|
||||
return new LibrarySourcesConfigWithCaching(project, moduleId, ecmaVersion, shouldGenerateSourceMap(), IS_INLINE_ENABLED, shouldBeTranslateAsUnitTestClass());
|
||||
return new LibrarySourcesConfigWithCaching(project, moduleId, ecmaVersion, shouldGenerateSourceMap(), IS_INLINE_ENABLED, shouldBeTranslateAsUnitTestClass(), getMetaInfo(moduleId));
|
||||
}
|
||||
else {
|
||||
return new LibrarySourcesConfig(project, moduleId, librariesWithJsStdlib(libraries), ecmaVersion, shouldGenerateSourceMap(), IS_INLINE_ENABLED);
|
||||
return new LibrarySourcesConfig(project, moduleId, librariesWithJsStdlib(libraries), ecmaVersion, shouldGenerateSourceMap(), IS_INLINE_ENABLED, getMetaInfo(moduleId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,7 +299,7 @@ public abstract class BasicTest extends KotlinTestWithEnvironment {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String getOutputPath() {
|
||||
protected String getOutputPath() {
|
||||
return pathToTestDir() + OUT;
|
||||
}
|
||||
|
||||
|
||||
@@ -146,7 +146,7 @@ class NoInternalVisibilityInStdLibTest {
|
||||
val environment = KotlinCoreEnvironment.createForProduction(disposable!!, configuration, EnvironmentConfigFiles.JS_CONFIG_FILES)
|
||||
val project = environment.project
|
||||
val pathToJsStdlibJar = KOTLIN_ROOT_PATH + PathUtil.getKotlinPathsForDistDirectory().getJsStdLibJarPath().path
|
||||
val config = LibrarySourcesConfig(project, "testModule", listOf(pathToJsStdlibJar), EcmaVersion.defaultVersion(), false, false)
|
||||
val config = LibrarySourcesConfig(project, "testModule", listOf(pathToJsStdlibJar), EcmaVersion.defaultVersion(), false, false, null)
|
||||
|
||||
TopDownAnalyzerFacadeForJS.analyzeFiles(listOf(), config).moduleDescriptor
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user