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

Unified Diff: pkg/analysis_server/test/mock_sdk.dart

Issue 2525203002: Implement getLinkedBundle() for MockSdk in analysis_server. (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/test/mock_sdk.dart
diff --git a/pkg/analysis_server/test/mock_sdk.dart b/pkg/analysis_server/test/mock_sdk.dart
index d3f44e0e3b338b4b6b947b8938fd3f9f369a368f..acb2095fc0c39442962eed293fd83d9699eaa983 100644
--- a/pkg/analysis_server/test/mock_sdk.dart
+++ b/pkg/analysis_server/test/mock_sdk.dart
@@ -11,6 +11,7 @@ import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/sdk.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/summary/idl.dart' show PackageBundle;
+import 'package:analyzer/src/summary/summary_file_builder.dart';
class MockSdk implements DartSdk {
static const MockSdkLibrary LIB_CORE = const MockSdkLibrary(
@@ -263,6 +264,11 @@ const Map<String, LibraryInfo> libraries = const {
*/
InternalAnalysisContext _analysisContext;
+ /**
+ * The cached linked bundle of the SDK.
+ */
+ PackageBundle _bundle;
+
MockSdk({resource.ResourceProvider resourceProvider})
: provider = resourceProvider ?? new resource.MemoryResourceProvider() {
LIBRARIES.forEach((SdkLibrary library) {
@@ -333,7 +339,18 @@ const Map<String, LibraryInfo> libraries = const {
}
@override
- PackageBundle getLinkedBundle() => null;
+ PackageBundle getLinkedBundle() {
+ if (_bundle == null) {
+ List<Source> librarySources = sdkLibraries
+ .map((SdkLibrary library) => mapDartUri(library.shortName))
+ .toList();
+ List<int> bytes = new SummaryBuilder(
+ librarySources, context, context.analysisOptions.strongMode)
+ .build();
+ _bundle = new PackageBundle.fromBuffer(bytes);
+ }
+ return _bundle;
+ }
@override
SdkLibrary getSdkLibrary(String dartUri) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698