| 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 11 matching lines...) Expand all Loading... |
| 22 import 'package:analyzer/task/dart.dart' show LibrarySpecificUnit; | 22 import 'package:analyzer/task/dart.dart' show LibrarySpecificUnit; |
| 23 | 23 |
| 24 /** | 24 /** |
| 25 * Context information necessary to analyze one or more libraries within an | 25 * Context information necessary to analyze one or more libraries within an |
| 26 * [AnalysisDriver]. | 26 * [AnalysisDriver]. |
| 27 * | 27 * |
| 28 * Currently this is implemented as a wrapper around [AnalysisContext]. | 28 * Currently this is implemented as a wrapper around [AnalysisContext]. |
| 29 * TODO(paulberry): make a front end API that this can make use of instead. | 29 * TODO(paulberry): make a front end API that this can make use of instead. |
| 30 */ | 30 */ |
| 31 class LibraryContext { | 31 class LibraryContext { |
| 32 final SummaryDataStore store; |
| 33 |
| 32 /** | 34 /** |
| 33 * The [AnalysisContext] which is used to do the analysis. | 35 * The [AnalysisContext] which is used to do the analysis. |
| 34 */ | 36 */ |
| 35 final AnalysisContext _analysisContext; | 37 final AnalysisContext _analysisContext; |
| 36 | 38 |
| 37 /** | 39 /** |
| 38 * Create a [LibraryContext] which is prepared to analyze [library]. | 40 * Create a [LibraryContext] which is prepared to analyze [library]. |
| 39 */ | 41 */ |
| 40 factory LibraryContext.forSingleLibrary( | 42 factory LibraryContext.forSingleLibrary( |
| 41 FileState library, | 43 FileState library, |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 String key = '${library.transitiveSignature}.linked'; | 118 String key = '${library.transitiveSignature}.linked'; |
| 117 List<int> bytes = linkedBuilder.toBuffer(); | 119 List<int> bytes = linkedBuilder.toBuffer(); |
| 118 LinkedLibrary linked = new LinkedLibrary.fromBuffer(bytes); | 120 LinkedLibrary linked = new LinkedLibrary.fromBuffer(bytes); |
| 119 store.addLinkedLibrary(uri, linked); | 121 store.addLinkedLibrary(uri, linked); |
| 120 byteStore.put(key, bytes); | 122 byteStore.put(key, bytes); |
| 121 }); | 123 }); |
| 122 | 124 |
| 123 var analysisContext = _createAnalysisContext( | 125 var analysisContext = _createAnalysisContext( |
| 124 options, declaredVariables, sourceFactory, fileTracker, store); | 126 options, declaredVariables, sourceFactory, fileTracker, store); |
| 125 | 127 |
| 126 return new LibraryContext._(analysisContext); | 128 return new LibraryContext._(store, analysisContext); |
| 127 }); | 129 }); |
| 128 } | 130 } |
| 129 | 131 |
| 130 LibraryContext._(this._analysisContext); | 132 LibraryContext._(this.store, this._analysisContext); |
| 131 | 133 |
| 132 /** | 134 /** |
| 133 * Computes a [CompilationUnitElement] for the given library/unit pair. | 135 * Computes a [CompilationUnitElement] for the given library/unit pair. |
| 134 */ | 136 */ |
| 135 CompilationUnitElement computeUnitElement( | 137 CompilationUnitElement computeUnitElement( |
| 136 Source librarySource, Source unitSource) { | 138 Source librarySource, Source unitSource) { |
| 137 return _analysisContext.computeResult( | 139 return _analysisContext.computeResult( |
| 138 new LibrarySpecificUnit(librarySource, unitSource), | 140 new LibrarySpecificUnit(librarySource, unitSource), |
| 139 COMPILATION_UNIT_ELEMENT); | 141 COMPILATION_UNIT_ELEMENT); |
| 140 } | 142 } |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 @override | 228 @override |
| 227 String setContents(Source source, String contents) { | 229 String setContents(Source source, String contents) { |
| 228 throw new UnimplementedError(); | 230 throw new UnimplementedError(); |
| 229 } | 231 } |
| 230 | 232 |
| 231 FileState _getFileForSource(Source source) { | 233 FileState _getFileForSource(Source source) { |
| 232 String path = source.fullName; | 234 String path = source.fullName; |
| 233 return fileTracker.fsState.getFileForPath(path); | 235 return fileTracker.fsState.getFileForPath(path); |
| 234 } | 236 } |
| 235 } | 237 } |
| OLD | NEW |