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

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

Issue 977223003: When target requires a function, propose a function reference, not an invocation (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge and remove unnecessary statement 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
Index: pkg/analysis_server/lib/src/services/completion/imported_computer.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/imported_computer.dart b/pkg/analysis_server/lib/src/services/completion/imported_computer.dart
index 4e025f3113136dd3e9d794e92c3621ed79df833d..7857d64f102218c588402afba0e027c525bf8fa9 100644
--- a/pkg/analysis_server/lib/src/services/completion/imported_computer.dart
+++ b/pkg/analysis_server/lib/src/services/completion/imported_computer.dart
@@ -22,6 +22,7 @@ import 'package:analyzer/src/generated/element.dart';
*/
class ImportedComputer extends DartCompletionComputer {
bool shouldWaitForLowPrioritySuggestions;
+ bool suggestionsComputed;
_ImportedSuggestionBuilder builder;
ImportedComputer({this.shouldWaitForLowPrioritySuggestions: false});
@@ -37,7 +38,10 @@ class ImportedComputer extends DartCompletionComputer {
constructorsOnly: optype.includeConstructorSuggestions);
builder.shouldWaitForLowPrioritySuggestions =
shouldWaitForLowPrioritySuggestions;
- return builder.computeFast(request.node);
+ // If target is an argument in an argument list
+ // then suggestions may need to be adjusted
+ suggestionsComputed = builder.computeFast(request.node);
+ return suggestionsComputed && request.target.argIndex == null;
}
return true;
}
@@ -45,10 +49,26 @@ class ImportedComputer extends DartCompletionComputer {
@override
Future<bool> computeFull(DartCompletionRequest request) {
if (builder != null) {
- return builder.computeFull(request.node);
+ if (!suggestionsComputed) {
+ return builder.computeFull(request.node).then((bool result) {
+ _updateSuggestions(request);
+ return result;
+ });
+ }
+ _updateSuggestions(request);
+ return new Future.value(true);
}
return new Future.value(false);
}
+
+ /**
+ * If target is a function argument, suggest identifiers not invocations
+ */
+ void _updateSuggestions(DartCompletionRequest request) {
+ if (request.target.isFunctionalArgument()) {
+ request.convertInvocationsToIdentifiers();
+ }
+ }
}
/**

Powered by Google App Engine
This is Rietveld 408576698