Chromium Code Reviews| 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 9381aa264841a98ad2a004f0ba0b366ed7c57946..514828423ce55b7b3a9fe6d53885a5ff6f02c01d 100644 |
| --- a/pkg/analyzer/lib/src/dart/analysis/file_state.dart |
| +++ b/pkg/analyzer/lib/src/dart/analysis/file_state.dart |
| @@ -102,6 +102,7 @@ class FileState { |
| String _transitiveSignature; |
| List<TopLevelDeclaration> _topLevelDeclarations; |
| + List<TopLevelDeclaration> _exportTopLevelDeclarations; |
| FileState._(this._fsState, this.path, this.uri, this.source); |
| @@ -131,6 +132,52 @@ class FileState { |
| */ |
| List<FileState> get exportedFiles => _exportedFiles; |
| + /** |
| + * Return [TopLevelDeclaration]s exported from the this library file. |
| + */ |
| + List<TopLevelDeclaration> get exportTopLevelDeclarations { |
|
Paul Berry
2016/12/01 21:16:10
This sounds like the name of a method with takes s
scheglov
2016/12/01 21:39:56
Done.
|
| + if (_exportTopLevelDeclarations == null) { |
| + _exportTopLevelDeclarations = <TopLevelDeclaration>[]; |
| + |
| + Set<FileState> seenLibraries = new Set<FileState>(); |
| + |
| + /** |
| + * Compute [TopLevelDeclaration]s exported from the [library]. |
| + */ |
| + List<TopLevelDeclaration> computeExported(FileState library) { |
|
Paul Berry
2016/12/01 21:16:10
I think there's a bug. Consider the following:
a
scheglov
2016/12/01 21:39:56
You're right.
Fixed.
|
| + var declarations = <String, TopLevelDeclaration>{}; |
| + if (seenLibraries.add(library)) { |
| + // Append the library declarations. |
| + for (TopLevelDeclaration t in library.topLevelDeclarations) { |
| + declarations[t.name] = t; |
|
Brian Wilkerson
2016/12/01 21:07:47
I think we need to test for private names both her
scheglov
2016/12/01 21:39:56
Done.
|
| + } |
| + for (FileState part in library.partedFiles) { |
| + for (TopLevelDeclaration t in part.topLevelDeclarations) { |
| + declarations[t.name] = t; |
| + } |
| + } |
| + |
| + // Append the exported declarations. |
| + for (int i = 0; i < library._exportedFiles.length; i++) { |
| + List<TopLevelDeclaration> exported = |
| + computeExported(library._exportedFiles[i]); |
| + for (TopLevelDeclaration t in exported) { |
| + if (!declarations.containsKey(t.name) && |
| + library._exportFilters[i].accepts(t.name)) { |
| + declarations[t.name] = t; |
| + } |
| + } |
| + } |
| + } |
| + |
| + return declarations.values.toList(); |
| + } |
| + |
| + _exportTopLevelDeclarations = computeExported(this); |
| + } |
| + return _exportTopLevelDeclarations; |
| + } |
| + |
| @override |
| int get hashCode => uri.hashCode; |
| @@ -352,18 +399,24 @@ class FileState { |
| _referencedNames = new Set<String>.from(driverUnlinkedUnit.referencedNames); |
| _unlinked = driverUnlinkedUnit.unit; |
| _lineInfo = new LineInfo(_unlinked.lineStarts); |
| + _topLevelDeclarations = null; |
| + |
| + // Prepare API signature. |
| List<int> newApiSignature = _unlinked.apiSignature; |
| bool apiSignatureChanged = _apiSignature != null && |
| !_equalByteLists(_apiSignature, newApiSignature); |
| _apiSignature = newApiSignature; |
| - // If the API signature changed, flush transitive signatures. |
| + // The API signature changed. |
| + // Flush transitive signatures of affected files. |
| + // Flush exported top-level declarations of all files. |
| if (apiSignatureChanged) { |
| for (FileState file in _fsState._uriToFile.values) { |
| if (file._transitiveFiles != null && |
| file._transitiveFiles.contains(this)) { |
| file._transitiveSignature = null; |
| } |
| + file._exportTopLevelDeclarations = null; |
| } |
| } |