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

Unified Diff: pkg/analyzer/lib/src/generated/parser.dart

Issue 189433006: Support for DartBlockBody, DartExpressionBody, DartOmit in java2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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: pkg/analyzer/lib/src/generated/parser.dart
diff --git a/pkg/analyzer/lib/src/generated/parser.dart b/pkg/analyzer/lib/src/generated/parser.dart
index 42a52424a0300a19c74afee7cac618dcc11a5215..dd4627993bbbdd04680f05d57c92e435495d6f1e 100644
--- a/pkg/analyzer/lib/src/generated/parser.dart
+++ b/pkg/analyzer/lib/src/generated/parser.dart
@@ -8563,6 +8563,10 @@ class ResolutionCopier implements AstVisitor<bool> {
class ToFormattedSourceVisitor implements AstVisitor<Object> {
Brian Wilkerson 2014/03/07 16:12:31 I don't understand why this class is here. It is p
scheglov 2014/03/07 22:47:44 You are right. I used it once about a year ago, bu
static String COMMENTS_KEY = "List of comments before statement";
+ static String BLOCK_BODY_KEY = "Block body source";
+
+ static String EXPRESSION_BODY_KEY = "Expression body source";
+
/**
* The writer to which the source is to be written.
*/
@@ -9161,10 +9165,25 @@ class ToFormattedSourceVisitor implements AstVisitor<Object> {
if (!node.isGetter) {
visitNode(node.parameters);
}
- if (node.body is! EmptyFunctionBody) {
- _writer.print(' ');
+ String bodySource;
+ if ((bodySource = node.getProperty(BLOCK_BODY_KEY) as String) != null) {
+ _writer.print(" {");
+ if (!bodySource.isEmpty) {
+ nl();
+ _writer.print(bodySource);
+ }
+ nl2();
+ _writer.print('}');
+ } else if ((bodySource = node.getProperty(EXPRESSION_BODY_KEY) as String) != null) {
+ _writer.print(" => ");
+ _writer.print(bodySource);
+ _writer.print(';');
+ } else {
+ if (node.body is! EmptyFunctionBody) {
+ _writer.print(' ');
+ }
+ visitNode(node.body);
}
- visitNode(node.body);
return null;
}

Powered by Google App Engine
This is Rietveld 408576698