Use minimal optimisation to slightly speed up the tests.
This commit is contained in:
@@ -19,6 +19,7 @@ package org.jetbrains.k2js.test.utils;
|
||||
import com.google.dart.compiler.backend.js.ast.JsProgram;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.k2js.facade.K2JSTranslator;
|
||||
import org.jetbrains.k2js.test.config.TestConfig;
|
||||
@@ -36,6 +37,9 @@ public final class TranslationUtils {
|
||||
private TranslationUtils() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static /*var*/ K2JSTranslator translator = null;
|
||||
|
||||
public static void translateFile(@NotNull Project project, @NotNull String inputFile,
|
||||
@NotNull String outputFile) throws Exception {
|
||||
translateFiles(project, Collections.singletonList(inputFile), outputFile);
|
||||
@@ -43,9 +47,16 @@ public final class TranslationUtils {
|
||||
|
||||
public static void translateFiles(@NotNull Project project, @NotNull List<String> inputFiles,
|
||||
@NotNull String outputFile) throws Exception {
|
||||
K2JSTranslator translator = new K2JSTranslator(new TestConfig(project));
|
||||
List<JetFile> psiFiles = createPsiFileList(inputFiles, project);
|
||||
JsProgram program = translator.generateProgram(psiFiles);
|
||||
JsProgram program = getTranslator(project).generateProgram(psiFiles);
|
||||
K2JSTranslator.saveProgramToFile(outputFile, program);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static K2JSTranslator getTranslator(@NotNull Project project) {
|
||||
if (translator == null) {
|
||||
translator = new K2JSTranslator(new TestConfig(project));
|
||||
}
|
||||
return translator;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user