merge js formatter from HEAD
diff --git a/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/FormatterNodeBuilder.java b/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/FormatterNodeBuilder.java
index 9ec5813..c1ca932 100644
--- a/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/FormatterNodeBuilder.java
+++ b/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/FormatterNodeBuilder.java
@@ -80,7 +80,6 @@
import org.eclipse.dltk.javascript.ast.XmlAttributeIdentifier;
import org.eclipse.dltk.javascript.ast.XmlLiteral;
import org.eclipse.dltk.javascript.ast.YieldOperator;
-import org.eclipse.dltk.javascript.formatter.JavaScriptFormatterConstants;
import org.eclipse.dltk.javascript.formatter.internal.nodes.AbstractParensConfiguration;
import org.eclipse.dltk.javascript.formatter.internal.nodes.ArrayBracketsConfiguration;
import org.eclipse.dltk.javascript.formatter.internal.nodes.BinaryOperationPinctuationConfiguration;
@@ -296,31 +295,10 @@
caseNode.setBegin(createTextNode(document, node.getKeyword()));
push(caseNode);
visit(node.getCondition());
- IFormatterTextNode colon = createCharNode(document, node
- .getColonPosition());
- if (!JavaScriptFormatterConstants.BRACE_SAME_LINE
- .equals(document
- .getString(JavaScriptFormatterConstants.BRACE_CASE))) {
- colon = new ColonNodeWrapper(colon);
- }
- caseNode.addChild(colon);
- checkedPop(caseNode, node.getColonPosition() + 1);
+ caseNode.addChild(new ColonNodeWrapper(createCharNode(document,
+ node.getColonPosition())));
- CaseBracesConfiguration configuration = new CaseBracesConfiguration(
- document);
- final FormatterBlockNode block = new FormatterIndentedBlockNode(
- document, configuration.isIndenting());
- block.addChild(createEmptyTextNode(document, node
- .getColonPosition() + 1));
- push(block);
- if (node.getStatements().size() == 1
- && node.getStatements().get(0) instanceof StatementBlock) {
- processBraces(node.getStatements().get(0), configuration);
- } else {
- visit(node.getStatements());
- }
- checkedPop(block, node.sourceEnd());
- return true;
+ return processSwitchComponent(caseNode, node);
}
public boolean visitDefaultClause(DefaultClause node) {
@@ -330,17 +308,22 @@
push(defaultNode);
defaultNode.addChild(new ColonNodeWrapper(createCharNode(
document, node.getColonPosition())));
- checkedPop(defaultNode, node.getColonPosition() + 1);
- CaseBracesConfiguration configuration = new CaseBracesConfiguration(
- document);
- final FormatterBlockNode block = new FormatterIndentedBlockNode(
- document, configuration.isIndenting());
- block.addChild(createEmptyTextNode(document, node
- .getColonPosition() + 1));
- push(block);
- visit(node.getStatements());
- checkedPop(block, node.sourceEnd());
+ return processSwitchComponent(defaultNode, node);
+ }
+
+ private boolean processSwitchComponent(FormatterCaseNode caseNode,
+ SwitchComponent node) {
+ if (node.getStatements().size() == 1
+ && node.getStatements().get(0) instanceof StatementBlock) {
+ CaseBracesConfiguration configuration = new CaseBracesConfiguration(
+ document);
+ caseNode.setIndenting(false);
+ processBraces(node.getStatements().get(0), configuration);
+ } else {
+ visit(node.getStatements());
+ }
+ checkedPop(caseNode, node.sourceEnd());
return true;
}
diff --git a/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/AbstractBracesConfiguration.java b/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/AbstractBracesConfiguration.java
index 08acaf0..aca2e45 100644
--- a/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/AbstractBracesConfiguration.java
+++ b/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/AbstractBracesConfiguration.java
@@ -95,13 +95,13 @@
private static final String describe(int value) {
switch (value) {
case UNDEFINED:
- return "UNDEFINED";
+ return "UNDEFINED"; //$NON-NLS-1$
case ONE_SPACE:
- return "ONE_SPACE";
+ return "ONE_SPACE"; //$NON-NLS-1$
case LINE_BREAK:
- return "LINE_BREAK";
+ return "LINE_BREAK"; //$NON-NLS-1$
case EMPTY_SPACE:
- return "EMPTY_SPACE";
+ return "EMPTY_SPACE"; //$NON-NLS-1$
default:
return String.valueOf(value);
}
@@ -109,10 +109,10 @@
@Override
public String toString() {
- return "beforeOpenBrace=" + describe(insertBeforeOpenBrace())
- + ", afterOpenBrace=" + describe(insertAfterOpenBrace())
- + ", beforeCloseBrace=" + describe(insertBeforeCloseBrace())
- + ", afterCloseBrace=" + describe(insertAfterCloseBrace());
+ return "beforeOpenBrace=" + describe(insertBeforeOpenBrace()) //$NON-NLS-1$
+ + ", afterOpenBrace=" + describe(insertAfterOpenBrace()) //$NON-NLS-1$
+ + ", beforeCloseBrace=" + describe(insertBeforeCloseBrace()) //$NON-NLS-1$
+ + ", afterCloseBrace=" + describe(insertAfterCloseBrace()); //$NON-NLS-1$
}
}
diff --git a/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/BracesNode.java b/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/BracesNode.java
index da47b4f..9b2577f 100644
--- a/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/BracesNode.java
+++ b/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/BracesNode.java
@@ -12,8 +12,6 @@
package org.eclipse.dltk.javascript.formatter.internal.nodes;
-import java.util.List;
-
import org.eclipse.core.runtime.Assert;
import org.eclipse.dltk.formatter.IFormatterContext;
import org.eclipse.dltk.formatter.IFormatterDocument;
@@ -55,7 +53,14 @@
printAfterOpenBrace(context, visitor);
// print body
+ final boolean indenting = isIndenting();
+ if (indenting) {
+ context.incIndent();
+ }
acceptBody(context, visitor);
+ if (indenting) {
+ context.decIndent();
+ }
printBeforeCloseBrace(context, visitor);
@@ -153,20 +158,7 @@
}
}
- protected void acceptNodes(final List<IFormatterNode> nodes,
- IFormatterContext context, IFormatterWriter visitor)
- throws Exception {
-
- if (isIndenting())
- context.incIndent();
-
- super.acceptNodes(nodes, context, visitor);
-
- if (isIndenting())
- context.decIndent();
-
- }
-
+ @Override
protected boolean isIndenting() {
return configuration.isIndenting();
}
diff --git a/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/BracketsNode.java b/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/BracketsNode.java
index 371b768..b3901bd 100644
--- a/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/BracketsNode.java
+++ b/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/BracketsNode.java
@@ -33,6 +33,7 @@
this.configuration = configuration;
}
+ @Override
public void accept(IFormatterContext context, IFormatterWriter visitor)
throws Exception {
@@ -66,9 +67,10 @@
}
- protected void acceptNodes(final List<IFormatterNode> nodes,
- IFormatterContext context, IFormatterWriter visitor)
- throws Exception {
+ @SuppressWarnings("unchecked")
+ @Override
+ protected void acceptNodes(final List nodes, IFormatterContext context,
+ IFormatterWriter visitor) throws Exception {
if (isIndenting())
context.incIndent();
@@ -80,6 +82,7 @@
}
+ @Override
protected boolean isIndenting() {
return configuration.isIndenting();
}
diff --git a/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/CaseBracesConfiguration.java b/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/CaseBracesConfiguration.java
index 74234e4..5b60aaf 100644
--- a/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/CaseBracesConfiguration.java
+++ b/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/CaseBracesConfiguration.java
@@ -20,8 +20,12 @@
public CaseBracesConfiguration(IFormatterDocument document) {
super(document);
- indentingSettingName = JavaScriptFormatterConstants.INDENT_CASE;
bracesSettingName = JavaScriptFormatterConstants.BRACE_CASE;
}
+ @Override
+ public boolean isIndenting() {
+ return true;
+ }
+
}
diff --git a/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/ColonNodeWrapper.java b/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/ColonNodeWrapper.java
new file mode 100644
index 0000000..23d22ef
--- /dev/null
+++ b/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/ColonNodeWrapper.java
@@ -0,0 +1,27 @@
+package org.eclipse.dltk.javascript.formatter.internal.nodes;
+
+import org.eclipse.dltk.formatter.IFormatterContext;
+import org.eclipse.dltk.formatter.IFormatterTextNode;
+import org.eclipse.dltk.formatter.IFormatterWriter;
+import org.eclipse.dltk.javascript.formatter.JavaScriptFormatterConstants;
+
+public class ColonNodeWrapper extends FormatterTextNodeWrapper {
+
+ public ColonNodeWrapper(IFormatterTextNode target) {
+ super(target);
+ }
+
+ @Override
+ public void accept(IFormatterContext context, IFormatterWriter visitor)
+ throws Exception {
+ super.accept(context, visitor);
+ if (!JavaScriptFormatterConstants.BRACE_SAME_LINE.equals(target
+ .getDocument().getString(
+ JavaScriptFormatterConstants.BRACE_CASE))) {
+ context.setBlankLines(-1);
+ visitor.writeLineBreak(context);
+ visitor.skipNextLineBreaks(context);
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/DoLoopWhileWrapper.java b/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/DoLoopWhileWrapper.java
new file mode 100644
index 0000000..405573f
--- /dev/null
+++ b/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/DoLoopWhileWrapper.java
@@ -0,0 +1,25 @@
+package org.eclipse.dltk.javascript.formatter.internal.nodes;
+
+import org.eclipse.dltk.formatter.IFormatterContext;
+import org.eclipse.dltk.formatter.IFormatterTextNode;
+import org.eclipse.dltk.formatter.IFormatterWriter;
+import org.eclipse.dltk.javascript.formatter.JavaScriptFormatterConstants;
+
+public class DoLoopWhileWrapper extends FormatterTextNodeWrapper {
+
+ public DoLoopWhileWrapper(IFormatterTextNode target) {
+ super(target);
+ }
+
+ @Override
+ public void accept(IFormatterContext context, IFormatterWriter visitor)
+ throws Exception {
+ if (!target.getDocument().getBoolean(
+ JavaScriptFormatterConstants.NEW_LINE_BEFORE_WHILE_IN_DO)) {
+ visitor.appendToPreviousLine(context, JSLiterals.EMPTY);
+ visitor.writeText(context, JSLiterals.SPACE);
+ }
+ super.accept(context, visitor);
+ }
+
+}
diff --git a/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/FormatterBlockWithBeginEndNode.java b/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/FormatterBlockWithBeginEndNode.java
index f4e75ce..58dac1d 100644
--- a/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/FormatterBlockWithBeginEndNode.java
+++ b/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/FormatterBlockWithBeginEndNode.java
@@ -35,6 +35,7 @@
private List<IFormatterNode> begin = null;
private IFormatterTextNode end;
+ @Override
public void accept(IFormatterContext context, IFormatterWriter visitor)
throws Exception {
context.setBlankLines(getBlankLinesBefore(context));
@@ -70,7 +71,7 @@
* @return the begin
*/
public IFormatterNode[] getBegin() {
- return FormatterUtils.toTextNodeArray(begin);
+ return FormatterUtils.toNodeArray(begin);
}
/**
@@ -108,6 +109,7 @@
/*
* @see FormatterBlockNode#getStartOffset()
*/
+ @Override
public int getStartOffset() {
if (begin != null) {
return ((IFormatterTextNode) begin.get(0)).getStartOffset();
@@ -118,6 +120,7 @@
/*
* @see FormatterBlockNode#getEndOffset()
*/
+ @Override
public int getEndOffset() {
if (end != null) {
return end.getEndOffset();
@@ -135,6 +138,7 @@
/*
* @see FormatterBlockNode#isEmpty()
*/
+ @Override
public boolean isEmpty() {
return begin == null && end == null && super.isEmpty();
}
@@ -142,6 +146,7 @@
/*
* @see FormatterBlockNode#getChildren()
*/
+ @Override
public List<IFormatterNode> getChildren() {
if (begin == null && end == null) {
return super.getChildren();
@@ -161,6 +166,7 @@
/*
* @see FormatterBlockNode#toString()
*/
+ @Override
public String toString() {
return begin + "\n" + super.toString() + "\n" + end; //$NON-NLS-1$ //$NON-NLS-2$
}
diff --git a/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/FormatterCaseNode.java b/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/FormatterCaseNode.java
index 6b8e425..b567a3c 100644
--- a/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/FormatterCaseNode.java
+++ b/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/FormatterCaseNode.java
@@ -17,12 +17,20 @@
public class FormatterCaseNode extends FormatterBlockWithBeginEndNode {
+ private boolean indenting;
+
public FormatterCaseNode(IFormatterDocument document) {
super(document);
+ indenting = document
+ .getBoolean(JavaScriptFormatterConstants.INDENT_CASE);
}
- protected boolean isIndenting() {
- return getDocument().getBoolean(
- JavaScriptFormatterConstants.INDENT_CASE);
+ @Override
+ public boolean isIndenting() {
+ return indenting;
+ }
+
+ public void setIndenting(boolean value) {
+ this.indenting = value;
}
}
diff --git a/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/FormatterTextNodeWrapper.java b/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/FormatterTextNodeWrapper.java
new file mode 100644
index 0000000..3ea803e
--- /dev/null
+++ b/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/FormatterTextNodeWrapper.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2009 xored software, Inc.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * xored software, Inc. - initial API and Implementation (Alex Panchenko)
+ *******************************************************************************/
+package org.eclipse.dltk.javascript.formatter.internal.nodes;
+
+import org.eclipse.dltk.formatter.IFormatterContext;
+import org.eclipse.dltk.formatter.IFormatterDocument;
+import org.eclipse.dltk.formatter.IFormatterTextNode;
+import org.eclipse.dltk.formatter.IFormatterWriter;
+
+public class FormatterTextNodeWrapper implements IFormatterTextNode {
+
+ protected final IFormatterTextNode target;
+
+ public FormatterTextNodeWrapper(IFormatterTextNode target) {
+ this.target = target;
+ }
+
+ public String getText() {
+ return target.getText();
+ }
+
+ public void accept(IFormatterContext context, IFormatterWriter visitor)
+ throws Exception {
+ target.accept(context, visitor);
+ }
+
+ public IFormatterDocument getDocument() {
+ return target.getDocument();
+ }
+
+ public int getEndOffset() {
+ return target.getEndOffset();
+ }
+
+ public int getStartOffset() {
+ return target.getStartOffset();
+ }
+
+ public boolean isEmpty() {
+ return target.isEmpty();
+ }
+
+ @Override
+ public String toString() {
+ return target.toString();
+ }
+
+}
diff --git a/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/FormatterVirtualLineBreakNode.java b/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/FormatterVirtualLineBreakNode.java
deleted file mode 100644
index d8a2974..0000000
--- a/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/FormatterVirtualLineBreakNode.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 xored software, Inc.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * xored software, Inc. - initial API and Implementation (Vladimir Belov)
- *******************************************************************************/
-
-package org.eclipse.dltk.javascript.formatter.internal.nodes;
-
-import org.eclipse.dltk.formatter.FormatterTextNode;
-import org.eclipse.dltk.formatter.IFormatterContext;
-import org.eclipse.dltk.formatter.IFormatterDocument;
-import org.eclipse.dltk.formatter.IFormatterWriter;
-
-public class FormatterVirtualLineBreakNode extends FormatterTextNode {
-
- public FormatterVirtualLineBreakNode(IFormatterDocument document,
- int startOffset, int endOffset) {
- super(document, startOffset, endOffset);
- }
-
- public void accept(IFormatterContext context, IFormatterWriter visitor)
- throws Exception {
- visitor.writeLineBreak(context);
- }
-
- public String getText() {
- return "\n";
- }
-
-}
diff --git a/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/FormatterVirtualTextNode.java b/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/FormatterVirtualTextNode.java
deleted file mode 100644
index 7db5767..0000000
--- a/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/FormatterVirtualTextNode.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 xored software, Inc.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * xored software, Inc. - initial API and Implementation (Vladimir Belov)
- *******************************************************************************/
-
-package org.eclipse.dltk.javascript.formatter.internal.nodes;
-
-import org.eclipse.dltk.formatter.FormatterTextNode;
-import org.eclipse.dltk.formatter.IFormatterContext;
-import org.eclipse.dltk.formatter.IFormatterDocument;
-import org.eclipse.dltk.formatter.IFormatterWriter;
-
-public class FormatterVirtualTextNode extends FormatterTextNode {
-
- private String text;
-
- public FormatterVirtualTextNode(IFormatterDocument document,
- int startOffset, int endOffset, String text) {
- super(document, startOffset, endOffset);
- this.text = text;
- }
-
- public void accept(IFormatterContext context, IFormatterWriter visitor)
- throws Exception {
- visitor.writeText(context, text);
- }
-
- public String getText() {
- return this.text;
- }
-
- public String toString() {
- return getText();
- }
-}
diff --git a/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/JSLiterals.java b/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/JSLiterals.java
new file mode 100644
index 0000000..3f59d26
--- /dev/null
+++ b/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/formatter/internal/nodes/JSLiterals.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2009 xored software, Inc.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * xored software, Inc. - initial API and Implementation (Alex Panchenko)
+ *******************************************************************************/
+package org.eclipse.dltk.javascript.formatter.internal.nodes;
+
+import org.eclipse.dltk.compiler.util.Util;
+
+public class JSLiterals {
+ public static final String EMPTY = Util.EMPTY_STRING;
+ public static final String SPACE = " "; //$NON-NLS-1$
+ public static final String EOL = "\n"; //$NON-NLS-1$
+ public static final String SEMICOLON = ";"; //$NON-NLS-1$
+}
diff --git a/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/parser/JSTransformer.java b/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/parser/JSTransformer.java
index 14f4da8..36dee5e 100644
--- a/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/parser/JSTransformer.java
+++ b/plugins/org.eclipse.dltk.javascript.formatter/src/org/eclipse/dltk/javascript/parser/JSTransformer.java
@@ -782,7 +782,7 @@
returnStatement.setEnd(returnStatement.getSemicolonPosition() + 1);
} else if (returnStatement.getValue() != null) {
- returnStatement.setEnd(returnStatement.getValue().sourceEnd() + 1);
+ returnStatement.setEnd(returnStatement.getValue().sourceEnd());
} else {
returnStatement.setEnd(returnStatement.getReturnKeyword()
.sourceEnd());
diff --git a/plugins/org.eclipse.dltk.javascript.parser/src/org/eclipse/dltk/javascript/parser/JSTransformer.java b/plugins/org.eclipse.dltk.javascript.parser/src/org/eclipse/dltk/javascript/parser/JSTransformer.java
index 14f4da8..36dee5e 100644
--- a/plugins/org.eclipse.dltk.javascript.parser/src/org/eclipse/dltk/javascript/parser/JSTransformer.java
+++ b/plugins/org.eclipse.dltk.javascript.parser/src/org/eclipse/dltk/javascript/parser/JSTransformer.java
@@ -782,7 +782,7 @@
returnStatement.setEnd(returnStatement.getSemicolonPosition() + 1);
} else if (returnStatement.getValue() != null) {
- returnStatement.setEnd(returnStatement.getValue().sourceEnd() + 1);
+ returnStatement.setEnd(returnStatement.getValue().sourceEnd());
} else {
returnStatement.setEnd(returnStatement.getReturnKeyword()
.sourceEnd());