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

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

Issue 2829253002: Add support for external summaries bundle in AnalysisDriver. (Closed)
Patch Set: Fixes for review comments. Created 3 years, 8 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/dart/analysis/file_state.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/context/context_root.dart'; 9 import 'package:analyzer/context/context_root.dart';
10 import 'package:analyzer/context/declared_variables.dart'; 10 import 'package:analyzer/context/declared_variables.dart';
(...skipping 12 matching lines...) Expand all
23 import 'package:analyzer/src/dart/analysis/search.dart'; 23 import 'package:analyzer/src/dart/analysis/search.dart';
24 import 'package:analyzer/src/dart/analysis/status.dart'; 24 import 'package:analyzer/src/dart/analysis/status.dart';
25 import 'package:analyzer/src/dart/analysis/top_level_declaration.dart'; 25 import 'package:analyzer/src/dart/analysis/top_level_declaration.dart';
26 import 'package:analyzer/src/generated/engine.dart' 26 import 'package:analyzer/src/generated/engine.dart'
27 show AnalysisContext, AnalysisEngine, AnalysisOptions; 27 show AnalysisContext, AnalysisEngine, AnalysisOptions;
28 import 'package:analyzer/src/generated/source.dart'; 28 import 'package:analyzer/src/generated/source.dart';
29 import 'package:analyzer/src/lint/registry.dart' as linter; 29 import 'package:analyzer/src/lint/registry.dart' as linter;
30 import 'package:analyzer/src/summary/api_signature.dart'; 30 import 'package:analyzer/src/summary/api_signature.dart';
31 import 'package:analyzer/src/summary/format.dart'; 31 import 'package:analyzer/src/summary/format.dart';
32 import 'package:analyzer/src/summary/idl.dart'; 32 import 'package:analyzer/src/summary/idl.dart';
33 import 'package:analyzer/src/summary/package_bundle_reader.dart';
33 import 'package:meta/meta.dart'; 34 import 'package:meta/meta.dart';
34 35
35 /** 36 /**
36 * This class computes [AnalysisResult]s for Dart files. 37 * This class computes [AnalysisResult]s for Dart files.
37 * 38 *
38 * Let the set of "explicitly analyzed files" denote the set of paths that have 39 * Let the set of "explicitly analyzed files" denote the set of paths that have
39 * been passed to [addFile] but not subsequently passed to [removeFile]. Let 40 * been passed to [addFile] but not subsequently passed to [removeFile]. Let
40 * the "current analysis results" denote the map from the set of explicitly 41 * the "current analysis results" denote the map from the set of explicitly
41 * analyzed files to the most recent [AnalysisResult] delivered to [results] 42 * analyzed files to the most recent [AnalysisResult] delivered to [results]
42 * for each file. Let the "current file state" represent a map from file path 43 * for each file. Let the "current file state" represent a map from file path
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 final ResourceProvider _resourceProvider; 99 final ResourceProvider _resourceProvider;
99 100
100 /** 101 /**
101 * The byte storage to get and put serialized data. 102 * The byte storage to get and put serialized data.
102 * 103 *
103 * It can be shared with other [AnalysisDriver]s. 104 * It can be shared with other [AnalysisDriver]s.
104 */ 105 */
105 final ByteStore _byteStore; 106 final ByteStore _byteStore;
106 107
107 /** 108 /**
109 * The optional store with externally provided unlinked and corresponding
110 * linked summaries. These summaries are always added to the store for any
111 * file analysis.
112 */
113 final SummaryDataStore _externalSummaries;
114
115 /**
108 * This [ContentCache] is consulted for a file content before reading 116 * This [ContentCache] is consulted for a file content before reading
109 * the content from the file. 117 * the content from the file.
110 */ 118 */
111 final FileContentOverlay _contentOverlay; 119 final FileContentOverlay _contentOverlay;
112 120
113 /** 121 /**
114 * The analysis options to analyze with. 122 * The analysis options to analyze with.
115 */ 123 */
116 AnalysisOptions _analysisOptions; 124 AnalysisOptions _analysisOptions;
117 125
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 AnalysisDriver( 277 AnalysisDriver(
270 this._scheduler, 278 this._scheduler,
271 PerformanceLog logger, 279 PerformanceLog logger,
272 this._resourceProvider, 280 this._resourceProvider,
273 this._byteStore, 281 this._byteStore,
274 this._contentOverlay, 282 this._contentOverlay,
275 this.contextRoot, 283 this.contextRoot,
276 SourceFactory sourceFactory, 284 SourceFactory sourceFactory,
277 this._analysisOptions, 285 this._analysisOptions,
278 {PackageBundle sdkBundle, 286 {PackageBundle sdkBundle,
279 this.disableChangesAndCacheAllResults: false}) 287 this.disableChangesAndCacheAllResults: false,
288 SummaryDataStore externalSummaries})
280 : _logger = logger, 289 : _logger = logger,
281 _sourceFactory = sourceFactory.clone(), 290 _sourceFactory = sourceFactory.clone(),
282 _sdkBundle = sdkBundle { 291 _sdkBundle = sdkBundle,
292 _externalSummaries = externalSummaries {
283 _onResults = _resultController.stream.asBroadcastStream(); 293 _onResults = _resultController.stream.asBroadcastStream();
284 _testView = new AnalysisDriverTestView(this); 294 _testView = new AnalysisDriverTestView(this);
285 _createFileTracker(logger); 295 _createFileTracker(logger);
286 _scheduler.add(this); 296 _scheduler.add(this);
287 _search = new Search(this); 297 _search = new Search(this);
288 } 298 }
289 299
290 /** 300 /**
291 * Return the set of files explicitly added to analysis using [addFile]. 301 * Return the set of files explicitly added to analysis using [addFile].
292 */ 302 */
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 } 1078 }
1069 1079
1070 /** 1080 /**
1071 * Creates a new [FileTracker] object and stores it in [_fileTracker]. 1081 * Creates a new [FileTracker] object and stores it in [_fileTracker].
1072 * 1082 *
1073 * This is used both on initial construction and whenever the configuration 1083 * This is used both on initial construction and whenever the configuration
1074 * changes. 1084 * changes.
1075 */ 1085 */
1076 void _createFileTracker(PerformanceLog logger) { 1086 void _createFileTracker(PerformanceLog logger) {
1077 _fillSalt(); 1087 _fillSalt();
1078 _fileTracker = new FileTracker(logger, _byteStore, _contentOverlay, 1088 _fileTracker = new FileTracker(
1079 _resourceProvider, sourceFactory, _analysisOptions, _salt, _changeHook); 1089 logger,
1090 _byteStore,
1091 _contentOverlay,
1092 _resourceProvider,
1093 sourceFactory,
1094 _analysisOptions,
1095 _salt,
1096 _externalSummaries,
1097 _changeHook);
1080 } 1098 }
1081 1099
1082 /** 1100 /**
1083 * Return the context in which the [library] should be analyzed. 1101 * Return the context in which the [library] should be analyzed.
1084 */ 1102 */
1085 LibraryContext _createLibraryContext(FileState library) => 1103 LibraryContext _createLibraryContext(FileState library) =>
1086 new LibraryContext.forSingleLibrary( 1104 new LibraryContext.forSingleLibrary(
1087 library, 1105 library,
1088 _logger, 1106 _logger,
1089 _sdkBundle, 1107 _sdkBundle,
1090 _byteStore, 1108 _byteStore,
1091 _analysisOptions, 1109 _analysisOptions,
1092 declaredVariables, 1110 declaredVariables,
1093 _sourceFactory, 1111 _sourceFactory,
1094 _fileTracker); 1112 _externalSummaries,
1113 fsState);
1095 1114
1096 /** 1115 /**
1097 * Fill [_salt] with data. 1116 * Fill [_salt] with data.
1098 */ 1117 */
1099 void _fillSalt() { 1118 void _fillSalt() {
1100 _salt[0] = DATA_VERSION; 1119 _salt[0] = DATA_VERSION;
1101 List<int> crossContextOptions = _analysisOptions.signature; 1120 List<int> crossContextOptions = _analysisOptions.signature;
1102 assert(crossContextOptions.length == AnalysisOptions.signatureLength); 1121 assert(crossContextOptions.length == AnalysisOptions.signatureLength);
1103 for (int i = 0; i < crossContextOptions.length; i++) { 1122 for (int i = 0; i < crossContextOptions.length; i++) {
1104 _salt[i + 1] = crossContextOptions[i]; 1123 _salt[i + 1] = crossContextOptions[i];
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
1523 class AnalysisDriverTestView { 1542 class AnalysisDriverTestView {
1524 final AnalysisDriver driver; 1543 final AnalysisDriver driver;
1525 1544
1526 int numOfAnalyzedLibraries = 0; 1545 int numOfAnalyzedLibraries = 0;
1527 1546
1528 AnalysisDriverTestView(this.driver); 1547 AnalysisDriverTestView(this.driver);
1529 1548
1530 FileTracker get fileTracker => driver._fileTracker; 1549 FileTracker get fileTracker => driver._fileTracker;
1531 1550
1532 Map<String, AnalysisResult> get priorityResults => driver._priorityResults; 1551 Map<String, AnalysisResult> get priorityResults => driver._priorityResults;
1552
1553 SummaryDataStore getSummaryStore(String libraryPath) {
1554 FileState library = driver.fsState.getFileForPath(libraryPath);
1555 LibraryContext libraryContext = driver._createLibraryContext(library);
1556 try {
1557 return libraryContext.store;
1558 } finally {
1559 libraryContext.dispose();
1560 }
1561 }
1533 } 1562 }
1534 1563
1535 /** 1564 /**
1536 * The result of analyzing of a single file. 1565 * The result of analyzing of a single file.
1537 * 1566 *
1538 * These results are self-consistent, i.e. [content], [contentHash], the 1567 * These results are self-consistent, i.e. [content], [contentHash], the
1539 * resolved [unit] correspond to each other. All referenced elements, even 1568 * resolved [unit] correspond to each other. All referenced elements, even
1540 * external ones, are also self-consistent. But none of the results is 1569 * external ones, are also self-consistent. But none of the results is
1541 * guaranteed to be consistent with the state of the files. 1570 * guaranteed to be consistent with the state of the files.
1542 * 1571 *
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
2053 libraryDeclarations.add(new TopLevelDeclarationInSource( 2082 libraryDeclarations.add(new TopLevelDeclarationInSource(
2054 file.source, declaration, isExported)); 2083 file.source, declaration, isExported));
2055 } 2084 }
2056 } 2085 }
2057 } 2086 }
2058 2087
2059 // We're not done yet. 2088 // We're not done yet.
2060 return false; 2089 return false;
2061 } 2090 }
2062 } 2091 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/dart/analysis/file_state.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698