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

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

Issue 2290373003: Move error checking from scope creation to error reporter (take 2) (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
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/error_verifier.dart » ('j') | 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) 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.dart.resolver.scope; 5 library analyzer.src.dart.resolver.scope;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/element/element.dart'; 10 import 'package:analyzer/dart/element/element.dart';
(...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 /** 1100 /**
1101 * Add the given [element] to this scope. If there is already an element with 1101 * Add the given [element] to this scope. If there is already an element with
1102 * the given name defined in this scope, then an error will be generated and 1102 * the given name defined in this scope, then an error will be generated and
1103 * the original element will continue to be mapped to the name. If there is an 1103 * the original element will continue to be mapped to the name. If there is an
1104 * element with the given name in an enclosing scope, then a warning will be 1104 * element with the given name in an enclosing scope, then a warning will be
1105 * generated but the given element will hide the inherited element. 1105 * generated but the given element will hide the inherited element.
1106 */ 1106 */
1107 void define(Element element) { 1107 void define(Element element) {
1108 String name = _getName(element); 1108 String name = _getName(element);
1109 if (name != null && !name.isEmpty) { 1109 if (name != null && !name.isEmpty) {
1110 if (_definedNames != null && _definedNames.containsKey(name)) { 1110 _definedNames ??= new HashMap<String, Element>();
1111 errorListener 1111 _definedNames.putIfAbsent(name, () => element);
1112 .onError(getErrorForDuplicate(_definedNames[name], element));
1113 } else {
1114 _definedNames ??= new HashMap<String, Element>();
1115 _definedNames[name] = element;
1116 }
1117 } 1112 }
1118 } 1113 }
1119 1114
1120 /** 1115 /**
1121 * Add the given [element] to this scope without checking for duplication or 1116 * Add the given [element] to this scope without checking for duplication or
1122 * hiding. 1117 * hiding.
1123 */ 1118 */
1124 void defineNameWithoutChecking(String name, Element element) { 1119 void defineNameWithoutChecking(String name, Element element) {
1125 _definedNames ??= new HashMap<String, Element>(); 1120 _definedNames ??= new HashMap<String, Element>();
1126 _definedNames[name] = element; 1121 _definedNames[name] = element;
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 1265
1271 /** 1266 /**
1272 * Define the type parameters declared by the [classElement]. 1267 * Define the type parameters declared by the [classElement].
1273 */ 1268 */
1274 void _defineTypeParameters(ClassElement classElement) { 1269 void _defineTypeParameters(ClassElement classElement) {
1275 for (TypeParameterElement typeParameter in classElement.typeParameters) { 1270 for (TypeParameterElement typeParameter in classElement.typeParameters) {
1276 define(typeParameter); 1271 define(typeParameter);
1277 } 1272 }
1278 } 1273 }
1279 } 1274 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/error_verifier.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698