JS backend: copy metdata when copy node.
This commit is contained in:
@@ -65,6 +65,6 @@ public final class JsArrayAccess extends JsExpressionImpl {
|
||||
JsExpression arrayCopy = AstUtil.deepCopy(arrayExpression);
|
||||
JsExpression indexCopy = AstUtil.deepCopy(indexExpression);
|
||||
|
||||
return new JsArrayAccess(arrayCopy, indexCopy);
|
||||
return new JsArrayAccess(arrayCopy, indexCopy).withMetadataFrom(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,6 @@ public final class JsArrayLiteral extends JsLiteral {
|
||||
@NotNull
|
||||
@Override
|
||||
public JsArrayLiteral deepCopy() {
|
||||
return new JsArrayLiteral(AstUtil.deepCopy(expressions));
|
||||
return new JsArrayLiteral(AstUtil.deepCopy(expressions)).withMetadataFrom(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,6 +75,6 @@ public final class JsBinaryOperation extends JsExpressionImpl {
|
||||
@NotNull
|
||||
@Override
|
||||
public JsExpression deepCopy() {
|
||||
return new JsBinaryOperation(op, AstUtil.deepCopy(arg1), AstUtil.deepCopy(arg2));
|
||||
return new JsBinaryOperation(op, AstUtil.deepCopy(arg1), AstUtil.deepCopy(arg2)).withMetadataFrom(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,6 +68,6 @@ public class JsBlock extends SourceInfoAwareJsNode implements JsStatement {
|
||||
@NotNull
|
||||
@Override
|
||||
public JsBlock deepCopy() {
|
||||
return new JsBlock(AstUtil.deepCopy(statements));
|
||||
return new JsBlock(AstUtil.deepCopy(statements)).withMetadataFrom(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,6 @@ public final class JsBreak extends JsContinue {
|
||||
@NotNull
|
||||
@Override
|
||||
public JsBreak deepCopy() {
|
||||
return new JsBreak(AstUtil.deepCopy(label));
|
||||
return new JsBreak(AstUtil.deepCopy(label)).withMetadataFrom(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,6 @@ public final class JsCase extends JsSwitchMember {
|
||||
caseCopy.caseExpression = AstUtil.deepCopy(caseExpression);
|
||||
caseCopy.statements.addAll(AstUtil.deepCopy(statements));
|
||||
|
||||
return caseCopy;
|
||||
return caseCopy.withMetadataFrom(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ public class JsCatch extends SourceInfoAwareJsNode implements HasCondition {
|
||||
JsExpression conditionCopy = AstUtil.deepCopy(condition);
|
||||
JsParameter paramCopy = AstUtil.deepCopy(param);
|
||||
|
||||
return new JsCatch(scopeCopy, bodyCopy, conditionCopy, paramCopy);
|
||||
return new JsCatch(scopeCopy, bodyCopy, conditionCopy, paramCopy).withMetadataFrom(this);
|
||||
}
|
||||
|
||||
private JsCatch(JsCatchScope scope, JsBlock body, JsExpression condition, JsParameter param) {
|
||||
|
||||
@@ -74,6 +74,6 @@ public final class JsConditional extends JsExpressionImpl {
|
||||
JsExpression thenCopy = AstUtil.deepCopy(thenExpression);
|
||||
JsExpression elseCopy = AstUtil.deepCopy(elseExpression);
|
||||
|
||||
return new JsConditional(testCopy, thenCopy, elseCopy);
|
||||
return new JsConditional(testCopy, thenCopy, elseCopy).withMetadataFrom(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,6 @@ public class JsContinue extends SourceInfoAwareJsNode implements JsStatement {
|
||||
public JsContinue deepCopy() {
|
||||
if (label == null) return new JsContinue();
|
||||
|
||||
return new JsContinue(AstUtil.deepCopy(label));
|
||||
return new JsContinue(AstUtil.deepCopy(label)).withMetadataFrom(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,6 @@ public final class JsDefault extends JsSwitchMember {
|
||||
public JsDefault deepCopy() {
|
||||
JsDefault defaultCopy = new JsDefault();
|
||||
defaultCopy.statements.addAll(AstUtil.deepCopy(statements));
|
||||
return defaultCopy;
|
||||
return defaultCopy.withMetadataFrom(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,6 @@ public class JsDoWhile extends JsWhile {
|
||||
JsExpression conditionCopy = AstUtil.deepCopy(condition);
|
||||
JsStatement bodyCopy = AstUtil.deepCopy(body);
|
||||
|
||||
return new JsDoWhile(conditionCopy, bodyCopy);
|
||||
return new JsDoWhile(conditionCopy, bodyCopy).withMetadataFrom(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,6 @@ public class JsDocComment extends JsExpressionImpl {
|
||||
@NotNull
|
||||
@Override
|
||||
public JsDocComment deepCopy() {
|
||||
return new JsDocComment(tags);
|
||||
return new JsDocComment(tags).withMetadataFrom(this);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -55,6 +55,6 @@ public final class JsExpressionStatement extends AbstractNode implements JsState
|
||||
@NotNull
|
||||
@Override
|
||||
public JsExpressionStatement deepCopy() {
|
||||
return new JsExpressionStatement(expression.deepCopy());
|
||||
return new JsExpressionStatement(expression.deepCopy()).withMetadataFrom(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,16 +129,13 @@ public class JsFor extends SourceInfoAwareJsNode implements JsStatement {
|
||||
JsExpression conditionCopy = AstUtil.deepCopy(condition);
|
||||
JsExpression incrementalExprCopy = AstUtil.deepCopy(incrementExpression);
|
||||
|
||||
JsFor result;
|
||||
if (initVars != null) {
|
||||
return new JsFor(initVars.deepCopy(),
|
||||
conditionCopy,
|
||||
incrementalExprCopy,
|
||||
bodyCopy);
|
||||
result = new JsFor(initVars.deepCopy(), conditionCopy, incrementalExprCopy, bodyCopy);
|
||||
} else {
|
||||
return new JsFor(initExpression.deepCopy(),
|
||||
conditionCopy,
|
||||
incrementExpression,
|
||||
bodyCopy);
|
||||
result = new JsFor(initExpression.deepCopy(), conditionCopy, incrementExpression, bodyCopy);
|
||||
}
|
||||
|
||||
return result.withMetadataFrom(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,6 +92,6 @@ public class JsForIn extends SourceInfoAwareJsNode implements JsStatement {
|
||||
JsExpression iterCopy = AstUtil.deepCopy(iterExpression);
|
||||
JsExpression objectCopy = AstUtil.deepCopy(objectExpression);
|
||||
|
||||
return new JsForIn(iterVarName, iterCopy, objectCopy, bodyCopy);
|
||||
return new JsForIn(iterVarName, iterCopy, objectCopy, bodyCopy).withMetadataFrom(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,6 +108,6 @@ public final class JsFunction extends JsLiteral implements HasName {
|
||||
functionCopy.params = AstUtil.deepCopy(params);
|
||||
functionCopy.isLocal = isLocal;
|
||||
|
||||
return functionCopy;
|
||||
return functionCopy.withMetadataFrom(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,6 @@ public class JsGlobalBlock extends JsBlock {
|
||||
JsGlobalBlock globalBlockCopy = new JsGlobalBlock();
|
||||
List<JsStatement> statementscopy = AstUtil.deepCopy(getStatements());
|
||||
globalBlockCopy.getStatements().addAll(statementscopy);
|
||||
return globalBlockCopy;
|
||||
return globalBlockCopy.withMetadataFrom(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,6 +86,6 @@ public final class JsIf extends SourceInfoAwareJsNode implements JsStatement {
|
||||
JsStatement thenCopy = AstUtil.deepCopy(thenStatement);
|
||||
JsStatement elseCopy = AstUtil.deepCopy(elseStatement);
|
||||
|
||||
return new JsIf(ifCopy, thenCopy, elseCopy);
|
||||
return new JsIf(ifCopy, thenCopy, elseCopy).withMetadataFrom(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,6 +87,6 @@ public final class JsInvocation extends JsExpressionImpl.JsExpressionHasArgument
|
||||
List<JsExpression> argumentsCopy = AstUtil.deepCopy(arguments);
|
||||
JsInvocation copy = new JsInvocation(qualifierCopy, argumentsCopy);
|
||||
copy.setInlineStrategy(inlineStrategy);
|
||||
return copy;
|
||||
return copy.withMetadataFrom(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,6 +64,6 @@ public class JsLabel extends SourceInfoAwareJsNode implements JsStatement, HasNa
|
||||
@NotNull
|
||||
@Override
|
||||
public JsLabel deepCopy() {
|
||||
return new JsLabel(label, AstUtil.deepCopy(statement.deepCopy()));
|
||||
return new JsLabel(label, AstUtil.deepCopy(statement.deepCopy())).withMetadataFrom(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,6 +99,6 @@ public final class JsNameRef extends JsExpressionImpl implements HasName {
|
||||
|
||||
if (name != null) return new JsNameRef(name, qualifierCopy);
|
||||
|
||||
return new JsNameRef(ident, qualifierCopy);
|
||||
return new JsNameRef(ident, qualifierCopy).withMetadataFrom(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,6 @@ public final class JsNew extends JsExpressionImpl.JsExpressionHasArguments {
|
||||
public JsNew deepCopy() {
|
||||
JsExpression constructorCopy = AstUtil.deepCopy(constructorExpression);
|
||||
List<JsExpression> argumentsCopy = AstUtil.deepCopy(arguments);
|
||||
return new JsNew(constructorCopy, argumentsCopy);
|
||||
return new JsNew(constructorCopy, argumentsCopy).withMetadataFrom(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +61,6 @@ public final class JsObjectLiteral extends JsLiteral {
|
||||
@NotNull
|
||||
@Override
|
||||
public JsObjectLiteral deepCopy() {
|
||||
return new JsObjectLiteral(AstUtil.deepCopy(properties), multiline);
|
||||
return new JsObjectLiteral(AstUtil.deepCopy(properties), multiline).withMetadataFrom(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,6 @@ public final class JsParameter extends SourceInfoAwareJsNode implements HasName
|
||||
public JsParameter deepCopy() {
|
||||
JsParameter parameter = new JsParameter(name);
|
||||
parameter.setHasDefaultValue(hasDefaultValue);
|
||||
return parameter;
|
||||
return parameter.withMetadataFrom(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,6 @@ public final class JsPostfixOperation extends JsUnaryOperation {
|
||||
@NotNull
|
||||
@Override
|
||||
public JsPostfixOperation deepCopy() {
|
||||
return new JsPostfixOperation(getOperator(), AstUtil.deepCopy(getArg()));
|
||||
return new JsPostfixOperation(getOperator(), AstUtil.deepCopy(getArg())).withMetadataFrom(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,6 @@ public final class JsPrefixOperation extends JsUnaryOperation {
|
||||
@NotNull
|
||||
@Override
|
||||
public JsPrefixOperation deepCopy() {
|
||||
return new JsPrefixOperation(getOperator(), AstUtil.deepCopy(getArg()));
|
||||
return new JsPrefixOperation(getOperator(), AstUtil.deepCopy(getArg())).withMetadataFrom(this);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -57,6 +57,6 @@ public class JsPropertyInitializer extends SourceInfoAwareJsNode {
|
||||
@NotNull
|
||||
@Override
|
||||
public JsPropertyInitializer deepCopy() {
|
||||
return new JsPropertyInitializer(labelExpr.deepCopy(), valueExpr.deepCopy());
|
||||
return new JsPropertyInitializer(labelExpr.deepCopy(), valueExpr.deepCopy()).withMetadataFrom(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,6 @@ public final class JsReturn extends SourceInfoAwareJsNode implements JsStatement
|
||||
@NotNull
|
||||
@Override
|
||||
public JsReturn deepCopy() {
|
||||
return new JsReturn(AstUtil.deepCopy(expression));
|
||||
return new JsReturn(AstUtil.deepCopy(expression)).withMetadataFrom(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,6 +66,6 @@ public class JsSwitch extends SourceInfoAwareJsNode implements JsStatement {
|
||||
JsExpression expressionCopy = AstUtil.deepCopy(expression);
|
||||
List<JsSwitchMember> casesCopy = AstUtil.deepCopy(cases);
|
||||
|
||||
return new JsSwitch(expressionCopy, casesCopy);
|
||||
return new JsSwitch(expressionCopy, casesCopy).withMetadataFrom(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,6 @@ public class JsThrow extends SourceInfoAwareJsNode implements JsStatement {
|
||||
@NotNull
|
||||
@Override
|
||||
public JsThrow deepCopy() {
|
||||
return new JsThrow(AstUtil.deepCopy(expression));
|
||||
return new JsThrow(AstUtil.deepCopy(expression)).withMetadataFrom(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,6 +82,6 @@ public class JsTry extends SourceInfoAwareJsNode implements JsStatement {
|
||||
List<JsCatch> catchCopy = AstUtil.deepCopy(catches);
|
||||
JsBlock finallyCopy = AstUtil.deepCopy(finallyBlock);
|
||||
|
||||
return new JsTry(tryCopy, catchCopy, finallyCopy);
|
||||
return new JsTry(tryCopy, catchCopy, finallyCopy).withMetadataFrom(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public class JsVars extends SourceInfoAwareJsNode implements JsStatement, Iterab
|
||||
public JsVar deepCopy() {
|
||||
if (initExpression == null) return new JsVar(name);
|
||||
|
||||
return new JsVar(name, initExpression.deepCopy());
|
||||
return new JsVar(name, initExpression.deepCopy()).withMetadataFrom(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,6 +162,6 @@ public class JsVars extends SourceInfoAwareJsNode implements JsStatement, Iterab
|
||||
@NotNull
|
||||
@Override
|
||||
public JsVars deepCopy() {
|
||||
return new JsVars(AstUtil.deepCopy(vars), multiline);
|
||||
return new JsVars(AstUtil.deepCopy(vars), multiline).withMetadataFrom(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,6 +64,6 @@ public class JsWhile extends SourceInfoAwareJsNode implements JsStatement {
|
||||
JsExpression conditionCopy = AstUtil.deepCopy(condition);
|
||||
JsStatement bodyCopy = AstUtil.deepCopy(body);
|
||||
|
||||
return new JsWhile(conditionCopy, bodyCopy);
|
||||
return new JsWhile(conditionCopy, bodyCopy).withMetadataFrom(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user