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

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

Issue 339933006: Fix for subscribing for notifications after analysis. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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/test/analysis_notification_navigation_test.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 da2510b0a0ce5f865f5cadeaea96a8085a984ad1..7c8fd523b45ed3a0a669fa979f6bb0b20f83a6d5 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -398,25 +398,21 @@ class AnalysisServer {
List<AnalysisError> errors = analysisContext.getErrors(source).errors;
sendAnalysisNotificationErrors(this, file, errors);
}
- // TODO(scheglov)
- // 1. implement resolveCompilationUnit()
- // 2. Share "if (dartUnit != null)"
- if (service == AnalysisService.HIGHLIGHTS) {
- CompilationUnit dartUnit = test_getResolvedCompilationUnit(file);
+ // Dart unit notifications.
+ if (AnalysisEngine.isDartFileName(file)) {
+ CompilationUnit dartUnit = resolveCompilationUnit(file);
Brian Wilkerson 2014/06/18 16:25:11 I think we need to only get the compilation unit i
scheglov 2014/06/18 17:38:27 Agree. Done.
if (dartUnit != null) {
- sendAnalysisNotificationHighlights(this, file, dartUnit);
- }
- }
- if (service == AnalysisService.NAVIGATION) {
- CompilationUnit dartUnit = test_getResolvedCompilationUnit(file);
- if (dartUnit != null) {
- sendAnalysisNotificationNavigation(this, file, dartUnit);
- }
- }
- if (service == AnalysisService.OUTLINE) {
- CompilationUnit dartUnit = test_getResolvedCompilationUnit(file);
- if (dartUnit != null) {
- sendAnalysisNotificationOutline(this, file, dartUnit);
+ switch (service) {
+ case AnalysisService.HIGHLIGHTS:
+ sendAnalysisNotificationHighlights(this, file, dartUnit);
+ break;
+ case AnalysisService.NAVIGATION:
+ sendAnalysisNotificationNavigation(this, file, dartUnit);
+ break;
+ case AnalysisService.OUTLINE:
+ sendAnalysisNotificationOutline(this, file, dartUnit);
+ break;
+ }
}
}
}
@@ -450,6 +446,26 @@ class AnalysisServer {
* Return the [CompilationUnit] of the Dart file with the given [path].
* Return `null` if the file is not a part of any context.
*/
+ CompilationUnit resolveCompilationUnit(String path) {
+ // prepare AnalysisContext
+ AnalysisContext context = _getAnalysisContext(path);
+ if (context == null) {
+ return null;
+ }
+ // prepare sources
+ Source unitSource = _getSource(path);
+ List<Source> librarySources = context.getLibrariesContaining(unitSource);
+ if (librarySources.isEmpty) {
+ return null;
+ }
+ // resolve the unit
+ return context.resolveCompilationUnit2(unitSource, librarySources[0]);
Brian Wilkerson 2014/06/18 16:25:11 We need to handle the case where a file is in more
scheglov 2014/06/18 17:38:27 AFAIK multiple libraries matter only for navigatio
+ }
+
+ /**
+ * Return the [CompilationUnit] of the Dart file with the given [path].
+ * Return `null` if the file is not a part of any context.
+ */
CompilationUnit test_getResolvedCompilationUnit(String path) {
// prepare AnalysisContext
AnalysisContext context = _getAnalysisContext(path);
« no previous file with comments | « no previous file | pkg/analysis_server/test/analysis_notification_navigation_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698