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

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

Issue 2562083002: Get some tests running using the analysis driver (Closed)
Patch Set: Created 4 years 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 7b1f87e8421fd6e898351c017a0621553a7d93b1..0224c7b92195c37e1430d36b5f85d798b4a69f91 100644
--- a/pkg/analysis_server/lib/src/context_manager.dart
+++ b/pkg/analysis_server/lib/src/context_manager.dart
@@ -290,6 +290,13 @@ abstract class ContextManager {
AnalysisContext getContextFor(String path);
/**
+ * Return a list of all of the analysis drivers reachable from the given
+ * [analysisRoot] (the driver associated with [analysisRoot] and all of its
+ * descendants).
+ */
+ List<AnalysisDriver> getDriversInAnalysisRoot(Folder analysisRoot);
+
+ /**
* Return `true` if the given [path] is ignored by a [ContextInfo] whose
* folder contains it.
*/
@@ -592,6 +599,30 @@ class ContextManagerImpl implements ContextManager {
}
@override
+ List<AnalysisDriver> getDriversInAnalysisRoot(Folder analysisRoot) {
+ List<AnalysisDriver> drivers = <AnalysisDriver>[];
+ void addContextAndDescendants(ContextInfo info) {
+ drivers.add(info.analysisDriver);
+ info.children.forEach(addContextAndDescendants);
+ }
+
+ ContextInfo innermostContainingInfo =
+ _getInnermostContextInfoFor(analysisRoot.path);
+ if (innermostContainingInfo != null) {
+ if (analysisRoot == innermostContainingInfo.folder) {
+ addContextAndDescendants(innermostContainingInfo);
+ } else {
+ for (ContextInfo info in innermostContainingInfo.children) {
+ if (analysisRoot.isOrContains(info.folder.path)) {
+ addContextAndDescendants(info);
+ }
+ }
+ }
+ }
+ return drivers;
+ }
+
+ @override
bool isIgnored(String path) {
ContextInfo info = rootInfo;
do {
@@ -956,15 +987,27 @@ class ContextManagerImpl implements ContextManager {
void _checkForAnalysisOptionsUpdate(
String path, ContextInfo info, ChangeType changeType) {
if (AnalysisEngine.isAnalysisOptionsFileName(path, pathContext)) {
- var analysisContext = info.context;
- if (analysisContext is context.AnalysisContextImpl) {
- Map<String, Object> options =
- readOptions(info.folder, info.disposition.packages);
- processOptionsForContext(info, options,
- optionsRemoved: changeType == ChangeType.REMOVE);
- analysisContext.sourceFactory = _createSourceFactory(
- analysisContext, analysisContext.analysisOptions, info.folder);
- callbacks.applyChangesToContext(info.folder, new ChangeSet());
+ if (enableNewAnalysisDriver) {
+ // TODO(brianwilkerson) Implement this.
+// AnalysisDriver driver = info.analysisDriver;
+// String contextRoot = info.folder.path;
+// ContextBuilder builder =
+// callbacks.createContextBuilder(info.folder, defaultContextOptions);
+// AnalysisOptions options = builder.getAnalysisOptions(contextRoot);
+// driver.analysisOptions = options;
+// driver.sourceFactory = builder.createSourceFactory(contextRoot, options);
+ // TODO(brianwilkerson) Set exclusion patterns.
+ } else {
+ var analysisContext = info.context;
+ if (analysisContext is context.AnalysisContextImpl) {
+ Map<String, Object> options =
+ readOptions(info.folder, info.disposition.packages);
+ processOptionsForContext(info, options,
+ optionsRemoved: changeType == ChangeType.REMOVE);
+ analysisContext.sourceFactory = _createSourceFactory(
+ analysisContext, analysisContext.analysisOptions, info.folder);
+ callbacks.applyChangesToContext(info.folder, new ChangeSet());
+ }
}
}
}

Powered by Google App Engine
This is Rietveld 408576698