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

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

Issue 1000203003: If the file belongs to any analysis root, check whether we're in it now. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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/operation/operation_analysis.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 3b5f5658909b739029f147481a6f5934640bc94e..6c790aa9936c79900140916de54320f02976e384 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -393,6 +393,25 @@ class AnalysisServer {
}
/**
+ * Return the [AnalysisContext] that contains the given [path].
+ * Return `null` if no context contains the [path].
+ */
+ AnalysisContext getContainingContext(String path) {
+ Folder containingFolder = null;
+ AnalysisContext containingContext = null;
+ folderMap.forEach((Folder folder, AnalysisContext context) {
+ if (folder.isOrContains(path)) {
+ if (containingFolder == null ||
+ containingFolder.path.length < folder.path.length) {
+ containingFolder = folder;
+ containingContext = context;
+ }
+ }
+ });
+ return containingContext;
+ }
+
+ /**
* Return the primary [ContextSourcePair] representing the given [path].
*
* The [AnalysisContext] of this pair will be the context that explicitly
@@ -420,17 +439,7 @@ class AnalysisServer {
Resource resource = resourceProvider.getResource(path);
File file = resource is File ? resource : null;
{
- Folder containingFolder = null;
- AnalysisContext containingContext = null;
- folderMap.forEach((Folder folder, AnalysisContext context) {
- if (folder.isOrContains(path)) {
- if (containingFolder == null ||
- containingFolder.path.length < folder.path.length) {
- containingFolder = folder;
- containingContext = context;
- }
- }
- });
+ AnalysisContext containingContext = getContainingContext(path);
if (containingContext != null) {
Source source = file != null
? ContextManager.createSourceInContext(containingContext, file)
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/operation/operation_analysis.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698