Introduce some convenience methods related to EcmaVersion
This commit is contained in:
@@ -22,6 +22,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.k2js.config.Config;
|
||||
import org.jetbrains.k2js.config.EcmaVersion;
|
||||
import org.jetbrains.k2js.utils.JetFileUtils;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
@@ -36,12 +37,11 @@ import java.util.List;
|
||||
//TODO: review/refactor
|
||||
public final class TestConfig extends Config {
|
||||
|
||||
|
||||
@Nullable
|
||||
private /*var*/ List<JetFile> jsLibFiles = null;
|
||||
|
||||
public TestConfig(@NotNull Project project) {
|
||||
super(project, null);
|
||||
super(project, EcmaVersion.v3);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -34,7 +34,7 @@ public abstract class Config {
|
||||
|
||||
@NotNull
|
||||
public static Config getEmptyConfig(@NotNull Project project, @Nullable String target) {
|
||||
return new Config(project, target) {
|
||||
return new Config(project, EcmaVersion.fromString(target)) {
|
||||
@NotNull
|
||||
@Override
|
||||
protected List<JetFile> generateLibFiles() {
|
||||
@@ -70,9 +70,9 @@ public abstract class Config {
|
||||
@NotNull
|
||||
private final EcmaVersion target;
|
||||
|
||||
public Config(@NotNull Project project, @Nullable String target) {
|
||||
public Config(@NotNull Project project, @NotNull EcmaVersion ecmaVersion) {
|
||||
this.project = project;
|
||||
this.target = EcmaVersion.fromString(target);
|
||||
this.target = ecmaVersion;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -27,7 +27,12 @@ public enum EcmaVersion {
|
||||
v3, v5;
|
||||
|
||||
@NotNull
|
||||
static EcmaVersion fromString(@Nullable String target) {
|
||||
public static EcmaVersion fromString(@Nullable String target) {
|
||||
return StringUtil.compareVersionNumbers(target, "5") >= 0 ? v5 : v3;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static EcmaVersion defaultVersion() {
|
||||
return v3;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,8 +40,8 @@ public class ZippedLibrarySourcesConfig extends Config {
|
||||
@Nullable
|
||||
protected final String pathToLibZip;
|
||||
|
||||
public ZippedLibrarySourcesConfig(@NotNull Project project, @Nullable String pathToZip, @Nullable String target) {
|
||||
super(project, target);
|
||||
public ZippedLibrarySourcesConfig(@NotNull Project project, @Nullable String pathToZip, @NotNull EcmaVersion ecmaVersion) {
|
||||
super(project, ecmaVersion);
|
||||
pathToLibZip = pathToZip;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user