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

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

Issue 1243893002: Separate the API's used by ContextManager. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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 57fd20387892bbcc19981930cef05cdf2a58d7f9..f7f2ede469538fe516e7722300f9e3dffd82ba47 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -117,7 +117,7 @@ class AnalysisServer {
* The [ContextManager] that handles the mapping from analysis roots to
* context directories.
*/
- ServerContextManager contextManager;
+ ContextManager contextManager;
/**
* A flag indicating whether the server is running. When false, contexts
@@ -294,20 +294,19 @@ class AnalysisServer {
_performance = performanceDuringStartup;
operationQueue = new ServerOperationQueue();
if (contextManager == null) {
- contextManager = new ServerContextManager(this, resourceProvider,
+ contextManager = new ContextManagerImpl(resourceProvider,
packageResolverProvider, packageMapProvider, instrumentationService);
- AnalysisOptionsImpl analysisOptions =
- (contextManager as ServerContextManager).defaultOptions;
- analysisOptions.incremental = true;
- analysisOptions.incrementalApi = options.enableIncrementalResolutionApi;
- analysisOptions.incrementalValidation =
- options.enableIncrementalResolutionValidation;
- analysisOptions.generateImplicitErrors = false;
- } else if (contextManager is! ServerContextManager) {
- // TODO(brianwilkerson) Remove this when the interface is complete.
- throw new StateError(
- 'The contextManager must be an instance of ServerContextManager');
}
+ ServerContextManagerCallbacks contextManagerCallbacks =
+ new ServerContextManagerCallbacks(this, resourceProvider);
+ contextManager.callbacks = contextManagerCallbacks;
+ AnalysisOptionsImpl analysisOptions =
+ contextManagerCallbacks.defaultOptions;
+ analysisOptions.incremental = true;
+ analysisOptions.incrementalApi = options.enableIncrementalResolutionApi;
+ analysisOptions.incrementalValidation =
+ options.enableIncrementalResolutionValidation;
+ analysisOptions.generateImplicitErrors = false;
this.contextManager = contextManager;
_noErrorNotification = options.noErrorNotification;
AnalysisEngine.instance.logger = new AnalysisLogger();
@@ -353,7 +352,7 @@ class AnalysisServer {
* The stream that is notified when contexts are added or removed.
*/
Stream<ContextsChangedEvent> get onContextsChanged =>
- contextManager.onContextsChanged;
+ (contextManager.callbacks as ServerContextManagerCallbacks).onContextsChanged;
Brian Wilkerson 2015/07/21 13:56:44 Do we plan on eventually removing the need for thi
Paul Berry 2015/07/21 17:22:21 Yes. My plan (probably in the next CL) is to remo
/**
* The stream that is notified when a single file has been analyzed.
@@ -497,15 +496,14 @@ class AnalysisServer {
{
AnalysisContext containingContext = getContainingContext(path);
if (containingContext != null) {
- Source source = AbstractContextManager.createSourceInContext(
- containingContext, file);
+ Source source =
+ ContextManagerImpl.createSourceInContext(containingContext, file);
return new ContextSourcePair(containingContext, source);
}
}
// try to find a context that analysed the file
for (AnalysisContext context in folderMap.values) {
- Source source =
- AbstractContextManager.createSourceInContext(context, file);
+ Source source = ContextManagerImpl.createSourceInContext(context, file);
SourceKind kind = context.getKindOf(source);
if (kind != SourceKind.UNKNOWN) {
return new ContextSourcePair(context, source);
@@ -1025,8 +1023,8 @@ class AnalysisServer {
Uri uri = context.sourceFactory.restoreUri(source);
if (uri.scheme != 'file') {
preferredContext = context;
- source = AbstractContextManager.createSourceInContext(
- context, resource);
+ source =
+ ContextManagerImpl.createSourceInContext(context, resource);
break;
}
}
@@ -1226,7 +1224,8 @@ class AnalysisServer {
//
// Update the defaults used to create new contexts.
//
- AnalysisOptionsImpl options = contextManager.defaultOptions;
+ AnalysisOptionsImpl options =
+ (contextManager.callbacks as ServerContextManagerCallbacks).defaultOptions;
optionUpdaters.forEach((OptionUpdater optionUpdater) {
optionUpdater(options);
});
@@ -1337,7 +1336,7 @@ class PriorityChangeEvent {
PriorityChangeEvent(this.firstSource);
}
-class ServerContextManager extends AbstractContextManager {
+class ServerContextManagerCallbacks extends ContextManagerCallbacks {
final AnalysisServer analysisServer;
/**
@@ -1350,12 +1349,12 @@ class ServerContextManager extends AbstractContextManager {
*/
StreamController<ContextsChangedEvent> _onContextsChangedController;
- ServerContextManager(this.analysisServer, ResourceProvider resourceProvider,
- ResolverProvider packageResolverProvider,
- OptimizingPubPackageMapProvider packageMapProvider,
- InstrumentationService service)
- : super(resourceProvider, packageResolverProvider, packageMapProvider,
- service) {
+ /**
+ * The [ResourceProvider] by which paths are converted into [Resource]s.
+ */
+ final ResourceProvider resourceProvider;
+
+ ServerContextManagerCallbacks(this.analysisServer, this.resourceProvider) {
_onContextsChangedController =
new StreamController<ContextsChangedEvent>.broadcast();
}
@@ -1406,13 +1405,8 @@ class ServerContextManager extends AbstractContextManager {
}
@override
- void removeContext(Folder folder) {
+ void removeContext(Folder folder, List<String> flushedFiles) {
AnalysisContext context = analysisServer.folderMap.remove(folder);
-
- // See dartbug.com/22689, the AnalysisContext is computed in
- // computeFlushedFiles instead of using the referenced context above, this
- // is an attempt to be careful concerning the referenced issue.
- List<String> flushedFiles = computeFlushedFiles(folder);
sendAnalysisNotificationFlushResults(analysisServer, flushedFiles);
if (analysisServer.index != null) {
« 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