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

Side by Side Diff: pkg/analyzer/lib/src/generated/java_core.dart

Issue 2321263003: Remove parseUriWithException() and URISyntaxException. (Closed)
Patch Set: Created 4 years, 3 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 analyzer.src.generated.java_core; 5 library analyzer.src.generated.java_core;
6 6
7 /** 7 /**
8 * Inserts the given arguments into [pattern]. 8 * Inserts the given arguments into [pattern].
9 * 9 *
10 * format('Hello, {0}!', 'John') = 'Hello, John!' 10 * format('Hello, {0}!', 'John') = 'Hello, John!'
(...skipping 21 matching lines...) Expand all
32 } 32 }
33 return pattern.replaceAllMapped(new RegExp(r'\{(\d+)\}'), (match) { 33 return pattern.replaceAllMapped(new RegExp(r'\{(\d+)\}'), (match) {
34 String indexStr = match.group(1); 34 String indexStr = match.group(1);
35 int index = int.parse(indexStr); 35 int index = int.parse(indexStr);
36 Object arg = arguments[index]; 36 Object arg = arguments[index];
37 assert(arg != null); 37 assert(arg != null);
38 return arg?.toString(); 38 return arg?.toString();
39 }); 39 });
40 } 40 }
41 41
42 /// Parses given string to [Uri], throws [URISyntaxException] if invalid.
43 Uri parseUriWithException(String str) {
44 Uri uri;
45 try {
46 uri = Uri.parse(str);
47 } on FormatException catch (e) {
48 throw new URISyntaxException(e.toString());
49 }
50 if (uri.path.isEmpty) {
51 throw new URISyntaxException('empty path');
52 }
53 return uri;
54 }
55
56 /** 42 /**
57 * Very limited printf implementation, supports only %s and %d. 43 * Very limited printf implementation, supports only %s and %d.
58 */ 44 */
59 String _printf(String fmt, List args) { 45 String _printf(String fmt, List args) {
60 StringBuffer sb = new StringBuffer(); 46 StringBuffer sb = new StringBuffer();
61 bool markFound = false; 47 bool markFound = false;
62 int argIndex = 0; 48 int argIndex = 0;
63 for (int i = 0; i < fmt.length; i++) { 49 for (int i = 0; i < fmt.length; i++) {
64 int c = fmt.codeUnitAt(i); 50 int c = fmt.codeUnitAt(i);
65 if (c == 0x25) { 51 if (c == 0x25) {
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 205
220 void printf(String fmt, List args) { 206 void printf(String fmt, List args) {
221 this.print(_printf(fmt, args)); 207 this.print(_printf(fmt, args));
222 } 208 }
223 209
224 void println(String s) { 210 void println(String s) {
225 this.print(s); 211 this.print(s);
226 this.newLine(); 212 this.newLine();
227 } 213 }
228 } 214 }
229
230 class URISyntaxException implements Exception {
231 final String message;
232 URISyntaxException(this.message);
233 String toString() => "URISyntaxException: $message";
234 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698