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

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

Issue 1918923003: Remove unnecessary casts and general code clean-up (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: clean-up Created 4 years, 8 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.error; 5 library analyzer.src.generated.error;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/ast/ast.dart' show AstNode; 9 import 'package:analyzer/dart/ast/ast.dart' show AstNode;
10 import 'package:analyzer/dart/ast/token.dart'; 10 import 'package:analyzer/dart/ast/token.dart';
(...skipping 3249 matching lines...) Expand 10 before | Expand all | Expand 10 after
3260 return buffer.toString(); 3260 return buffer.toString();
3261 } 3261 }
3262 } 3262 }
3263 return type.displayName; 3263 return type.displayName;
3264 } 3264 }
3265 if (_hasEqualTypeNames(arguments)) { 3265 if (_hasEqualTypeNames(arguments)) {
3266 int count = arguments.length; 3266 int count = arguments.length;
3267 for (int i = 0; i < count; i++) { 3267 for (int i = 0; i < count; i++) {
3268 Object argument = arguments[i]; 3268 Object argument = arguments[i];
3269 if (argument is DartType) { 3269 if (argument is DartType) {
3270 DartType type = argument; 3270 Element element = argument.element;
3271 Element element = type.element;
3272 if (element == null) { 3271 if (element == null) {
3273 arguments[i] = displayName(type); 3272 arguments[i] = displayName(argument);
3274 } else { 3273 } else {
3275 arguments[i] = element.getExtendedDisplayName(displayName(type)); 3274 arguments[i] =
3275 element.getExtendedDisplayName(displayName(argument));
3276 } 3276 }
3277 } 3277 }
3278 } 3278 }
3279 } else { 3279 } else {
3280 int count = arguments.length; 3280 int count = arguments.length;
3281 for (int i = 0; i < count; i++) { 3281 for (int i = 0; i < count; i++) {
3282 Object argument = arguments[i]; 3282 Object argument = arguments[i];
3283 if (argument is DartType) { 3283 if (argument is DartType) {
3284 arguments[i] = displayName(argument); 3284 arguments[i] = displayName(argument);
3285 } 3285 }
3286 } 3286 }
3287 } 3287 }
3288 } 3288 }
3289 3289
3290 /** 3290 /**
3291 * Return `true` if the given array of [arguments] contains two or more types 3291 * Return `true` if the given array of [arguments] contains two or more types
3292 * with the same display name. 3292 * with the same display name.
3293 */ 3293 */
3294 bool _hasEqualTypeNames(List<Object> arguments) { 3294 bool _hasEqualTypeNames(List<Object> arguments) {
3295 int count = arguments.length; 3295 int count = arguments.length;
3296 HashSet<String> typeNames = new HashSet<String>(); 3296 HashSet<String> typeNames = new HashSet<String>();
3297 for (int i = 0; i < count; i++) { 3297 for (int i = 0; i < count; i++) {
3298 if (arguments[i] is DartType && 3298 Object argument = arguments[i];
3299 !typeNames.add((arguments[i] as DartType).displayName)) { 3299 if (argument is DartType && !typeNames.add(argument.displayName)) {
3300 return true; 3300 return true;
3301 } 3301 }
3302 } 3302 }
3303 return false; 3303 return false;
3304 } 3304 }
3305 } 3305 }
3306 3306
3307 /** 3307 /**
3308 * The severity of an [ErrorCode]. 3308 * The severity of an [ErrorCode].
3309 */ 3309 */
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
3580 /** 3580 /**
3581 * Generate a hint for a constructor, function or method invocation where a 3581 * Generate a hint for a constructor, function or method invocation where a
3582 * required parameter is missing. 3582 * required parameter is missing.
3583 * 3583 *
3584 * Parameters: 3584 * Parameters:
3585 * 0: the name of the parameter 3585 * 0: the name of the parameter
3586 */ 3586 */
3587 static const HintCode MISSING_REQUIRED_PARAM = const HintCode( 3587 static const HintCode MISSING_REQUIRED_PARAM = const HintCode(
3588 'MISSING_REQUIRED_PARAM', "The parameter '{0}' is required."); 3588 'MISSING_REQUIRED_PARAM', "The parameter '{0}' is required.");
3589 3589
3590
3591 /** 3590 /**
3592 * Generate a hint for a constructor, function or method invocation where a 3591 * Generate a hint for a constructor, function or method invocation where a
3593 * required parameter is missing. 3592 * required parameter is missing.
3594 * 3593 *
3595 * Parameters: 3594 * Parameters:
3596 * 0: the name of the parameter 3595 * 0: the name of the parameter
3597 * 1: message details 3596 * 1: message details
3598 */ 3597 */
3599 static const HintCode MISSING_REQUIRED_PARAM_WITH_DETAILS = const HintCode( 3598 static const HintCode MISSING_REQUIRED_PARAM_WITH_DETAILS = const HintCode(
3600 'MISSING_REQUIRED_PARAM', "The parameter '{0}' is required. {1}"); 3599 'MISSING_REQUIRED_PARAM', "The parameter '{0}' is required. {1}");
(...skipping 2210 matching lines...) Expand 10 before | Expand all | Expand 10 after
5811 * Initialize a newly created error code to have the given [name]. 5810 * Initialize a newly created error code to have the given [name].
5812 */ 5811 */
5813 const TodoCode(String name) : super(name, "{0}"); 5812 const TodoCode(String name) : super(name, "{0}");
5814 5813
5815 @override 5814 @override
5816 ErrorSeverity get errorSeverity => ErrorSeverity.INFO; 5815 ErrorSeverity get errorSeverity => ErrorSeverity.INFO;
5817 5816
5818 @override 5817 @override
5819 ErrorType get type => ErrorType.TODO; 5818 ErrorType get type => ErrorType.TODO;
5820 } 5819 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/element_resolver.dart ('k') | pkg/analyzer/lib/src/generated/error_verifier.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698