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

Unified Diff: pkg/analyzer/lib/src/services/writer.dart

Issue 322563002: Formatter: fix for long multiline strings. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes for review comments. Created 6 years, 6 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
« no previous file with comments | « no previous file | pkg/analyzer/test/services/formatter_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/services/writer.dart
diff --git a/pkg/analyzer/lib/src/services/writer.dart b/pkg/analyzer/lib/src/services/writer.dart
index d1437482530c66388d246ac3d3cf1f60f8ce7e20..cf0dd74718aaa05917a1b55124c04cfadd0987a8 100644
--- a/pkg/analyzer/lib/src/services/writer.dart
+++ b/pkg/analyzer/lib/src/services/writer.dart
@@ -350,8 +350,18 @@ class SourceWriter {
}
}
- void write(x) {
- _addToken(new LineToken(x));
+ void write(String string) {
+ var lines = string.split(lineSeparator);
+ var length = lines.length;
+ for (int i = 0; i < length; i++) {
+ var line = lines[i];
+ _addToken(new LineToken(line));
+ if (i != length - 1) {
+ newline();
+ // no indentation for multi-line strings
+ currentLine.clear();
+ }
+ }
}
void writeln(String s) {
« no previous file with comments | « no previous file | pkg/analyzer/test/services/formatter_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698