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

Unified Diff: pkg/dart_messages/bin/publish.dart

Issue 1700243002: Share const-error messages. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Use double-quotes Created 4 years, 10 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/dart_messages/bin/publish.dart
diff --git a/pkg/dart_messages/bin/publish.dart b/pkg/dart_messages/bin/publish.dart
index 4b497b8113323e9908a9146240217e04e536399c..acba54f4371238ab979f35e7d29eb5eeb1fe2922 100644
--- a/pkg/dart_messages/bin/publish.dart
+++ b/pkg/dart_messages/bin/publish.dart
@@ -112,17 +112,25 @@ void emitDart2js() {
}
if (message.examples != null) {
out.writeln(",\n examples: const [");
+
+ String escapeExampleContent(String content) {
+ if (content.contains("\n") || content.contains('"')) {
+ return 'r"""\n$content"""';
+ } else if (content.contains("\\")) {
+ return 'r"$content"';
+ }
+ return '"$content"';
+ }
for (var example in message.examples) {
if (example is String) {
- out.writeln(" r'''");
- out.write(example);
- out.write("'''");
+ out.write(" ");
+ out.write(escapeExampleContent(example));
} else if (example is Map) {
out.writeln(" const {");
example.forEach((String fileName, String content) {
- out.writeln(" '$fileName': r'''");
- out.write(content);
- out.writeln("''',");
+ out.writeln(" '$fileName': ");
+ out.write(escapeExampleContent(content));
+ out.writeln(",");
});
out.write(" }");
}
« no previous file with comments | « pkg/compiler/lib/src/diagnostics/messages.dart ('k') | pkg/dart_messages/lib/generated/shared_messages.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698