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

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

Issue 1500793003: rework ArgListContributor to use new task model (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge Created 5 years 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/completion_manager.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/completion_manager.dart b/pkg/analysis_server/lib/src/services/completion/dart/completion_manager.dart
index 8f9754ca097b3f5fd9fcea9e00b1614d82031777..6f182d813487e9dfbb72823ce03eeff57dff2962 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/completion_manager.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/completion_manager.dart
@@ -90,6 +90,15 @@ class DartCompletionRequestImpl extends CompletionRequestImpl
: super(context, resourceProvider, searchEngine, source, offset);
@override
+ CompletionTarget get target {
+ if (_target == null) {
+ CompilationUnit unit = context.computeResult(source, PARSED_UNIT);
+ _target = new CompletionTarget.forOffset(unit, offset);
+ }
+ return _target;
+ }
+
+ @override
Future<CompilationUnit> resolveDeclarationsInScope() async {
CompilationUnit unit = target.unit;
if (_haveResolveDeclarationsInScope) {
@@ -131,11 +140,46 @@ class DartCompletionRequestImpl extends CompletionRequestImpl
}
@override
- CompletionTarget get target {
- if (_target == null) {
- CompilationUnit unit = context.computeResult(source, PARSED_UNIT);
- _target = new CompletionTarget.forOffset(unit, offset);
+ Future resolveIdentifier(SimpleIdentifier identifier) async {
+ if (identifier.bestElement != null) {
+ return;
}
- return _target;
+
+ //TODO(danrubel) resolve the expression or containing method
+ // rather than the entire complilation unit
+
+ CompilationUnit unit = target.unit;
+
+ // Determine the library source
+ Source librarySource;
+ if (unit.directives.any((d) => d is PartOfDirective)) {
+ List<Source> libraries = context.getLibrariesContaining(source);
+ if (libraries.isEmpty) {
+ return;
+ }
+ librarySource = libraries[0];
+ } else {
+ librarySource = source;
+ }
+
+ // Resolve declarations in the target unit
+ CompilationUnit resolvedUnit =
+ await new AnalysisFutureHelper<CompilationUnit>(
+ context,
+ new LibrarySpecificUnit(librarySource, source),
+ RESOLVED_UNIT).computeAsync();
+
+ // TODO(danrubel) determine if the underlying source has been modified
+ // in a way that invalidates the completion request
+ // and return null
+
+ // Gracefully degrade if unit cannot be resolved
+ if (resolvedUnit == null) {
+ return;
+ }
+
+ // Recompute the target for the newly resolved unit
+ _target = new CompletionTarget.forOffset(resolvedUnit, offset);
+ _haveResolveDeclarationsInScope = true;
}
}

Powered by Google App Engine
This is Rietveld 408576698