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

Unified Diff: pkg/analyzer/lib/src/dart/analysis/driver.dart

Issue 2447603002: Include linked hashes into the current file state. (Closed)
Patch Set: Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/analysis/driver.dart
diff --git a/pkg/analyzer/lib/src/dart/analysis/driver.dart b/pkg/analyzer/lib/src/dart/analysis/driver.dart
index 0b2bbf18912ec8ac14a1f565e04103e92ef3b57f..045d9c60f578ad4ba21cf7d3669696a66016a7db 100644
--- a/pkg/analyzer/lib/src/dart/analysis/driver.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/driver.dart
@@ -128,11 +128,16 @@ class AnalysisDriver {
/**
* The current file state.
*
- * It maps file paths to MD5 hash of the file content.
+ * It maps file paths to the MD5 hash of the file content.
*/
final _fileContentHashMap = <String, String>{};
/**
+ * Mapping from library URIs to the linked hash of the library.
+ */
+ final _linkedHashMap = <Uri, String>{};
Paul Berry 2016/10/24 11:51:47 My comments about nomenclature from the last patch
scheglov 2016/10/24 17:44:37 Acknowledged. I renamed them together.
+
+ /**
* TODO(scheglov) document and improve
*/
final _hasWorkStreamController = new StreamController<String>();
@@ -233,6 +238,7 @@ class AnalysisDriver {
void changeFile(String path) {
// TODO(scheglov) Don't clear, schedule API signature validation.
_fileContentHashMap.clear();
+ _linkedHashMap.clear();
_filesToAnalyze.add(path);
_filesToAnalyze.addAll(_explicitFiles);
// TODO(scheglov) name?!
@@ -277,6 +283,25 @@ class AnalysisDriver {
* TODO(scheglov) replace with actual [AnalysisResult] computing.
*/
List<String> _computeAndPrintErrors(_File file) {
+ // TODO(scheglov) Computing resolved unit fails for these units.
+ // pkg/analyzer/lib/plugin/embedded_resolver_provider.dart
+ // pkg/analyzer/lib/plugin/embedded_resolver_provider.dart
+ if (file.path.endsWith(
+ 'pkg/analyzer/lib/plugin/embedded_resolver_provider.dart') ||
+ file.path.endsWith('pkg/analyzer/lib/source/embedder.dart') ||
+ file.path.endsWith('pkg/analyzer/lib/src/generated/ast.dart') ||
+ file.path.endsWith('pkg/analyzer/lib/src/generated/element.dart') ||
+ file.path
+ .endsWith('pkg/analyzer/lib/src/generated/element_handle.dart') ||
+ file.path.endsWith('pkg/analyzer/lib/src/generated/error.dart') ||
+ file.path.endsWith('pkg/analyzer/lib/src/generated/scanner.dart') ||
+ file.path.endsWith('pkg/analyzer/lib/src/generated/sdk_io.dart') ||
+ file.path.endsWith('pkg/analyzer/lib/src/generated/visitors.dart') ||
+ file.path.endsWith('pkg/analyzer/test/generated/constant_test.dart') ||
+ file.path.endsWith('pkg/analyzer/test/source/embedder_test.dart')) {
+ return [];
+ }
+
List<String> errorStrings = _logger.run('Compute errors $file', () {
LibraryContext libraryContext = _createLibraryContext(file);
@@ -299,9 +324,14 @@ class AnalysisDriver {
}
AnalysisContext analysisContext = _createAnalysisContext(libraryContext);
- analysisContext.resolveCompilationUnit2(
- libraryContext.file.source, libraryContext.file.source);
+ analysisContext.setContents(file.source, file.content);
try {
+ // Compute resolved unit.
+// _logger.runTimed('Computed resolved unit', () {
Paul Berry 2016/10/24 11:51:47 Why is this code commented out? Either remove or
scheglov 2016/10/24 17:44:37 We don't actually compute full analysis results ye
+// analysisContext.resolveCompilationUnit2(
+// libraryContext.file.source, libraryContext.file.source);
+// });
+ // Compute errors.
List<AnalysisError> errors;
try {
errors = _logger.runTimed('Computed errors', () {
@@ -874,10 +904,8 @@ class _LibraryNode {
bool get isReady => linked != null;
String get linkedHash {
- if (_linkedHash == null) {
- if (transitiveDependencies == null) {
- computeTransitiveDependencies();
- }
+ _linkedHash ??= driver._linkedHashMap.putIfAbsent(uri, () {
+ computeTransitiveDependencies();
// Add all unlinked API signatures.
List<String> signatures = <String>[];
@@ -893,8 +921,8 @@ class _LibraryNode {
ApiSignature signature = new ApiSignature();
signature.addString(uri.toString());
signatures.forEach(signature.addString);
- _linkedHash = signature.toHex();
- }
+ return signature.toHex();
+ });
return _linkedHash;
}
« 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