Drop extra fields which covered by metadata: isLocal from JsFunction.
This commit is contained in:
@@ -19,7 +19,6 @@ public final class JsFunction extends JsLiteral implements HasName {
|
||||
@NotNull
|
||||
private final JsFunctionScope scope;
|
||||
private JsName name;
|
||||
private boolean isLocal = false;
|
||||
|
||||
public JsFunction(@NotNull JsScope parentScope, @NotNull String description) {
|
||||
this(parentScope, description, null);
|
||||
@@ -63,10 +62,6 @@ public final class JsFunction extends JsLiteral implements HasName {
|
||||
return scope;
|
||||
}
|
||||
|
||||
public boolean isLocal() {
|
||||
return isLocal;
|
||||
}
|
||||
|
||||
public void setBody(@NotNull JsBlock body) {
|
||||
this.body = body;
|
||||
}
|
||||
@@ -75,10 +70,6 @@ public final class JsFunction extends JsLiteral implements HasName {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void markAsLocal() {
|
||||
isLocal = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(JsVisitor v) {
|
||||
v.visitFunction(this);
|
||||
@@ -106,7 +97,6 @@ public final class JsFunction extends JsLiteral implements HasName {
|
||||
functionCopy.getScope().copyOwnNames(scope);
|
||||
functionCopy.setBody(body.deepCopy());
|
||||
functionCopy.params = AstUtil.deepCopy(params);
|
||||
functionCopy.isLocal = isLocal;
|
||||
|
||||
return functionCopy.withMetadataFrom(this);
|
||||
}
|
||||
|
||||
+3
-2
@@ -18,6 +18,7 @@ package org.jetbrains.k2js.inline.clean
|
||||
|
||||
import com.google.dart.compiler.backend.js.ast.*
|
||||
import com.google.dart.compiler.backend.js.ast.metadata.staticRef
|
||||
import com.google.dart.compiler.backend.js.ast.metadata.isLocal
|
||||
|
||||
import com.intellij.util.containers.Stack
|
||||
import java.util.IdentityHashMap
|
||||
@@ -54,11 +55,11 @@ private class UnusedLocalFunctionsCollector(functions: Map<JsName, JsFunction>)
|
||||
get() = tracker.removable
|
||||
|
||||
public fun process() {
|
||||
functions.filter { it.value.isLocal() }
|
||||
functions.filter { it.value.isLocal }
|
||||
.forEach { tracker.addCandidateForRemoval(it.key, it.value) }
|
||||
|
||||
for ((name, function) in functions) {
|
||||
if (function.isLocal()) {
|
||||
if (function.isLocal) {
|
||||
processLocalFunction(name, function)
|
||||
} else {
|
||||
processNonLocalFunction(name, function)
|
||||
|
||||
+3
-2
@@ -18,6 +18,7 @@ package org.jetbrains.k2js.translate.expression
|
||||
|
||||
import com.google.dart.compiler.backend.js.ast.*
|
||||
import com.google.dart.compiler.backend.js.ast.metadata.staticRef
|
||||
import com.google.dart.compiler.backend.js.ast.metadata.isLocal
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.ReceiverParameterDescriptor
|
||||
import org.jetbrains.jet.lang.psi.JetDeclarationWithBody
|
||||
@@ -60,11 +61,11 @@ class LiteralFunctionTranslator(context: TranslationContext) : AbstractTranslato
|
||||
|
||||
if (tracker.hasCapturedExceptContaining()) {
|
||||
val lambdaCreator = simpleReturnFunction(invokingContext.scope(), lambda)
|
||||
lambdaCreator.markAsLocal()
|
||||
lambdaCreator.isLocal = true
|
||||
return lambdaCreator.withCapturedParameters(functionContext, invokingContext, descriptor)
|
||||
}
|
||||
|
||||
lambda.markAsLocal()
|
||||
lambda.isLocal = true
|
||||
return invokingContext.define(descriptor, lambda)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user