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

Unified Diff: editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/util/ToFormattedSourceVisitor.java

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: editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/util/ToFormattedSourceVisitor.java
diff --git a/editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/util/ToFormattedSourceVisitor.java b/editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/util/ToFormattedSourceVisitor.java
index d3e6990bc18c35a216029603bb00e6275a890ed4..1bd4d3d128ce7cbfd3d230686a09504055c8ade6 100644
--- a/editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/util/ToFormattedSourceVisitor.java
+++ b/editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/util/ToFormattedSourceVisitor.java
@@ -28,6 +28,8 @@ import java.util.List;
*/
public class ToFormattedSourceVisitor implements AstVisitor<Void> {
public static final String COMMENTS_KEY = "List of comments before statement";
+ public static final String BLOCK_BODY_KEY = "Block body source";
+ public static final String EXPRESSION_BODY_KEY = "Expression body source";
/**
* The writer to which the source is to be written.
@@ -691,10 +693,25 @@ public class ToFormattedSourceVisitor implements AstVisitor<Void> {
if (!node.isGetter()) {
visitNode(node.getParameters());
}
- if (!(node.getBody() instanceof EmptyFunctionBody)) {
- writer.print(' ');
+ String bodySource;
+ if ((bodySource = (String) node.getProperty(BLOCK_BODY_KEY)) != null) {
+ writer.print(" {");
+ if (!bodySource.isEmpty()) {
+ nl();
+ writer.print(bodySource);
+ }
+ nl2();
+ writer.print('}');
+ } else if ((bodySource = (String) node.getProperty(EXPRESSION_BODY_KEY)) != null) {
+ writer.print(" => ");
+ writer.print(bodySource);
+ writer.print(';');
+ } else {
+ if (!(node.getBody() instanceof EmptyFunctionBody)) {
+ writer.print(' ');
+ }
+ visitNode(node.getBody());
}
- visitNode(node.getBody());
return null;
}

Powered by Google App Engine
This is Rietveld 408576698