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

Unified Diff: pkg/analysis_server/lib/src/services/completion/dart/common_usage_sorter.dart

Issue 2478963002: Completion with the new analysis driver. (Closed)
Patch Set: Fixes for review comments. Created 4 years, 1 month 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/services/completion/dart/common_usage_sorter.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/common_usage_sorter.dart b/pkg/analysis_server/lib/src/services/completion/dart/common_usage_sorter.dart
index 719221e8f035bfaaaaa12bb07cc689028338dd64..67f7137d12af24fcf58ce74e07a30b2be9325690 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/common_usage_sorter.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/common_usage_sorter.dart
@@ -46,18 +46,24 @@ class CommonUsageSorter implements DartContributionSorter {
}
CompletionTarget _getCompletionTarget(CompletionRequest request) {
- // TODO (danrubel) get cached completion target
- var libSrcs = request.context.getLibrariesContaining(request.source);
- if (libSrcs.length == 0) {
- return null;
- }
- var libElem = request.context.getResult(libSrcs[0], LIBRARY_ELEMENT1);
- if (libElem is LibraryElement) {
- var unit = request.context.getResult(
- new LibrarySpecificUnit(libElem.source, request.source),
- RESOLVED_UNIT5);
- if (unit is CompilationUnit) {
- return new CompletionTarget.forOffset(unit, request.offset);
+ if (request.result != null) {
+ var unit = request.result.unit;
+ return new CompletionTarget.forOffset(unit, request.offset);
+ } else {
+ // TODO (danrubel) get cached completion target
+ var libSrcs = request.context.getLibrariesContaining(request.source);
+ if (libSrcs.length == 0) {
+ return null;
+ }
+ LibraryElement libElem =
+ request.context.getResult(libSrcs[0], LIBRARY_ELEMENT1);
+ if (libElem is LibraryElement) {
+ var unit = request.context.getResult(
+ new LibrarySpecificUnit(libElem.source, request.source),
+ RESOLVED_UNIT5);
+ if (unit is CompilationUnit) {
+ return new CompletionTarget.forOffset(unit, request.offset);
+ }
}
}
return null;

Powered by Google App Engine
This is Rietveld 408576698