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

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

Issue 2579223003: Do nothing if the changed file is not known to the driver. (Closed)
Patch Set: Rollback file_state changes. 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 | pkg/analyzer/test/src/dart/analysis/driver_test.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) 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:async'; 5 import 'dart:async';
6 import 'dart:collection'; 6 import 'dart:collection';
7 import 'dart:typed_data'; 7 import 'dart:typed_data';
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' show CompilationUnitElement; 10 import 'package:analyzer/dart/element/element.dart' show CompilationUnitElement;
(...skipping 12 matching lines...) Expand all
23 show AnalysisContext, AnalysisEngine, AnalysisOptions, ChangeSet; 23 show AnalysisContext, AnalysisEngine, AnalysisOptions, ChangeSet;
24 import 'package:analyzer/src/generated/source.dart'; 24 import 'package:analyzer/src/generated/source.dart';
25 import 'package:analyzer/src/services/lint.dart'; 25 import 'package:analyzer/src/services/lint.dart';
26 import 'package:analyzer/src/summary/api_signature.dart'; 26 import 'package:analyzer/src/summary/api_signature.dart';
27 import 'package:analyzer/src/summary/format.dart'; 27 import 'package:analyzer/src/summary/format.dart';
28 import 'package:analyzer/src/summary/idl.dart'; 28 import 'package:analyzer/src/summary/idl.dart';
29 import 'package:analyzer/src/summary/link.dart'; 29 import 'package:analyzer/src/summary/link.dart';
30 import 'package:analyzer/src/summary/package_bundle_reader.dart'; 30 import 'package:analyzer/src/summary/package_bundle_reader.dart';
31 import 'package:analyzer/src/task/dart.dart' show COMPILATION_UNIT_ELEMENT; 31 import 'package:analyzer/src/task/dart.dart' show COMPILATION_UNIT_ELEMENT;
32 import 'package:analyzer/task/dart.dart' show LibrarySpecificUnit; 32 import 'package:analyzer/task/dart.dart' show LibrarySpecificUnit;
33 import 'package:meta/meta.dart';
33 34
34 /** 35 /**
35 * This class computes [AnalysisResult]s for Dart files. 36 * This class computes [AnalysisResult]s for Dart files.
36 * 37 *
37 * Let the set of "explicitly analyzed files" denote the set of paths that have 38 * Let the set of "explicitly analyzed files" denote the set of paths that have
38 * been passed to [addFile] but not subsequently passed to [removeFile]. Let 39 * been passed to [addFile] but not subsequently passed to [removeFile]. Let
39 * the "current analysis results" denote the map from the set of explicitly 40 * the "current analysis results" denote the map from the set of explicitly
40 * analyzed files to the most recent [AnalysisResult] delivered to [results] 41 * analyzed files to the most recent [AnalysisResult] delivered to [results]
41 * for each file. Let the "current file state" represent a map from file path 42 * for each file. Let the "current file state" represent a map from file path
42 * to the file contents most recently read from that file, or fetched from the 43 * to the file contents most recently read from that file, or fetched from the
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 * The controller for the [exceptions] stream. 213 * The controller for the [exceptions] stream.
213 */ 214 */
214 final StreamController<ExceptionResult> _exceptionController = 215 final StreamController<ExceptionResult> _exceptionController =
215 new StreamController<ExceptionResult>(); 216 new StreamController<ExceptionResult>();
216 217
217 /** 218 /**
218 * The instance of the [Search] helper. 219 * The instance of the [Search] helper.
219 */ 220 */
220 Search _search; 221 Search _search;
221 222
223 AnalysisDriverTestView _testView;
224
222 /** 225 /**
223 * Create a new instance of [AnalysisDriver]. 226 * Create a new instance of [AnalysisDriver].
224 * 227 *
225 * The given [SourceFactory] is cloned to ensure that it does not contain a 228 * The given [SourceFactory] is cloned to ensure that it does not contain a
226 * reference to a [AnalysisContext] in which it could have been used. 229 * reference to a [AnalysisContext] in which it could have been used.
227 */ 230 */
228 AnalysisDriver( 231 AnalysisDriver(
229 this._scheduler, 232 this._scheduler,
230 this._logger, 233 this._logger,
231 this._resourceProvider, 234 this._resourceProvider,
232 this._byteStore, 235 this._byteStore,
233 this._contentOverlay, 236 this._contentOverlay,
234 SourceFactory sourceFactory, 237 SourceFactory sourceFactory,
235 this._analysisOptions) 238 this._analysisOptions)
236 : _sourceFactory = sourceFactory.clone() { 239 : _sourceFactory = sourceFactory.clone() {
240 _testView = new AnalysisDriverTestView(this);
237 _fillSalt(); 241 _fillSalt();
238 _sdkBundle = sourceFactory.dartSdk.getLinkedBundle(); 242 _sdkBundle = sourceFactory.dartSdk.getLinkedBundle();
239 _fsState = new FileSystemState( 243 _fsState = new FileSystemState(
240 _logger, 244 _logger,
241 _byteStore, 245 _byteStore,
242 _contentOverlay, 246 _contentOverlay,
243 _resourceProvider, 247 _resourceProvider,
244 sourceFactory, 248 sourceFactory,
245 _analysisOptions, 249 _analysisOptions,
246 _salt, 250 _salt,
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 * Return the source factory used to resolve URIs to paths and restore URIs 345 * Return the source factory used to resolve URIs to paths and restore URIs
342 * from file paths. 346 * from file paths.
343 */ 347 */
344 SourceFactory get sourceFactory => _sourceFactory; 348 SourceFactory get sourceFactory => _sourceFactory;
345 349
346 /** 350 /**
347 * Return the stream that produces [AnalysisStatus] events. 351 * Return the stream that produces [AnalysisStatus] events.
348 */ 352 */
349 Stream<AnalysisStatus> get status => _statusSupport.stream; 353 Stream<AnalysisStatus> get status => _statusSupport.stream;
350 354
355 @visibleForTesting
356 AnalysisDriverTestView get test => _testView;
357
351 /** 358 /**
352 * Return the priority of work that the driver needs to perform. 359 * Return the priority of work that the driver needs to perform.
353 */ 360 */
354 AnalysisDriverPriority get _workPriority { 361 AnalysisDriverPriority get _workPriority {
355 if (_requestedFiles.isNotEmpty) { 362 if (_requestedFiles.isNotEmpty) {
356 return AnalysisDriverPriority.interactive; 363 return AnalysisDriverPriority.interactive;
357 } 364 }
358 if (_referencingNameTasks.isNotEmpty) { 365 if (_referencingNameTasks.isNotEmpty) {
359 return AnalysisDriverPriority.interactive; 366 return AnalysisDriverPriority.interactive;
360 } 367 }
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 return null; 907 return null;
901 } 908 }
902 909
903 /** 910 /**
904 * Perform a single chunk of work and produce [results]. 911 * Perform a single chunk of work and produce [results].
905 */ 912 */
906 Future<Null> _performWork() async { 913 Future<Null> _performWork() async {
907 // Verify all changed files one at a time. 914 // Verify all changed files one at a time.
908 if (_changedFiles.isNotEmpty) { 915 if (_changedFiles.isNotEmpty) {
909 String path = _removeFirst(_changedFiles); 916 String path = _removeFirst(_changedFiles);
910 _verifyApiSignature(path); 917 // If the file has not been accessed yet, we either will eventually read
918 // it later while analyzing one of the added files, or don't need it.
919 if (_fsState.knownFilePaths.contains(path)) {
920 _verifyApiSignature(path);
921 }
911 return; 922 return;
912 } 923 }
913 924
914 // Analyze a requested file. 925 // Analyze a requested file.
915 if (_requestedFiles.isNotEmpty) { 926 if (_requestedFiles.isNotEmpty) {
916 String path = _requestedFiles.keys.first; 927 String path = _requestedFiles.keys.first;
917 try { 928 try {
918 AnalysisResult result = _computeAnalysisResult(path, withUnit: true); 929 AnalysisResult result = _computeAnalysisResult(path, withUnit: true);
919 // If a part without a library, delay its analysis. 930 // If a part without a library, delay its analysis.
920 if (result == null) { 931 if (result == null) {
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
1249 * the event queue. 1260 * the event queue.
1250 */ 1261 */
1251 static Future _pumpEventQueue(int times) { 1262 static Future _pumpEventQueue(int times) {
1252 if (times == 0) { 1263 if (times == 0) {
1253 return new Future.value(); 1264 return new Future.value();
1254 } 1265 }
1255 return new Future.delayed(Duration.ZERO, () => _pumpEventQueue(times - 1)); 1266 return new Future.delayed(Duration.ZERO, () => _pumpEventQueue(times - 1));
1256 } 1267 }
1257 } 1268 }
1258 1269
1270 @visibleForTesting
1271 class AnalysisDriverTestView {
1272 final AnalysisDriver driver;
1273
1274 AnalysisDriverTestView(this.driver);
1275
1276 Set<String> get filesToAnalyze => driver._filesToAnalyze;
1277 }
1278
1259 /** 1279 /**
1260 * The result of analyzing of a single file. 1280 * The result of analyzing of a single file.
1261 * 1281 *
1262 * These results are self-consistent, i.e. [content], [contentHash], the 1282 * These results are self-consistent, i.e. [content], [contentHash], the
1263 * resolved [unit] correspond to each other. All referenced elements, even 1283 * resolved [unit] correspond to each other. All referenced elements, even
1264 * external ones, are also self-consistent. But none of the results is 1284 * external ones, are also self-consistent. But none of the results is
1265 * guaranteed to be consistent with the state of the files. 1285 * guaranteed to be consistent with the state of the files.
1266 * 1286 *
1267 * Every result is independent, and is not guaranteed to be consistent with 1287 * Every result is independent, and is not guaranteed to be consistent with
1268 * any previously returned result, even inside of the same library. 1288 * any previously returned result, even inside of the same library.
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
1592 libraryDeclarations.add(new TopLevelDeclarationInSource( 1612 libraryDeclarations.add(new TopLevelDeclarationInSource(
1593 file.source, declaration, isExported)); 1613 file.source, declaration, isExported));
1594 } 1614 }
1595 } 1615 }
1596 } 1616 }
1597 1617
1598 // We're not done yet. 1618 // We're not done yet.
1599 return false; 1619 return false;
1600 } 1620 }
1601 } 1621 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/src/dart/analysis/driver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698