| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 'package:analyzer/context/declared_variables.dart'; | 5 import 'package:analyzer/context/declared_variables.dart'; |
| 6 import 'package:analyzer/dart/ast/ast.dart'; | 6 import 'package:analyzer/dart/ast/ast.dart'; |
| 7 import 'package:analyzer/dart/element/element.dart' show CompilationUnitElement; | 7 import 'package:analyzer/dart/element/element.dart' show CompilationUnitElement; |
| 8 import 'package:analyzer/error/error.dart'; | 8 import 'package:analyzer/error/error.dart'; |
| 9 import 'package:analyzer/src/context/context.dart'; | 9 import 'package:analyzer/src/context/context.dart'; |
| 10 import 'package:analyzer/src/dart/analysis/byte_store.dart'; | 10 import 'package:analyzer/src/dart/analysis/byte_store.dart'; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 */ | 30 */ |
| 31 class LibraryContext { | 31 class LibraryContext { |
| 32 final SummaryDataStore store; | 32 final SummaryDataStore store; |
| 33 | 33 |
| 34 /** | 34 /** |
| 35 * The [AnalysisContext] which is used to do the analysis. | 35 * The [AnalysisContext] which is used to do the analysis. |
| 36 */ | 36 */ |
| 37 final AnalysisContext _analysisContext; | 37 final AnalysisContext _analysisContext; |
| 38 | 38 |
| 39 /** | 39 /** |
| 40 * Create a [LibraryContext] which is prepared to analyze [library]. | 40 * Create a [LibraryContext] which is prepared to analyze [targetLibrary]. |
| 41 */ | 41 */ |
| 42 factory LibraryContext.forSingleLibrary( | 42 factory LibraryContext.forSingleLibrary( |
| 43 FileState library, | 43 FileState targetLibrary, |
| 44 PerformanceLog logger, | 44 PerformanceLog logger, |
| 45 PackageBundle sdkBundle, | 45 PackageBundle sdkBundle, |
| 46 ByteStore byteStore, | 46 ByteStore byteStore, |
| 47 AnalysisOptions options, | 47 AnalysisOptions options, |
| 48 DeclaredVariables declaredVariables, | 48 DeclaredVariables declaredVariables, |
| 49 SourceFactory sourceFactory, | 49 SourceFactory sourceFactory, |
| 50 FileTracker fileTracker) { | 50 FileTracker fileTracker) { |
| 51 return logger.run('Create library context', () { | 51 return logger.run('Create library context', () { |
| 52 Map<String, FileState> libraries = <String, FileState>{}; | 52 Map<String, FileState> libraries = <String, FileState>{}; |
| 53 SummaryDataStore store = new SummaryDataStore(const <String>[]); | 53 SummaryDataStore store = new SummaryDataStore(const <String>[]); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 73 store.addUnlinkedUnit(part.uriStr, part.unlinked); | 73 store.addUnlinkedUnit(part.uriStr, part.unlinked); |
| 74 } | 74 } |
| 75 | 75 |
| 76 // Append referenced libraries. | 76 // Append referenced libraries. |
| 77 library.importedFiles.forEach(appendLibraryFiles); | 77 library.importedFiles.forEach(appendLibraryFiles); |
| 78 library.exportedFiles.forEach(appendLibraryFiles); | 78 library.exportedFiles.forEach(appendLibraryFiles); |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 | 81 |
| 82 logger.run('Append library files', () { | 82 logger.run('Append library files', () { |
| 83 return appendLibraryFiles(library); | 83 return appendLibraryFiles(targetLibrary); |
| 84 }); | 84 }); |
| 85 | 85 |
| 86 Set<String> libraryUrisToLink = new Set<String>(); | 86 Set<String> libraryUrisToLink = new Set<String>(); |
| 87 logger.run('Load linked bundles', () { | 87 logger.run('Load linked bundles', () { |
| 88 for (FileState library in libraries.values) { | 88 for (FileState library in libraries.values) { |
| 89 if (library.exists) { | 89 if (library.exists || library == targetLibrary) { |
| 90 String key = '${library.transitiveSignature}.linked'; | 90 String key = '${library.transitiveSignature}.linked'; |
| 91 List<int> bytes = byteStore.get(key); | 91 List<int> bytes = byteStore.get(key); |
| 92 if (bytes != null) { | 92 if (bytes != null) { |
| 93 LinkedLibrary linked = new LinkedLibrary.fromBuffer(bytes); | 93 LinkedLibrary linked = new LinkedLibrary.fromBuffer(bytes); |
| 94 store.addLinkedLibrary(library.uriStr, linked); | 94 store.addLinkedLibrary(library.uriStr, linked); |
| 95 } else { | 95 } else { |
| 96 libraryUrisToLink.add(library.uriStr); | 96 libraryUrisToLink.add(library.uriStr); |
| 97 } | 97 } |
| 98 } | 98 } |
| 99 } | 99 } |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 @override | 228 @override |
| 229 String setContents(Source source, String contents) { | 229 String setContents(Source source, String contents) { |
| 230 throw new UnimplementedError(); | 230 throw new UnimplementedError(); |
| 231 } | 231 } |
| 232 | 232 |
| 233 FileState _getFileForSource(Source source) { | 233 FileState _getFileForSource(Source source) { |
| 234 String path = source.fullName; | 234 String path = source.fullName; |
| 235 return fileTracker.fsState.getFileForPath(path); | 235 return fileTracker.fsState.getFileForPath(path); |
| 236 } | 236 } |
| 237 } | 237 } |
| OLD | NEW |