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

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

Issue 1504233002: add suggestion for partial named parameter - fixes #24758 (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address comments 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
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/completion/dart/arglist_contributor_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/services/completion/dart/arglist_contributor.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/arglist_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/arglist_contributor.dart
index 46e20aa5ff6fb60b59a50e42d37d9958bf4e1ef4..85d0cf6945f238b3f8a7560e80dd3d23291b2d37 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/arglist_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/arglist_contributor.dart
@@ -87,6 +87,23 @@ bool _isAppendingToArgList(DartCompletionRequest request) {
}
/**
+ * Determine if the completion target is the label for a named argument.
+ */
+bool _isEditingNamedArgLabel(DartCompletionRequest request) {
+ AstNode node = request.target.containingNode;
+ if (node is ArgumentList) {
+ var entity = request.target.entity;
+ if (entity is NamedExpression) {
+ int offset = request.offset;
+ if (entity.offset <= offset && offset < entity.end) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+/**
* Determine if the completion target is an emtpy argument list.
*/
bool _isEmptyArgList(DartCompletionRequest request) {
@@ -233,7 +250,7 @@ class ArgListContributor extends DartCompletionContributor {
_addArgListSuggestion(requiredParam);
return;
}
- if (_isAppendingToArgList(request)) {
+ if (_isEditingNamedArgLabel(request) || _isAppendingToArgList(request)) {
if (requiredCount == 0 || requiredCount < _argCount(request)) {
_addDefaultParamSuggestions(parameters);
}
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/completion/dart/arglist_contributor_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698