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

Unified Diff: sdk/lib/_internal/compiler/implementation/dart_backend/dart_printer.dart

Issue 336413002: Allow whitespace and \ before the first newline of multiline string. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use more intuitive test. 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
Index: sdk/lib/_internal/compiler/implementation/dart_backend/dart_printer.dart
diff --git a/sdk/lib/_internal/compiler/implementation/dart_backend/dart_printer.dart b/sdk/lib/_internal/compiler/implementation/dart_backend/dart_printer.dart
index f9757db86140af75f5b2f10b64ca89ba0e432b19..fb4b241fba64692d20ca8531eb758351d014bf1d 100644
--- a/sdk/lib/_internal/compiler/implementation/dart_backend/dart_printer.dart
+++ b/sdk/lib/_internal/compiler/implementation/dart_backend/dart_printer.dart
@@ -1239,6 +1239,17 @@ class Unparser {
}
}
+ /// A list of string quotings that the printer may use to quote strings.
+ // Ignore multiline quotings for now. Would need to make sure that no
+ // newline (potentially prefixed by whitespace) follows the quoting.
+ // TODO(asgerf): Include multiline quotation schemes.
+ static const _QUOTINGS = const <tree.StringQuoting>[
+ const tree.StringQuoting(characters.$DQ, raw: false, leftQuoteLength: 1),
+ const tree.StringQuoting(characters.$DQ, raw: true, leftQuoteLength: 1),
+ const tree.StringQuoting(characters.$SQ, raw: false, leftQuoteLength: 1),
+ const tree.StringQuoting(characters.$SQ, raw: true, leftQuoteLength: 1),
+ ];
+
static StringLiteralOutput analyzeStringLiteral(Expression node) {
// TODO(asgerf): This might be a bit too expensive. Benchmark.
// Flatten the StringConcat tree.
@@ -1281,11 +1292,7 @@ class Unparser {
List<int> nonRaws = <int>[];
List<int> sqs = <int>[];
List<int> dqs = <int>[];
- for (tree.StringQuoting q in tree.StringQuoting.mapping) {
- // Ignore multiline quotings for now. Encoding of line breaks is unclear.
- // TODO(asgerf): Include multiline quotation schemes.
- if (q.leftQuoteCharCount >= 3)
- continue;
+ for (tree.StringQuoting q in _QUOTINGS) {
OpenStringChunk chunk = new OpenStringChunk(null, q, getQuoteCost(q));
int index = best.length;
best.add(chunk);

Powered by Google App Engine
This is Rietveld 408576698