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

Side by Side Diff: pkg/analyzer/lib/src/dart/analysis/analysis_impl.dart

Issue 2685043002: Compute pending errors for @Required named parameters. (Closed)
Patch Set: Created 3 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 | 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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 'package:analyzer/context/declared_variables.dart'; 5 import 'package:analyzer/context/declared_variables.dart';
6 import 'package:analyzer/dart/ast/ast.dart'; 6 import 'package:analyzer/dart/ast/ast.dart';
7 import 'package:analyzer/dart/element/element.dart'; 7 import 'package:analyzer/dart/element/element.dart';
8 import 'package:analyzer/error/error.dart'; 8 import 'package:analyzer/error/error.dart';
9 import 'package:analyzer/error/listener.dart'; 9 import 'package:analyzer/error/listener.dart';
10 import 'package:analyzer/src/context/context.dart'; 10 import 'package:analyzer/src/context/context.dart';
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 StoreBasedSummaryResynthesizer _resynthesizer; 42 StoreBasedSummaryResynthesizer _resynthesizer;
43 LibraryElement _libraryElement; 43 LibraryElement _libraryElement;
44 44
45 final Map<FileState, LineInfo> _fileToLineInfo = {}; 45 final Map<FileState, LineInfo> _fileToLineInfo = {};
46 final Map<FileState, IgnoreInfo> _fileToIgnoreInfo = {}; 46 final Map<FileState, IgnoreInfo> _fileToIgnoreInfo = {};
47 47
48 final Map<FileState, RecordingErrorListener> _errorListeners = {}; 48 final Map<FileState, RecordingErrorListener> _errorListeners = {};
49 final Map<FileState, ErrorReporter> _errorReporters = {}; 49 final Map<FileState, ErrorReporter> _errorReporters = {};
50 final List<UsedImportedElements> _usedImportedElementsList = []; 50 final List<UsedImportedElements> _usedImportedElementsList = [];
51 final List<UsedLocalElements> _usedLocalElementsList = []; 51 final List<UsedLocalElements> _usedLocalElementsList = [];
52 final Map<FileState, List<PendingError>> _fileToPendingErrors = {};
52 final List<ConstantEvaluationTarget> _constants = []; 53 final List<ConstantEvaluationTarget> _constants = [];
53 54
54 AnalyzerImpl(this._analysisOptions, this._declaredVariables, 55 AnalyzerImpl(this._analysisOptions, this._declaredVariables,
55 this._sourceFactory, this._fsState, this._store, this._library); 56 this._sourceFactory, this._fsState, this._store, this._library);
56 57
57 /** 58 /**
58 * Compute analysis results for all units of the library. 59 * Compute analysis results for all units of the library.
59 */ 60 */
60 Map<FileState, UnitAnalysisResult> analyze() { 61 Map<FileState, UnitAnalysisResult> analyze() {
61 Map<FileState, CompilationUnit> units = {}; 62 Map<FileState, CompilationUnit> units = {};
(...skipping 16 matching lines...) Expand all
78 _context, _sourceFactory, _analysisOptions.strongMode, _store); 79 _context, _sourceFactory, _analysisOptions.strongMode, _store);
79 _typeProvider = _resynthesizer.typeProvider; 80 _typeProvider = _resynthesizer.typeProvider;
80 _context.typeProvider = _typeProvider; 81 _context.typeProvider = _typeProvider;
81 82
82 _libraryElement = _resynthesizer.getLibraryElement(_library.uriStr); 83 _libraryElement = _resynthesizer.getLibraryElement(_library.uriStr);
83 84
84 _resolveDirectives(units); 85 _resolveDirectives(units);
85 86
86 units.forEach((file, unit) { 87 units.forEach((file, unit) {
87 _resolveFile(file, unit); 88 _resolveFile(file, unit);
89 _computePendingMissingRequiredParameters(file, unit);
88 }); 90 });
89 91
90 _computeConstants(); 92 _computeConstants();
91 93
92 units.forEach((file, unit) { 94 units.forEach((file, unit) {
93 { 95 {
94 var visitor = new GatherUsedLocalElementsVisitor(_libraryElement); 96 var visitor = new GatherUsedLocalElementsVisitor(_libraryElement);
95 unit.accept(visitor); 97 unit.accept(visitor);
96 _usedLocalElementsList.add(visitor.usedElements); 98 _usedLocalElementsList.add(visitor.usedElements);
97 } 99 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 nodeMap[constant] = node; 137 nodeMap[constant] = node;
136 } 138 }
137 139
138 for (_ConstantNode node in nodes) { 140 for (_ConstantNode node in nodes) {
139 if (!node.isEvaluated) { 141 if (!node.isEvaluated) {
140 new _ConstantWalker(evaluationEngine).walk(node); 142 new _ConstantWalker(evaluationEngine).walk(node);
141 } 143 }
142 } 144 }
143 } 145 }
144 146
147 void _computePendingMissingRequiredParameters(
148 FileState file, CompilationUnit unit) {
149 // TODO(scheglov) This can be done without "pending" if we resynthesize.
150 var computer = new RequiredConstantsComputer(file.source);
151 unit.accept(computer);
152 _constants.addAll(computer.requiredConstants);
153 _fileToPendingErrors[file] = computer.pendingErrors;
154 }
155
145 void _computeVerifyErrorsAndHints(FileState file, CompilationUnit unit) { 156 void _computeVerifyErrorsAndHints(FileState file, CompilationUnit unit) {
146 RecordingErrorListener errorListener = _getErrorListener(file); 157 RecordingErrorListener errorListener = _getErrorListener(file);
147 CompilationUnitElement unitElement = unit.element; 158 CompilationUnitElement unitElement = unit.element;
148 159
149 // 160 //
150 // Use the ErrorVerifier to compute errors. 161 // Convert the pending errors into actual errors.
151 // 162 //
152 List<PendingError> pendingErrors; 163 for (PendingError pendingError in _fileToPendingErrors[file]) {
153 { 164 errorListener.onError(pendingError.toAnalysisError());
154 RequiredConstantsComputer computer =
155 new RequiredConstantsComputer(file.source);
156 unit.accept(computer);
157 pendingErrors = computer.pendingErrors;
158 List<ConstantEvaluationTarget> requiredConstants =
159 computer.requiredConstants;
160 } 165 }
161 166
162 if (_analysisOptions.strongMode) { 167 if (_analysisOptions.strongMode) {
163 AnalysisOptionsImpl options = _analysisOptions as AnalysisOptionsImpl; 168 AnalysisOptionsImpl options = _analysisOptions as AnalysisOptionsImpl;
164 CodeChecker checker = new CodeChecker( 169 CodeChecker checker = new CodeChecker(
165 _typeProvider, 170 _typeProvider,
166 new StrongTypeSystemImpl(_typeProvider, 171 new StrongTypeSystemImpl(_typeProvider,
167 implicitCasts: options.implicitCasts, 172 implicitCasts: options.implicitCasts,
168 nonnullableTypes: options.nonnullableTypes), 173 nonnullableTypes: options.nonnullableTypes),
169 errorListener, 174 errorListener,
(...skipping 20 matching lines...) Expand all
190 // 195 //
191 ErrorVerifier errorVerifier = new ErrorVerifier( 196 ErrorVerifier errorVerifier = new ErrorVerifier(
192 errorReporter, 197 errorReporter,
193 _libraryElement, 198 _libraryElement,
194 _typeProvider, 199 _typeProvider,
195 new InheritanceManager(_libraryElement), 200 new InheritanceManager(_libraryElement),
196 _analysisOptions.enableSuperMixins); 201 _analysisOptions.enableSuperMixins);
197 unit.accept(errorVerifier); 202 unit.accept(errorVerifier);
198 203
199 // 204 //
200 // Convert the pending errors into actual errors.
201 //
202 for (PendingError pendingError in pendingErrors) {
203 errorListener.onError(pendingError.toAnalysisError());
204 }
205
206 //
207 // Find dead code. 205 // Find dead code.
208 // 206 //
209 unit.accept( 207 unit.accept(
210 new DeadCodeVerifier(errorReporter, typeSystem: _context.typeSystem)); 208 new DeadCodeVerifier(errorReporter, typeSystem: _context.typeSystem));
211 209
212 // Dart2js analysis. 210 // Dart2js analysis.
213 if (_analysisOptions.dart2jsHint) { 211 if (_analysisOptions.dart2jsHint) {
214 unit.accept(new Dart2JSVerifier(errorReporter)); 212 unit.accept(new Dart2JSVerifier(errorReporter));
215 } 213 }
216 214
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 } 736 }
739 737
740 /** 738 /**
741 * Either the name or the source associated with a part-of directive. 739 * Either the name or the source associated with a part-of directive.
742 */ 740 */
743 class _NameOrSource { 741 class _NameOrSource {
744 final String name; 742 final String name;
745 final Source source; 743 final Source source;
746 _NameOrSource(this.name, this.source); 744 _NameOrSource(this.name, this.source);
747 } 745 }
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