| 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("leg.dart"); |
| 10 #import("scanner/scannerlib.dart"); | 10 #import("scanner/scannerlib.dart"); |
| 11 #import("tree/tree.dart"); | 11 #import("tree/tree.dart"); |
| 12 #import("elements/elements.dart"); | 12 #import("elements/elements.dart"); |
| 13 #import("util/characters.dart"); | 13 #import("util/characters.dart"); |
| 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; |
| 24 int rightQuote = quoting.rightQuoteLength; | 24 int rightQuote = quoting.rightQuoteLength; |
| 25 SourceString content = source.copyWithoutQuotes(leftQuote, rightQuote); | 25 SourceString content = source.copyWithoutQuotes(leftQuote, rightQuote); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 } | 179 } |
| 180 } | 180 } |
| 181 // String literal successfully validated. | 181 // String literal successfully validated. |
| 182 if (quoting.raw || !containsEscape) { | 182 if (quoting.raw || !containsEscape) { |
| 183 // A string without escapes could just as well have been raw. | 183 // A string without escapes could just as well have been raw. |
| 184 return new DartString.rawString(string, length); | 184 return new DartString.rawString(string, length); |
| 185 } | 185 } |
| 186 return new DartString.escapedString(string, length); | 186 return new DartString.escapedString(string, length); |
| 187 } | 187 } |
| 188 } | 188 } |
| OLD | NEW |