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

Side by Side Diff: pkg/analyzer/lib/src/dart/resolver/inheritance_manager.dart

Issue 2537643004: Use putIfAbsent in InheritanceManager._reportError. (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 import 'dart:collection'; 5 import 'dart:collection';
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/ast/token.dart'; 8 import 'package:analyzer/dart/ast/token.dart';
9 import 'package:analyzer/dart/element/element.dart'; 9 import 'package:analyzer/dart/element/element.dart';
10 import 'package:analyzer/dart/element/type.dart'; 10 import 'package:analyzer/dart/element/type.dart';
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 * @param offset the offset of the location of the error 662 * @param offset the offset of the location of the error
663 * @param length the length of the location of the error 663 * @param length the length of the location of the error
664 * @param errorCode the error code to be associated with this error 664 * @param errorCode the error code to be associated with this error
665 * @param arguments the arguments used to build the error message 665 * @param arguments the arguments used to build the error message
666 */ 666 */
667 void _reportError( 667 void _reportError(
668 ClassElement classElt, ErrorCode errorCode, List<Object> arguments) { 668 ClassElement classElt, ErrorCode errorCode, List<Object> arguments) {
669 if (ignoreErrors) { 669 if (ignoreErrors) {
670 return; 670 return;
671 } 671 }
672 HashSet<AnalysisError> errorSet = _errorsInClassElement[classElt]; 672 HashSet<AnalysisError> errorSet = _errorsInClassElement.putIfAbsent(
673 if (errorSet == null) { 673 classElt, () => new HashSet<AnalysisError>());
674 errorSet = new HashSet<AnalysisError>();
675 _errorsInClassElement[classElt] = errorSet;
676 }
677 errorSet.add(new AnalysisError(classElt.source, classElt.nameOffset, 674 errorSet.add(new AnalysisError(classElt.source, classElt.nameOffset,
678 classElt.nameLength, errorCode, arguments)); 675 classElt.nameLength, errorCode, arguments));
679 } 676 }
680 677
681 /** 678 /**
682 * Given the set of methods defined by classes above [classElt] in the class h ierarchy, 679 * Given the set of methods defined by classes above [classElt] in the class h ierarchy,
683 * apply the appropriate inheritance rules to determine those methods inherite d by or overridden 680 * apply the appropriate inheritance rules to determine those methods inherite d by or overridden
684 * by [classElt]. Also report static warnings 681 * by [classElt]. Also report static warnings
685 * [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE] and 682 * [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE] and
686 * [StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETTER_AND_METHOD] if ap propriate. 683 * [StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETTER_AND_METHOD] if ap propriate.
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 } 1247 }
1251 1248
1252 /** 1249 /**
1253 * Initializes [keys] and [values]. 1250 * Initializes [keys] and [values].
1254 */ 1251 */
1255 void _initArrays(int initialCapacity) { 1252 void _initArrays(int initialCapacity) {
1256 _keys = new List<String>(initialCapacity); 1253 _keys = new List<String>(initialCapacity);
1257 _values = new List<ExecutableElement>(initialCapacity); 1254 _values = new List<ExecutableElement>(initialCapacity);
1258 } 1255 }
1259 } 1256 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698