| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 | 4 |
| 5 // Check the validity of string literals. | 5 // Check the validity of string literals. |
| 6 | 6 |
| 7 #library("stringvalidator"); | 7 library stringvalidator; |
| 8 | 8 |
| 9 #import("leg.dart"); | 9 import "dart2jslib.dart"; |
| 10 #import("scanner/scannerlib.dart"); | 10 import "tree/tree.dart"; |
| 11 #import("tree/tree.dart"); | 11 import "elements/elements.dart"; |
| 12 #import("elements/elements.dart"); | 12 import "util/characters.dart"; |
| 13 #import("util/characters.dart"); | 13 import "scanner/scannerlib.dart" show Token; |
| 14 | 14 |
| 15 class StringValidator { | 15 class StringValidator { |
| 16 final DiagnosticListener listener; | 16 final DiagnosticListener listener; |
| 17 | 17 |
| 18 StringValidator(this.listener); | 18 StringValidator(this.listener); |
| 19 | 19 |
| 20 DartString validateQuotedString(Token token) { | 20 DartString validateQuotedString(Token token) { |
| 21 SourceString source = token.value; | 21 SourceString source = token.value; |
| 22 StringQuoting quoting = quotingFromString(source); | 22 StringQuoting quoting = quotingFromString(source); |
| 23 int leftQuote = quoting.leftQuoteLength; | 23 int leftQuote = quoting.leftQuoteLength; |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 } | 178 } |
| 179 } | 179 } |
| 180 // String literal successfully validated. | 180 // String literal successfully validated. |
| 181 if (quoting.raw || !containsEscape) { | 181 if (quoting.raw || !containsEscape) { |
| 182 // A string without escapes could just as well have been raw. | 182 // A string without escapes could just as well have been raw. |
| 183 return new DartString.rawString(string, length); | 183 return new DartString.rawString(string, length); |
| 184 } | 184 } |
| 185 return new DartString.escapedString(string, length); | 185 return new DartString.escapedString(string, length); |
| 186 } | 186 } |
| 187 } | 187 } |
| OLD | NEW |