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

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

Issue 2296773002: Revert "Move error checking from scope creation to error reporter" (TBD) (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 _definedNames ??= new HashMap<String, Element>(); 1110 if (_definedNames != null && _definedNames.containsKey(name)) {
1111 _definedNames.putIfAbsent(name, () => element); 1111 errorListener
1112 .onError(getErrorForDuplicate(_definedNames[name], element));
1113 } else {
1114 _definedNames ??= new HashMap<String, Element>();
1115 _definedNames[name] = element;
1116 }
1112 } 1117 }
1113 } 1118 }
1114 1119
1115 /** 1120 /**
1116 * Add the given [element] to this scope without checking for duplication or 1121 * Add the given [element] to this scope without checking for duplication or
1117 * hiding. 1122 * hiding.
1118 */ 1123 */
1119 void defineNameWithoutChecking(String name, Element element) { 1124 void defineNameWithoutChecking(String name, Element element) {
1120 _definedNames ??= new HashMap<String, Element>(); 1125 _definedNames ??= new HashMap<String, Element>();
1121 _definedNames[name] = element; 1126 _definedNames[name] = element;
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1265 1270
1266 /** 1271 /**
1267 * Define the type parameters declared by the [classElement]. 1272 * Define the type parameters declared by the [classElement].
1268 */ 1273 */
1269 void _defineTypeParameters(ClassElement classElement) { 1274 void _defineTypeParameters(ClassElement classElement) {
1270 for (TypeParameterElement typeParameter in classElement.typeParameters) { 1275 for (TypeParameterElement typeParameter in classElement.typeParameters) {
1271 define(typeParameter); 1276 define(typeParameter);
1272 } 1277 }
1273 } 1278 }
1274 } 1279 }
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