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

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

Issue 1933763002: Use null-aware operators to clean up the code (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Additional clean-up Created 4 years, 7 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 final Stopwatch nanoTimeStopwatch = new Stopwatch(); 7 final Stopwatch nanoTimeStopwatch = new Stopwatch();
8 8
9 /** 9 /**
10 * Inserts the given arguments into [pattern]. 10 * Inserts the given arguments into [pattern].
(...skipping 19 matching lines...) Expand all
30 String formatList(String pattern, List<Object> arguments) { 30 String formatList(String pattern, List<Object> arguments) {
31 if (arguments == null || arguments.isEmpty) { 31 if (arguments == null || arguments.isEmpty) {
32 assert(!pattern.contains(new RegExp(r'\{(\d+)\}'))); 32 assert(!pattern.contains(new RegExp(r'\{(\d+)\}')));
33 return pattern; 33 return pattern;
34 } 34 }
35 return pattern.replaceAllMapped(new RegExp(r'\{(\d+)\}'), (match) { 35 return pattern.replaceAllMapped(new RegExp(r'\{(\d+)\}'), (match) {
36 String indexStr = match.group(1); 36 String indexStr = match.group(1);
37 int index = int.parse(indexStr); 37 int index = int.parse(indexStr);
38 Object arg = arguments[index]; 38 Object arg = arguments[index];
39 assert(arg != null); 39 assert(arg != null);
40 return arg != null ? arg.toString() : null; 40 return arg?.toString();
41 }); 41 });
42 } 42 }
43 43
44 /// Parses given string to [Uri], throws [URISyntaxException] if invalid. 44 /// Parses given string to [Uri], throws [URISyntaxException] if invalid.
45 Uri parseUriWithException(String str) { 45 Uri parseUriWithException(String str) {
46 Uri uri; 46 Uri uri;
47 try { 47 try {
48 uri = Uri.parse(str); 48 uri = Uri.parse(str);
49 } on FormatException catch (e) { 49 } on FormatException catch (e) {
50 throw new URISyntaxException(e.toString()); 50 throw new URISyntaxException(e.toString());
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 367
368 class UnsupportedOperationException extends JavaException { 368 class UnsupportedOperationException extends JavaException {
369 UnsupportedOperationException([message = ""]) : super(message); 369 UnsupportedOperationException([message = ""]) : super(message);
370 } 370 }
371 371
372 class URISyntaxException implements Exception { 372 class URISyntaxException implements Exception {
373 final String message; 373 final String message;
374 URISyntaxException(this.message); 374 URISyntaxException(this.message);
375 String toString() => "URISyntaxException: $message"; 375 String toString() => "URISyntaxException: $message";
376 } 376 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/incremental_resolver.dart ('k') | pkg/analyzer/lib/src/generated/parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698