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

Side by Side Diff: lib/text/ast_to_text.dart

Issue 2500453002: Fix a bug in printing of string literals with escape sequences. (Closed)
Patch Set: Add testcase Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | testcases/input/stringliteral.dart » ('j') | testcases/input/stringliteral.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 library kernel.ast_to_text; 4 library kernel.ast_to_text;
5 5
6 import '../ast.dart'; 6 import '../ast.dart';
7 import '../import_table.dart'; 7 import '../import_table.dart';
8 import '../type_propagation/type_propagation.dart'; 8 import '../type_propagation/type_propagation.dart';
9 9
10 class Namer<T> { 10 class Namer<T> {
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 } 832 }
833 } 833 }
834 834
835 String escapeString(String string) { 835 String escapeString(String string) {
836 StringBuffer buffer; 836 StringBuffer buffer;
837 for (int i = 0; i < string.length; ++i) { 837 for (int i = 0; i < string.length; ++i) {
838 String character = getEscapedCharacter(string.codeUnitAt(i)); 838 String character = getEscapedCharacter(string.codeUnitAt(i));
839 if (character != null) { 839 if (character != null) {
840 buffer ??= new StringBuffer(string.substring(0, i)); 840 buffer ??= new StringBuffer(string.substring(0, i));
841 buffer.write(character); 841 buffer.write(character);
842 } else {
843 buffer?.write(string[i]);
842 } 844 }
843 } 845 }
844 return buffer == null ? string : buffer.toString(); 846 return buffer == null ? string : buffer.toString();
845 } 847 }
846 848
847 visitStringConcatenation(StringConcatenation node) { 849 visitStringConcatenation(StringConcatenation node) {
848 if (state == WORD) { 850 if (state == WORD) {
849 writeSpace(); 851 writeSpace();
850 } 852 }
851 write('"'); 853 write('"');
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
1522 } 1524 }
1523 throw 'illegal ProcedureKind: $kind'; 1525 throw 'illegal ProcedureKind: $kind';
1524 } 1526 }
1525 1527
1526 class ExpressionPrinter { 1528 class ExpressionPrinter {
1527 final Printer writeer; 1529 final Printer writeer;
1528 final int minimumPrecedence; 1530 final int minimumPrecedence;
1529 1531
1530 ExpressionPrinter(this.writeer, this.minimumPrecedence); 1532 ExpressionPrinter(this.writeer, this.minimumPrecedence);
1531 } 1533 }
OLDNEW
« no previous file with comments | « no previous file | testcases/input/stringliteral.dart » ('j') | testcases/input/stringliteral.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698