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

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

Issue 946803002: Create package: URIs everywhere (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 1f58eb92a58e4a8d99331c403d3e7b941bd50479..40297678f22555d376fb68795a83013879084ea1 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -374,7 +374,7 @@ class AnalysisServer {
return null;
}
// check if there is a context that analyzed this source
- return getAnalysisContextForSource(getSource(path));
+ return getAnalysisContextForSource(_getSourceWithoutContext(path));
}
/**
@@ -497,32 +497,6 @@ class AnalysisServer {
// }
/**
- * Returns resolved [CompilationUnit]s of the Dart file with the given [path].
- *
- * May be empty, but not `null`.
- */
- List<CompilationUnit> getResolvedCompilationUnits(String path) {
- List<CompilationUnit> units = <CompilationUnit>[];
- // prepare AnalysisContext
- AnalysisContext context = getAnalysisContext(path);
- if (context == null) {
- return units;
- }
- // add a unit for each unit/library combination
- Source unitSource = getSource(path);
- List<Source> librarySources = context.getLibrariesContaining(unitSource);
- for (Source librarySource in librarySources) {
- CompilationUnit unit =
- context.resolveCompilationUnit2(unitSource, librarySource);
- if (unit != null) {
- units.add(unit);
- }
- }
- // done
- return units;
- }
-
- /**
* Returns the [CompilationUnit] of the Dart file with the given [path] that
* should be used to resend notifications for already resolved unit.
* Returns `null` if the file is not a part of any context, library has not
@@ -550,6 +524,32 @@ class AnalysisServer {
}
/**
+ * Returns resolved [CompilationUnit]s of the Dart file with the given [path].
+ *
+ * May be empty, but not `null`.
+ */
+ List<CompilationUnit> getResolvedCompilationUnits(String path) {
+ List<CompilationUnit> units = <CompilationUnit>[];
+ // prepare AnalysisContext
+ AnalysisContext context = getAnalysisContext(path);
+ if (context == null) {
+ return units;
+ }
+ // add a unit for each unit/library combination
+ Source unitSource = getSource(path);
+ List<Source> librarySources = context.getLibrariesContaining(unitSource);
+ for (Source librarySource in librarySources) {
+ CompilationUnit unit =
+ context.resolveCompilationUnit2(unitSource, librarySource);
+ if (unit != null) {
+ units.add(unit);
+ }
+ }
+ // done
+ return units;
+ }
+
+ /**
* Return the [Source] of the Dart file with the given [path].
*/
Source getSource(String path) {
@@ -563,7 +563,7 @@ class AnalysisServer {
}
// file-based source
File file = resourceProvider.getResource(path);
- return file.createSource();
+ return ContextManager.createSourceInContext(getAnalysisContext(path), file);
}
/**
@@ -1072,6 +1072,24 @@ class AnalysisServer {
}
/**
+ * Return the [Source] of the Dart file with the given [path], assuming that
+ * we do not know the context in which the path should be interpreted.
+ */
+ Source _getSourceWithoutContext(String path) {
+ // try SDK
+ {
+ Uri uri = resourceProvider.pathContext.toUri(path);
+ Source sdkSource = defaultSdk.fromFileUri(uri);
+ if (sdkSource != null) {
+ return sdkSource;
+ }
+ }
+ // file-based source
+ File file = resourceProvider.getResource(path);
+ return file.createSource();
+ }
+
+ /**
* Schedules [performOperation] exection.
*/
void _schedulePerformOperation() {
« 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