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

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

Issue 2754473004: Replace making getInnermostContext public with making a getFolder method (Closed)
Patch Set: Created 3 years, 9 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/single_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/context_manager.dart
diff --git a/pkg/analysis_server/lib/src/context_manager.dart b/pkg/analysis_server/lib/src/context_manager.dart
index 99ee3179bddf3ffbe0f994f264f6e91b875d2378..e85b94a5d5345981655989eae3d7bbb0ca4aaf4c 100644
--- a/pkg/analysis_server/lib/src/context_manager.dart
+++ b/pkg/analysis_server/lib/src/context_manager.dart
@@ -301,18 +301,17 @@ abstract class ContextManager {
AnalysisDriver getDriverFor(String path);
/**
- * Return the [ContextInfo] for the "innermost" context whose associated
- * folder is or contains the given path. ("innermost" refers to the nesting
- * of contexts, so if there is a context for path /foo and a context for
- * path /foo/bar, then the innermost context containing /foo/bar/baz.dart is
- * the context for /foo/bar.)
+ * Like [getDriverFor] and [getContextFor], but returns the [Folder] which
+ * allows plugins to create & manage their own tree of drivers just like using
+ * [getDriverFor].
*
- * If no context contains the given path, `null` is returned.
+ * This folder should be the root of analysis context, not just the containing
+ * folder of the path (like basename), as this is NOT just a file API.
*
- * This is public at least temporarily, for plugin support until the new API
- * is ready.
+ * This exists at least temporarily, for plugin support until the new API is
+ * ready.
*/
- ContextInfo getInnermostContextInfoFor(String path);
+ Folder getContextFolderFor(String path);
/**
* Return a list of all of the analysis drivers reachable from the given
@@ -582,7 +581,7 @@ class ContextManagerImpl implements ContextManager {
List<AnalysisContext> contextsInAnalysisRoot(Folder analysisRoot) {
List<AnalysisContext> contexts = <AnalysisContext>[];
ContextInfo innermostContainingInfo =
- getInnermostContextInfoFor(analysisRoot.path);
+ _getInnermostContextInfoFor(analysisRoot.path);
void addContextAndDescendants(ContextInfo info) {
contexts.add(info.context);
info.children.forEach(addContextAndDescendants);
@@ -609,14 +608,14 @@ class ContextManagerImpl implements ContextManager {
@override
AnalysisContext getContextFor(String path) {
- return getInnermostContextInfoFor(path)?.context;
+ return _getInnermostContextInfoFor(path)?.context;
}
/**
* For testing: get the [ContextInfo] object for the given [folder], if any.
*/
ContextInfo getContextInfoFor(Folder folder) {
- ContextInfo info = getInnermostContextInfoFor(folder.path);
+ ContextInfo info = _getInnermostContextInfoFor(folder.path);
if (info != null && folder == info.folder) {
return info;
}
@@ -625,7 +624,11 @@ class ContextManagerImpl implements ContextManager {
@override
AnalysisDriver getDriverFor(String path) {
- return getInnermostContextInfoFor(path)?.analysisDriver;
+ return _getInnermostContextInfoFor(path)?.analysisDriver;
+ }
+
+ Folder getContextFolderFor(String path) {
+ return _getInnermostContextInfoFor(path)?.folder;
}
@override
@@ -637,7 +640,7 @@ class ContextManagerImpl implements ContextManager {
}
ContextInfo innermostContainingInfo =
- getInnermostContextInfoFor(analysisRoot.path);
+ _getInnermostContextInfoFor(analysisRoot.path);
if (innermostContainingInfo != null) {
if (analysisRoot == innermostContainingInfo.folder) {
addContextAndDescendants(innermostContainingInfo);
@@ -1352,7 +1355,7 @@ class ContextManagerImpl implements ContextManager {
*
* If no context contains the given path, `null` is returned.
*/
- ContextInfo getInnermostContextInfoFor(String path) {
+ ContextInfo _getInnermostContextInfoFor(String path) {
ContextInfo info = rootInfo.findChildInfoFor(path);
if (info == null) {
return null;
@@ -1370,7 +1373,7 @@ class ContextManagerImpl implements ContextManager {
* Return the parent for a new [ContextInfo] with the given [path] folder.
*/
ContextInfo _getParentForNewContext(String path) {
- ContextInfo parent = getInnermostContextInfoFor(path);
+ ContextInfo parent = _getInnermostContextInfoFor(path);
if (parent != null) {
return parent;
}
@@ -1383,7 +1386,7 @@ class ContextManagerImpl implements ContextManager {
// but implicitly referenced in another context, we will only send a
// changeSet to the context that explicitly includes the file (because
// that's the only context that's watching the file).
- ContextInfo info = getInnermostContextInfoFor(event.path);
+ ContextInfo info = _getInnermostContextInfoFor(event.path);
if (info == null) {
// This event doesn't apply to any context. This could happen due to a
// race condition (e.g. a context was removed while one of its events was
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/single_context_manager.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698