Index: pkg/front_end/lib/src/incremental/file_state.dart |
diff --git a/pkg/front_end/lib/src/incremental/file_state.dart b/pkg/front_end/lib/src/incremental/file_state.dart |
index 3f353897463840f6dab6be37cef2ee59734140aa..993d84a7f4f29fc159494e5e6af0d24314f68c1e 100644 |
--- a/pkg/front_end/lib/src/incremental/file_state.dart |
+++ b/pkg/front_end/lib/src/incremental/file_state.dart |
@@ -35,6 +35,7 @@ class FileState { |
List<int> _content; |
List<int> _contentHash; |
+ List<NamespaceExport> _exports; |
List<FileState> _importedLibraries; |
List<FileState> _exportedLibraries; |
List<FileState> _partFiles; |
@@ -61,6 +62,9 @@ class FileState { |
/// The list of the libraries exported by this library. |
List<FileState> get exportedLibraries => _exportedLibraries; |
+ /// The list of the exported files with combinators. |
+ List<NamespaceExport> get exports => _exports; |
+ |
@override |
int get hashCode => uri.hashCode; |
@@ -123,16 +127,32 @@ class FileState { |
_importedLibraries = <FileState>[]; |
_exportedLibraries = <FileState>[]; |
_partFiles = <FileState>[]; |
- await _addFileForRelativeUri(_importedLibraries, 'dart:core'); |
- for (String uri in listener.imports) { |
- await _addFileForRelativeUri(_importedLibraries, uri); |
+ _exports = <NamespaceExport>[]; |
+ { |
+ FileState coreFile = await _getFileForRelativeUri('dart:core'); |
+ if (coreFile != null) { |
+ _importedLibraries.add(coreFile); |
+ } |
+ } |
+ for (ImportDirective import_ in listener.imports) { |
+ FileState file = await _getFileForRelativeUri(import_.uri); |
+ if (file != null) { |
+ _importedLibraries.add(file); |
+ } |
} |
await _addVmTargetImportsForCore(); |
- for (String uri in listener.exports) { |
- await _addFileForRelativeUri(_exportedLibraries, uri); |
+ for (ExportDirective export_ in listener.exports) { |
+ FileState file = await _getFileForRelativeUri(export_.uri); |
+ if (file != null) { |
+ _exportedLibraries.add(file); |
+ _exports.add(new NamespaceExport(file, export_.combinators)); |
+ } |
} |
for (String uri in listener.parts) { |
- await _addFileForRelativeUri(_partFiles, uri); |
+ FileState file = await _getFileForRelativeUri(uri); |
+ if (file != null) { |
+ _partFiles.add(file); |
+ } |
} |
// Compute referenced files. |
@@ -152,11 +172,24 @@ class FileState { |
return fileUri.toString(); |
} |
- /// Add the [FileState] for the given [relativeUri] to the [files]. |
- /// Do nothing if the URI cannot be parsed, cannot correspond any file, etc. |
- Future<Null> _addFileForRelativeUri( |
- List<FileState> files, String relativeUri) async { |
- if (relativeUri.isEmpty) return; |
+ /// Fasta unconditionally loads all VM libraries. In order to be able to |
+ /// serve them using the file system view, pretend that all of them were |
+ /// imported into `dart:core`. |
+ /// TODO(scheglov) Ask VM people whether all these libraries are required. |
Siggi Cherem (dart-lang)
2017/05/15 22:18:53
I think it's safe to remove this.
The VM needs th
scheglov
2017/05/16 00:14:24
It's not safe to remove here.
TargetImplemenation.
Siggi Cherem (dart-lang)
2017/05/16 21:43:47
I see, then yes :) we need to update fasta to stop
|
+ Future<Null> _addVmTargetImportsForCore() async { |
+ if (uri.toString() != 'dart:core') return; |
+ for (String uri in new VmTarget(null).extraRequiredLibraries) { |
+ FileState file = await _getFileForRelativeUri(uri); |
+ if (file != null) { |
+ _importedLibraries.add(file); |
+ } |
+ } |
+ } |
+ |
+ /// Return the [FileState] for the given [relativeUri] or `null` if the URI |
+ /// cannot be parsed, cannot correspond any file, etc. |
+ Future<FileState> _getFileForRelativeUri(String relativeUri) async { |
+ if (relativeUri.isEmpty) return null; |
// Resolve the relative URI into absolute. |
// The result is either: |
@@ -166,23 +199,10 @@ class FileState { |
try { |
absoluteUri = fileUri.resolve(relativeUri); |
} on FormatException { |
- return; |
+ return null; |
} |
- FileState file = await _fsState.getFile(absoluteUri); |
- if (file == null) return; |
- files.add(file); |
- } |
- |
- /// Fasta unconditionally loads all VM libraries. In order to be able to |
- /// serve them using the file system view, pretend that all of them were |
- /// imported into `dart:core`. |
- /// TODO(scheglov) Ask VM people whether all these libraries are required. |
- Future<Null> _addVmTargetImportsForCore() async { |
- if (uri.toString() != 'dart:core') return; |
- for (String uri in new VmTarget(null).extraRequiredLibraries) { |
- await _addFileForRelativeUri(_importedLibraries, uri); |
- } |
+ return await _fsState.getFile(absoluteUri); |
} |
/// Scan the content of the file. |
@@ -257,6 +277,30 @@ class LibraryCycle { |
} |
} |
+/// Information about a single `export` directive. |
+class NamespaceExport { |
+ final FileState library; |
+ final List<NamespaceCombinator> combinators; |
+ |
+ NamespaceExport(this.library, this.combinators); |
+ |
+ /// Return `true` if the [name] satisfies the sequence of the [combinators]. |
+ bool filter(String name) { |
Siggi Cherem (dart-lang)
2017/05/15 22:18:53
nit: consider renaming this method. It might be ju
scheglov
2017/05/16 00:14:24
Done.
|
+ for (NamespaceCombinator combinator in combinators) { |
Siggi Cherem (dart-lang)
2017/05/15 22:18:53
how much do we expect to use these functions? In p
scheglov
2017/05/16 00:14:24
I think usually there are zero combinators.
Someti
|
+ if (combinator.isShow) { |
+ if (!combinator.names.contains(name)) { |
+ return false; |
+ } |
+ } else { |
+ if (combinator.names.contains(name)) { |
+ return false; |
+ } |
+ } |
+ } |
+ return true; |
+ } |
+} |
+ |
/// [DirectiveListener] that skips native clauses. |
class _DirectiveListenerWithNative extends DirectiveListener { |
@override |