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

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

Issue 624403002: Write end-of-block comments. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 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 a6f4e2460e6d3f53ff773655dac817e376b06fc6..e5f58a3887a1cd35d5206d1949b009195a1a256a 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
@@ -27,7 +27,8 @@ import java.util.List;
* AST node (and all of it's children) to a writer.
*/
public class ToFormattedSourceVisitor implements AstVisitor<Void> {
- public static final String COMMENTS_KEY = "List of comments before statement";
+ public static final String COMMENTS_BEFORE_STATEMENT = "List of comments before statement";
+ public static final String COMMENTS_AT_BLOCK_END = "List of comments at the end of block";
public static final String BLOCK_BODY_KEY = "Block body source";
public static final String EXPRESSION_BODY_KEY = "Expression body source";
public static final String DEFAULT_VALUE_KEY = "Default parameter value";
@@ -122,6 +123,7 @@ public class ToFormattedSourceVisitor implements AstVisitor<Void> {
{
indentInc();
visitNodeListWithSeparatorAndPrefix("\n", node.getStatements(), "\n");
+ printTrailingComments(node);
indentDec();
}
nl2();
@@ -1127,14 +1129,25 @@ public class ToFormattedSourceVisitor implements AstVisitor<Void> {
@SuppressWarnings("unchecked")
private void printLeadingComments(Statement statement) {
- List<String> comments = (List<String>) statement.getProperty(COMMENTS_KEY);
+ List<String> comments = (List<String>) statement.getProperty(COMMENTS_BEFORE_STATEMENT);
if (comments == null) {
return;
}
for (String comment : comments) {
writer.print(comment);
- writer.print("\n");
- indent();
+ nl2();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void printTrailingComments(Block block) {
+ List<String> comments = (List<String>) block.getProperty(COMMENTS_AT_BLOCK_END);
+ if (comments == null) {
+ return;
+ }
+ for (String comment : comments) {
+ nl2();
+ writer.print(comment);
}
}

Powered by Google App Engine
This is Rietveld 408576698