JS: minor code cleanup
This commit is contained in:
@@ -10,14 +10,14 @@ import java.util.*;
|
||||
|
||||
public class JsProgramFragment {
|
||||
private final JsScope scope;
|
||||
private final List<JsImportedModule> importedModules = new ArrayList<JsImportedModule>();
|
||||
private final Map<String, JsExpression> imports = new LinkedHashMap<String, JsExpression>();
|
||||
private final List<JsImportedModule> importedModules = new ArrayList<>();
|
||||
private final Map<String, JsExpression> imports = new LinkedHashMap<>();
|
||||
private final JsGlobalBlock declarationBlock = new JsGlobalBlock();
|
||||
private final JsGlobalBlock exportBlock = new JsGlobalBlock();
|
||||
private final JsGlobalBlock initializerBlock = new JsGlobalBlock();
|
||||
private final List<JsNameBinding> nameBindings = new ArrayList<JsNameBinding>();
|
||||
private final Map<JsName, JsClassModel> classes = new LinkedHashMap<JsName, JsClassModel>();
|
||||
private final Map<String, JsExpression> inlineModuleMap = new LinkedHashMap<String, JsExpression>();
|
||||
private final List<JsNameBinding> nameBindings = new ArrayList<>();
|
||||
private final Map<JsName, JsClassModel> classes = new LinkedHashMap<>();
|
||||
private final Map<String, JsExpression> inlineModuleMap = new LinkedHashMap<>();
|
||||
|
||||
public JsProgramFragment(@NotNull JsScope scope) {
|
||||
this.scope = scope;
|
||||
|
||||
@@ -268,11 +268,11 @@ public final class Translation {
|
||||
JsName internalModuleName = program.getScope().declareName("_");
|
||||
Merger merger = new Merger(rootFunction, internalModuleName, moduleDescriptor);
|
||||
|
||||
Map<KtFile, JsProgramFragment> fragmentMap = new HashMap<KtFile, JsProgramFragment>();
|
||||
List<JsProgramFragment> fragments = new ArrayList<JsProgramFragment>();
|
||||
List<JsProgramFragment> newFragments = new ArrayList<JsProgramFragment>();
|
||||
Map<KtFile, JsProgramFragment> fragmentMap = new HashMap<>();
|
||||
List<JsProgramFragment> fragments = new ArrayList<>();
|
||||
List<JsProgramFragment> newFragments = new ArrayList<>();
|
||||
|
||||
Map<KtFile, List<DeclarationDescriptor>> fileMemberScopes = new HashMap<KtFile, List<DeclarationDescriptor>>();
|
||||
Map<KtFile, List<DeclarationDescriptor>> fileMemberScopes = new HashMap<>();
|
||||
|
||||
JsAstDeserializer deserializer = new JsAstDeserializer(program);
|
||||
for (TranslationUnit unit : units) {
|
||||
@@ -280,7 +280,7 @@ public final class Translation {
|
||||
KtFile file = ((TranslationUnit.SourceFile) unit).getFile();
|
||||
StaticContext staticContext = new StaticContext(bindingTrace, config, moduleDescriptor);
|
||||
TranslationContext context = TranslationContext.rootContext(staticContext);
|
||||
List<DeclarationDescriptor> fileMemberScope = new ArrayList<DeclarationDescriptor>();
|
||||
List<DeclarationDescriptor> fileMemberScope = new ArrayList<>();
|
||||
translateFile(context, file, fileMemberScope);
|
||||
fragments.add(staticContext.getFragment());
|
||||
newFragments.add(staticContext.getFragment());
|
||||
@@ -371,10 +371,7 @@ public final class Translation {
|
||||
catch (TranslationRuntimeException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
throw new TranslationRuntimeException(file, e);
|
||||
}
|
||||
catch (AssertionError e) {
|
||||
catch (RuntimeException | AssertionError e) {
|
||||
throw new TranslationRuntimeException(file, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -427,12 +427,6 @@ public final class JsAstUtils {
|
||||
return new JsVars(new JsVars.JsVar(name, expr));
|
||||
}
|
||||
|
||||
public static void setParameters(@NotNull JsFunction function, @NotNull List<JsParameter> newParams) {
|
||||
List<JsParameter> parameters = function.getParameters();
|
||||
assert parameters.isEmpty() : "Arguments already set.";
|
||||
parameters.addAll(newParams);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static JsExpression newSequence(@NotNull List<JsExpression> expressions) {
|
||||
assert !expressions.isEmpty();
|
||||
@@ -575,13 +569,4 @@ public final class JsAstUtils {
|
||||
MetadataProperties.setCoroutineReceiver(result, true);
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static JsExpression comma(JsExpression first, JsExpression... tail) {
|
||||
JsExpression result = first;
|
||||
for (JsExpression e : tail) {
|
||||
result = new JsBinaryOperation(JsBinaryOperator.COMMA, result, e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user