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

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

Issue 2839273002: Named arg completion fixes (flutter-intellij#551) (Closed)
Patch Set: formatting Created 3 years, 8 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/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 579b7b8662c16a1b621dddba7de8b6008a459b3e..a179311633dce22b0642c9669c4ca0d06e0b4081 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
@@ -14,6 +14,7 @@ import 'package:analysis_server/src/services/completion/dart/utilities.dart';
import 'package:analysis_server/src/services/correction/flutter_util.dart';
import 'package:analysis_server/src/utilities/documentation.dart';
import 'package:analyzer/dart/ast/ast.dart';
+import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/generated/utilities_dart.dart';
@@ -251,6 +252,7 @@ class ArgListContributor extends DartCompletionContributor {
if (appendColon) {
completion += ': ';
}
+ int selectionOffset = completion.length;
if (appendComma) {
completion += ',';
}
@@ -258,7 +260,7 @@ class ArgListContributor extends DartCompletionContributor {
CompletionSuggestionKind.NAMED_ARGUMENT,
DART_RELEVANCE_NAMED_PARAMETER,
completion,
- completion.length,
+ selectionOffset,
0,
false,
false,
@@ -305,7 +307,11 @@ class ArgListContributor extends DartCompletionContributor {
} else if (_isInsertingToArgListWithNoSynthetic(request)) {
_addDefaultParamSuggestions(parameters, true);
} else if (_isInsertingToArgListWithSynthetic(request)) {
- _addDefaultParamSuggestions(parameters);
+ var entity = request.target.entity;
+ Token token =
+ entity is AstNode ? entity.endToken : entity is Token ? entity : null;
+ bool followedByComma = token?.next?.type == TokenType.COMMA;
+ _addDefaultParamSuggestions(parameters, !followedByComma);
}
}
« 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