Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Unified Diff: editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/formatter/CodeFormatterVisitor.java

Issue 10913197: Convert throw from a statement to an expression (issue 4872) (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/formatter/CodeFormatterVisitor.java
===================================================================
--- editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/formatter/CodeFormatterVisitor.java (revision 12211)
+++ editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/formatter/CodeFormatterVisitor.java (working copy)
@@ -79,7 +79,7 @@
import com.google.dart.compiler.ast.DartSyntheticErrorExpression;
import com.google.dart.compiler.ast.DartSyntheticErrorStatement;
import com.google.dart.compiler.ast.DartThisExpression;
-import com.google.dart.compiler.ast.DartThrowStatement;
+import com.google.dart.compiler.ast.DartThrowExpression;
import com.google.dart.compiler.ast.DartTryStatement;
import com.google.dart.compiler.ast.DartTypeExpression;
import com.google.dart.compiler.ast.DartTypeNode;
@@ -1909,7 +1909,7 @@
}
@Override
- public DartNode visitThrowStatement(DartThrowStatement throwStatement) {
+ public DartNode visitThrowExpression(DartThrowExpression throwStatement) {
scribe.printNextToken(Token.THROW);
DartExpression expression = throwStatement.getException();
final int numberOfParens = countParens(expression);
@@ -1918,11 +1918,6 @@
scribe.space();
}
expression.accept(this);
- /*
- * Print the semi-colon
- */
- scribe.printNextToken(Token.SEMICOLON, preferences.insert_space_before_semicolon);
- scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT);
return null;
}
@@ -3456,9 +3451,12 @@
return !commentStartsBlock(
block.getSourceInfo().getOffset(),
block.getSourceInfo().getLength() + block.getSourceInfo().getOffset()) &&
- block.getStatements() != null && block.getStatements().size() == 1 && (
- block.getStatements().get(0) instanceof DartReturnStatement
- || block.getStatements().get(0) instanceof DartThrowStatement);
+ block.getStatements() != null && block.getStatements().size() == 1
+ && (
+ block.getStatements().get(0) instanceof DartReturnStatement || (
+ block.getStatements().get(0) instanceof DartExprStmt
+ && (((DartExprStmt) block.getStatements().get(0))
+ .getExpression() instanceof DartThrowExpression)));
}
private boolean isMultipleLocalDeclaration(DartVariableStatement localDeclaration) {

Powered by Google App Engine
This is Rietveld 408576698