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

Unified Diff: pkg/analysis_server/lib/src/analysis_server.dart

Issue 2107793002: Generalize DartSdkManager to support embedder SDKs (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 months 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 | pkg/analysis_server/lib/src/context_manager.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/analysis_server.dart
diff --git a/pkg/analysis_server/lib/src/analysis_server.dart b/pkg/analysis_server/lib/src/analysis_server.dart
index 25d639f3aaa008825821ca2c229bd634c969bdad..7e695a2762d8b459f62846e0663eaa077de8b1a1 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -43,6 +43,7 @@ import 'package:analyzer/src/task/dart.dart';
import 'package:analyzer/src/util/glob.dart';
import 'package:analyzer/task/dart.dart';
import 'package:plugin/plugin.dart';
+import 'package:yaml/yaml.dart';
typedef void OptionUpdater(AnalysisOptionsImpl options);
@@ -151,11 +152,6 @@ class AnalysisServer {
List<RequestHandler> handlers;
/**
- * The function used to create a new SDK using the default SDK.
- */
- final SdkCreator defaultSdkCreator;
-
- /**
* The object used to manage the SDK's known to this server.
*/
DartSdkManager sdkManager;
@@ -317,7 +313,7 @@ class AnalysisServer {
Index _index,
this.serverPlugin,
this.options,
- this.defaultSdkCreator,
+ this.sdkManager,
this.instrumentationService,
{ResolverProvider fileResolverProvider: null,
ResolverProvider packageResolverProvider: null,
@@ -335,7 +331,6 @@ class AnalysisServer {
options.finerGrainedInvalidation;
defaultContextOptions.generateImplicitErrors = false;
operationQueue = new ServerOperationQueue();
- sdkManager = new DartSdkManager(defaultSdkCreator);
if (useSingleContextManager) {
contextManager = new SingleContextManager(resourceProvider, sdkManager,
packageResolverProvider, analyzedFilesGlobs, defaultContextOptions);
@@ -1639,15 +1634,30 @@ class ServerContextManagerCallbacks extends ContextManagerCallbacks {
// If no embedded URI resolver was provided, defer to a locator-backed one.
EmbedderYamlLocator locator =
disposition.getEmbedderLocator(resourceProvider);
- EmbedderSdk sdk = new EmbedderSdk(locator.embedderYamls);
- if (sdk.libraryMap.size() == 0) {
- // The embedder file has no mappings, so use the default Dart SDK.
+ Map<Folder, YamlMap> embedderYamls = locator.embedderYamls;
+ EmbedderSdk embedderSdk = new EmbedderSdk(embedderYamls);
+ if (embedderSdk.libraryMap.size() == 0) {
+ // There was no embedder file, or the file was empty, so used the default
+ // SDK.
resolvers.add(new DartUriResolver(
analysisServer.sdkManager.getSdkForOptions(options)));
} else {
- // The embedder uri resolver has mappings, use it instead of the default
- // Dart SDK uri resolver.
- resolvers.add(new DartUriResolver(sdk));
+ // The embedder file defines an alternate SDK, so use it.
+ List<String> paths = <String>[];
+ for (Folder folder in embedderYamls.keys) {
+ paths.add(folder
+ .getChildAssumingFile(EmbedderYamlLocator.EMBEDDER_FILE_NAME)
+ .path);
+ }
+ DartSdk dartSdk = analysisServer.sdkManager
+ .getSdk(new SdkDescription(paths, options), () {
+ embedderSdk.analysisOptions = options;
+ // TODO(brianwilkerson) Enable summary use after we have decided where
+ // summary files for embedder files will live.
+ embedderSdk.useSummary = false;
+ return embedderSdk;
+ });
+ resolvers.add(new DartUriResolver(dartSdk));
}
resolvers.addAll(packageUriResolvers);
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/context_manager.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698