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

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

Issue 1729523002: Revert collecting defined elements. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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/task/dart.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.generated.resolver; 5 library analyzer.src.generated.resolver;
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/ast/token.dart'; 10 import 'package:analyzer/dart/ast/token.dart';
(...skipping 3997 matching lines...) Expand 10 before | Expand all | Expand 10 after
4008 for (int i = 0; i < count; i++) { 4008 for (int i = 0; i < count; i++) {
4009 annotations[i].accept(this); 4009 annotations[i].accept(this);
4010 } 4010 }
4011 } 4011 }
4012 } 4012 }
4013 4013
4014 /** 4014 /**
4015 * An [AstVisitor] that fills [UsedLocalElements]. 4015 * An [AstVisitor] that fills [UsedLocalElements].
4016 */ 4016 */
4017 class GatherUsedLocalElementsVisitor extends RecursiveAstVisitor { 4017 class GatherUsedLocalElementsVisitor extends RecursiveAstVisitor {
4018 final List<Element> definedElements = <Element>[];
4019 final UsedLocalElements usedElements = new UsedLocalElements(); 4018 final UsedLocalElements usedElements = new UsedLocalElements();
4020 4019
4021 final LibraryElement _enclosingLibrary; 4020 final LibraryElement _enclosingLibrary;
4022 ClassElement _enclosingClass; 4021 ClassElement _enclosingClass;
4023 ExecutableElement _enclosingExec; 4022 ExecutableElement _enclosingExec;
4024 4023
4025 GatherUsedLocalElementsVisitor(this._enclosingLibrary); 4024 GatherUsedLocalElementsVisitor(this._enclosingLibrary);
4026 4025
4027 @override 4026 @override
4028 visitCatchClause(CatchClause node) { 4027 visitCatchClause(CatchClause node) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
4078 try { 4077 try {
4079 _enclosingExec = node.element; 4078 _enclosingExec = node.element;
4080 super.visitMethodDeclaration(node); 4079 super.visitMethodDeclaration(node);
4081 } finally { 4080 } finally {
4082 _enclosingExec = enclosingExecOld; 4081 _enclosingExec = enclosingExecOld;
4083 } 4082 }
4084 } 4083 }
4085 4084
4086 @override 4085 @override
4087 visitSimpleIdentifier(SimpleIdentifier node) { 4086 visitSimpleIdentifier(SimpleIdentifier node) {
4088 Element element = node.staticElement;
4089 if (node.inDeclarationContext()) { 4087 if (node.inDeclarationContext()) {
4090 if (element != null) {
4091 definedElements.add(element);
4092 }
4093 return; 4088 return;
4094 } 4089 }
4090 Element element = node.staticElement;
4095 bool isIdentifierRead = _isReadIdentifier(node); 4091 bool isIdentifierRead = _isReadIdentifier(node);
4096 if (element is LocalVariableElement) { 4092 if (element is LocalVariableElement) {
4097 if (isIdentifierRead) { 4093 if (isIdentifierRead) {
4098 usedElements.addElement(element); 4094 usedElements.addElement(element);
4099 } 4095 }
4100 } else { 4096 } else {
4101 _useIdentifierElement(node); 4097 _useIdentifierElement(node);
4102 if (element == null || 4098 if (element == null ||
4103 element.enclosingElement is ClassElement && 4099 element.enclosingElement is ClassElement &&
4104 !identical(element, _enclosingExec)) { 4100 !identical(element, _enclosingExec)) {
(...skipping 8125 matching lines...) Expand 10 before | Expand all | Expand 10 after
12230 } 12226 }
12231 return false; 12227 return false;
12232 } 12228 }
12233 } 12229 }
12234 12230
12235 /** 12231 /**
12236 * Instances of the class [UnusedLocalElementsVerifier] traverse an element 12232 * Instances of the class [UnusedLocalElementsVerifier] traverse an element
12237 * structure looking for cases of [HintCode.UNUSED_ELEMENT], 12233 * structure looking for cases of [HintCode.UNUSED_ELEMENT],
12238 * [HintCode.UNUSED_FIELD], [HintCode.UNUSED_LOCAL_VARIABLE], etc. 12234 * [HintCode.UNUSED_FIELD], [HintCode.UNUSED_LOCAL_VARIABLE], etc.
12239 */ 12235 */
12240 class UnusedLocalElementsVerifier extends SimpleElementVisitor { 12236 class UnusedLocalElementsVerifier extends RecursiveElementVisitor {
12241 /** 12237 /**
12242 * The error listener to which errors will be reported. 12238 * The error listener to which errors will be reported.
12243 */ 12239 */
12244 final AnalysisErrorListener _errorListener; 12240 final AnalysisErrorListener _errorListener;
12245 12241
12246 /** 12242 /**
12247 * The elements know to be used. 12243 * The elements know to be used.
12248 */ 12244 */
12249 final UsedLocalElements _usedElements; 12245 final UsedLocalElements _usedElements;
12250 12246
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
12800 nonFields.add(node); 12796 nonFields.add(node);
12801 return null; 12797 return null;
12802 } 12798 }
12803 12799
12804 @override 12800 @override
12805 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this); 12801 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this);
12806 12802
12807 @override 12803 @override
12808 Object visitWithClause(WithClause node) => null; 12804 Object visitWithClause(WithClause node) => null;
12809 } 12805 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/task/dart.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698