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

Side by Side Diff: pkg/front_end/lib/src/fasta/quote.dart

Issue 2974933002: Remove deprecated_internalProblem. (Closed)
Patch Set: Created 3 years, 5 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 unified diff | Download patch
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 4
5 library fasta.quote; 5 library fasta.quote;
6 6
7 import 'deprecated_problems.dart' 7 import 'deprecated_problems.dart' show deprecated_inputError;
8 show deprecated_inputError, deprecated_internalProblem; 8
9 import 'problems.dart' show unhandled;
9 10
10 import 'scanner/characters.dart' 11 import 'scanner/characters.dart'
11 show 12 show
12 $BACKSLASH, 13 $BACKSLASH,
13 $BS, 14 $BS,
14 $CLOSE_CURLY_BRACKET, 15 $CLOSE_CURLY_BRACKET,
15 $CR, 16 $CR,
16 $FF, 17 $FF,
17 $LF, 18 $LF,
18 $OPEN_CURLY_BRACKET, 19 $OPEN_CURLY_BRACKET,
(...skipping 24 matching lines...) Expand all
43 44
44 Quote analyzeQuote(String first) { 45 Quote analyzeQuote(String first) {
45 if (first.startsWith('"""')) return Quote.MultiLineDouble; 46 if (first.startsWith('"""')) return Quote.MultiLineDouble;
46 if (first.startsWith('r"""')) return Quote.RawMultiLineDouble; 47 if (first.startsWith('r"""')) return Quote.RawMultiLineDouble;
47 if (first.startsWith("'''")) return Quote.MultiLineSingle; 48 if (first.startsWith("'''")) return Quote.MultiLineSingle;
48 if (first.startsWith("r'''")) return Quote.RawMultiLineSingle; 49 if (first.startsWith("r'''")) return Quote.RawMultiLineSingle;
49 if (first.startsWith('"')) return Quote.Double; 50 if (first.startsWith('"')) return Quote.Double;
50 if (first.startsWith('r"')) return Quote.RawDouble; 51 if (first.startsWith('r"')) return Quote.RawDouble;
51 if (first.startsWith("'")) return Quote.Single; 52 if (first.startsWith("'")) return Quote.Single;
52 if (first.startsWith("r'")) return Quote.RawSingle; 53 if (first.startsWith("r'")) return Quote.RawSingle;
53 return deprecated_internalProblem("Unexpected string literal: $first"); 54 return unhandled(first, "analyzeQuote", -1, null);
54 } 55 }
55 56
56 // Note: based on [StringValidator.quotingFromString] 57 // Note: based on [StringValidator.quotingFromString]
57 // (pkg/compiler/lib/src/string_validator.dart). 58 // (pkg/compiler/lib/src/string_validator.dart).
58 int lengthOfOptionalWhitespacePrefix(String first, int start) { 59 int lengthOfOptionalWhitespacePrefix(String first, int start) {
59 List<int> codeUnits = first.codeUnits; 60 List<int> codeUnits = first.codeUnits;
60 for (int i = start; i < codeUnits.length; i++) { 61 for (int i = start; i < codeUnits.length; i++) {
61 int code = codeUnits[i]; 62 int code = codeUnits[i];
62 if (code == $BACKSLASH) { 63 if (code == $BACKSLASH) {
63 i++; 64 i++;
(...skipping 29 matching lines...) Expand all
93 return lengthOfOptionalWhitespacePrefix(first, 3); 94 return lengthOfOptionalWhitespacePrefix(first, 3);
94 95
95 case Quote.RawSingle: 96 case Quote.RawSingle:
96 case Quote.RawDouble: 97 case Quote.RawDouble:
97 return 2; 98 return 2;
98 99
99 case Quote.RawMultiLineSingle: 100 case Quote.RawMultiLineSingle:
100 case Quote.RawMultiLineDouble: 101 case Quote.RawMultiLineDouble:
101 return lengthOfOptionalWhitespacePrefix(first, 4); 102 return lengthOfOptionalWhitespacePrefix(first, 4);
102 } 103 }
103 return deprecated_internalProblem("Unhandled string quote: $quote"); 104 return unhandled("$quote", "firstQuoteLength", -1, null);
104 } 105 }
105 106
106 int lastQuoteLength(Quote quote) { 107 int lastQuoteLength(Quote quote) {
107 switch (quote) { 108 switch (quote) {
108 case Quote.Single: 109 case Quote.Single:
109 case Quote.Double: 110 case Quote.Double:
110 case Quote.RawSingle: 111 case Quote.RawSingle:
111 case Quote.RawDouble: 112 case Quote.RawDouble:
112 return 1; 113 return 1;
113 114
114 case Quote.MultiLineSingle: 115 case Quote.MultiLineSingle:
115 case Quote.MultiLineDouble: 116 case Quote.MultiLineDouble:
116 case Quote.RawMultiLineSingle: 117 case Quote.RawMultiLineSingle:
117 case Quote.RawMultiLineDouble: 118 case Quote.RawMultiLineDouble:
118 return 3; 119 return 3;
119 } 120 }
120 return deprecated_internalProblem("Unhandled string quote: $quote"); 121 return unhandled("$quote", "lastQuoteLength", -1, null);
121 } 122 }
122 123
123 String unescapeFirstStringPart(String first, Quote quote) { 124 String unescapeFirstStringPart(String first, Quote quote) {
124 return unescape(first.substring(firstQuoteLength(first, quote)), quote); 125 return unescape(first.substring(firstQuoteLength(first, quote)), quote);
125 } 126 }
126 127
127 String unescapeLastStringPart(String last, Quote quote) { 128 String unescapeLastStringPart(String last, Quote quote) {
128 return unescape( 129 return unescape(
129 last.substring(0, last.length - lastQuoteLength(quote)), quote); 130 last.substring(0, last.length - lastQuoteLength(quote)), quote);
130 } 131 }
(...skipping 23 matching lines...) Expand all
154 case Quote.RawSingle: 155 case Quote.RawSingle:
155 case Quote.RawDouble: 156 case Quote.RawDouble:
156 return string; 157 return string;
157 158
158 case Quote.RawMultiLineSingle: 159 case Quote.RawMultiLineSingle:
159 case Quote.RawMultiLineDouble: 160 case Quote.RawMultiLineDouble:
160 return !string.contains("\r") 161 return !string.contains("\r")
161 ? string 162 ? string
162 : unescapeCodeUnits(string.codeUnits, true); 163 : unescapeCodeUnits(string.codeUnits, true);
163 } 164 }
164 return deprecated_internalProblem( 165 return unhandled("$quote", "unescape", -1, null);
165 "Internal error: Unexpected quote: $quote.");
166 } 166 }
167 167
168 const String incompleteSequence = "Incomplete escape sequence."; 168 const String incompleteSequence = "Incomplete escape sequence.";
169 169
170 const String invalidCharacter = "Invalid character in escape sequence."; 170 const String invalidCharacter = "Invalid character in escape sequence.";
171 171
172 const String invalidCodePoint = "Invalid code point."; 172 const String invalidCodePoint = "Invalid code point.";
173 173
174 // Note: based on 174 // Note: based on
175 // [StringValidator.validateString](pkg/compiler/lib/src/string_validator.dart). 175 // [StringValidator.validateString](pkg/compiler/lib/src/string_validator.dart).
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 } 247 }
248 } else { 248 } else {
249 // Nothing, escaped character is passed through; 249 // Nothing, escaped character is passed through;
250 } 250 }
251 if (code > 0x10FFFF) return error(i, invalidCodePoint); 251 if (code > 0x10FFFF) return error(i, invalidCodePoint);
252 } 252 }
253 result[resultOffset++] = code; 253 result[resultOffset++] = code;
254 } 254 }
255 return new String.fromCharCodes(result, 0, resultOffset); 255 return new String.fromCharCodes(result, 0, resultOffset);
256 } 256 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698