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

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

Issue 2465923002: Integration of the new analysis driver, behind a flag. (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
Index: pkg/analysis_server/lib/src/context_manager.dart
diff --git a/pkg/analysis_server/lib/src/context_manager.dart b/pkg/analysis_server/lib/src/context_manager.dart
index 66977c472fc347921240701911ff6560bff928c5..ab0c499c0bba3fccb42da0e230ead6d7263805c7 100644
--- a/pkg/analysis_server/lib/src/context_manager.dart
+++ b/pkg/analysis_server/lib/src/context_manager.dart
@@ -24,6 +24,7 @@ import 'package:analyzer/source/pub_package_map_provider.dart';
import 'package:analyzer/source/sdk_ext.dart';
import 'package:analyzer/src/context/builder.dart';
import 'package:analyzer/src/context/context.dart' as context;
+import 'package:analyzer/src/dart/analysis/driver.dart';
import 'package:analyzer/src/dart/sdk/sdk.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/java_io.dart';
@@ -90,6 +91,11 @@ class ContextInfo {
Set<String> _dependencies = new Set<String>();
/**
+ * The analysis driver that was created for the [folder].
+ */
+ AnalysisDriver analysisDriver;
+
+ /**
* The analysis context that was created for the [folder].
*/
AnalysisContext context;
@@ -321,6 +327,12 @@ abstract class ContextManager {
*/
abstract class ContextManagerCallbacks {
/**
+ * Create and return a new analysis driver rooted at the given [folder], with
+ * the given analysis [options].
+ */
+ AnalysisDriver addAnalysisDriver(Folder folder, AnalysisOptions options);
Brian Wilkerson 2016/10/31 15:42:58 I really want to get rid of ContextManagerCallback
scheglov 2016/10/31 16:54:20 I'm all for removing extra layers. But in this CL
+
+ /**
* Create and return a new analysis context rooted at the given [folder], with
* the given analysis [options].
*/
@@ -479,6 +491,8 @@ class ContextManagerImpl implements ContextManager {
*/
final InstrumentationService _instrumentationService;
+ final bool enableNewAnalysisDriver;
+
@override
ContextManagerCallbacks callbacks;
@@ -491,8 +505,7 @@ class ContextManagerImpl implements ContextManager {
/**
* A table mapping [Folder]s to the [AnalysisContext]s associated with them.
*/
- @override
- final Map<Folder, AnalysisContext> folderMap =
+ final Map<Folder, AnalysisContext> _folderMap =
new HashMap<Folder, AnalysisContext>();
/**
@@ -509,7 +522,8 @@ class ContextManagerImpl implements ContextManager {
this._packageMapProvider,
this.analyzedFilesGlobs,
this._instrumentationService,
- this.defaultContextOptions) {
+ this.defaultContextOptions,
+ this.enableNewAnalysisDriver) {
absolutePathContext = resourceProvider.absolutePathContext;
pathContext = resourceProvider.pathContext;
}
@@ -517,6 +531,14 @@ class ContextManagerImpl implements ContextManager {
@override
Iterable<AnalysisContext> get analysisContexts => folderMap.values;
+ Map<Folder, AnalysisContext> get folderMap {
+ if (enableNewAnalysisDriver) {
+ throw new StateError('Should not be used with the new analysis driver');
+ } else {
+ return _folderMap;
+ }
+ }
+
@override
List<AnalysisContext> contextsInAnalysisRoot(Folder analysisRoot) {
List<AnalysisContext> contexts = <AnalysisContext>[];
@@ -1033,9 +1055,13 @@ class ContextManagerImpl implements ContextManager {
applyToAnalysisOptions(options, optionMap);
info.setDependencies(dependencies);
- info.context = callbacks.addContext(folder, options);
- folderMap[folder] = info.context;
- info.context.name = folder.path;
+ if (enableNewAnalysisDriver) {
+ info.analysisDriver = callbacks.addAnalysisDriver(folder, options);
+ } else {
+ info.context = callbacks.addContext(folder, options);
+ _folderMap[folder] = info.context;
+ info.context.name = folder.path;
+ }
// Look for pubspec-specified analysis configuration.
File pubspec;
@@ -1052,13 +1078,21 @@ class ContextManagerImpl implements ContextManager {
}
if (pubspec != null) {
File pubSource = resourceProvider.getFile(pubspec.path);
- setConfiguration(
- info.context,
- new AnalysisConfiguration.fromPubspec(
- pubSource, resourceProvider, disposition.packages));
+ if (enableNewAnalysisDriver) {
+ // TODO(scheglov) implement for the new analysis driver
+ } else {
+ setConfiguration(
+ info.context,
+ new AnalysisConfiguration.fromPubspec(
+ pubSource, resourceProvider, disposition.packages));
+ }
}
- processOptionsForContext(info, optionMap);
+ if (enableNewAnalysisDriver) {
+ // TODO(scheglov) implement for the new analysis driver
+ } else {
+ processOptionsForContext(info, optionMap);
+ }
return info;
}

Powered by Google App Engine
This is Rietveld 408576698