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

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

Issue 2757753002: Migrate DDC to the new analysis driver.
Patch Set: Created 3 years, 9 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
Index: pkg/analyzer/lib/src/dart/analysis/file_state.dart
diff --git a/pkg/analyzer/lib/src/dart/analysis/file_state.dart b/pkg/analyzer/lib/src/dart/analysis/file_state.dart
index 11e3674946d17b84a8a4341eea58c226bfca8492..ae3fad2603a2ea1f410f3624a7c72e7e6b92b337 100644
--- a/pkg/analyzer/lib/src/dart/analysis/file_state.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/file_state.dart
@@ -25,6 +25,7 @@ import 'package:analyzer/src/summary/api_signature.dart';
import 'package:analyzer/src/summary/format.dart';
import 'package:analyzer/src/summary/idl.dart';
import 'package:analyzer/src/summary/name_filter.dart';
+import 'package:analyzer/src/summary/package_bundle_reader.dart';
import 'package:analyzer/src/summary/summarize_ast.dart';
import 'package:convert/convert.dart';
import 'package:crypto/crypto.dart';
@@ -595,6 +596,18 @@ class FileSystemState {
final Uint32List _salt;
/**
+ * The optional store with externally provided unlinked and corresponding
+ * linked summaries. These summaries are always added to the store for any
+ * file analysis.
+ *
+ * While walking the file graph, when we reach a file that exists in the
+ * external store, we don't add it.
+ *
+ * TODO(scheglov) document some more
+ */
+ final SummaryDataStore externalSummaries;
+
+ /**
* Mapping from a URI to the corresponding [FileState].
*/
final Map<Uri, FileState> _uriToFile = {};
@@ -633,7 +646,8 @@ class FileSystemState {
this._resourceProvider,
this._sourceFactory,
this._analysisOptions,
- this._salt) {
+ this._salt,
+ {this.externalSummaries}) {
_testView = new FileSystemStateTestView(this);
}
@@ -685,12 +699,23 @@ class FileSystemState {
FileState getFileForUri(Uri uri) {
FileState file = _uriToFile[uri];
if (file == null) {
- Source uriSource = _sourceFactory.resolveUri(null, uri.toString());
+ String uriStr = uri.toString();
+
+ // If the external store has this URI, don't create the file for it.
+ // We are given all required unlinked and linked summaries for it.
+ if (externalSummaries != null &&
+ externalSummaries.hasUnlinkedUnit(uriStr)) {
+ return null;
+ }
+
+ Source uriSource = _sourceFactory.resolveUri(null, uriStr);
+
// If the URI is invalid, for example package:/test/d.dart (note the
// leading '/'), then `null` is returned. We should ignore this URI.
if (uriSource == null) {
return null;
}
+
String path = uriSource.fullName;
File resource = _resourceProvider.getFile(path);
FileSource source = new FileSource(resource, uri);
@@ -756,6 +781,9 @@ class FileSystemState {
_pathToFiles[path] = files;
}
files.add(file);
+ if (file.uri.scheme != 'package') {
+ _pathToCanonicalFile[path] = file;
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698