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

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

Issue 1414653002: Disable completion of formal parameter names as *types*. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: tweaks Created 5 years, 2 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/lib/src/services/completion/suggestion_builder.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/optype.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/optype.dart b/pkg/analysis_server/lib/src/services/completion/optype.dart
index dc389196d50bfe94e5b9dda83994b2bbe7cde43f..3408e9637717eb4ca7685ab74036d5817f6ad8a7 100644
--- a/pkg/analysis_server/lib/src/services/completion/optype.dart
+++ b/pkg/analysis_server/lib/src/services/completion/optype.dart
@@ -325,7 +325,36 @@ class _OpTypeAstVisitor extends GeneralizingAstVisitor {
@override
void visitFormalParameterList(FormalParameterList node) {
- optype.includeTypeNameSuggestions = true;
+ dynamic entity = this.entity;
+ if (entity is Token && entity.previous != null) {
+ TokenType type = entity.previous.type;
+ if (type == TokenType.OPEN_PAREN || type == TokenType.COMMA) {
+ optype.includeTypeNameSuggestions = true;
+ }
+ }
+ // Handle default normal parameter just as a normal parameter.
+ if (entity is DefaultFormalParameter) {
+ entity = entity.parameter;
+ }
+ // "(^ this.field)"
+ if (entity is FieldFormalParameter) {
+ if (offset < entity.thisKeyword.offset) {
+ optype.includeTypeNameSuggestions = true;
+ }
+ }
+ // "(Type name)"
+ if (entity is SimpleFormalParameter) {
+ // "(Type^)" is parsed as a parameter with the _name_ "Type".
+ if (entity.type == null) {
+ optype.includeTypeNameSuggestions = true;
+ }
+ // If inside of "Type" in "(Type^ name)", then include types.
+ if (entity.type != null &&
+ entity.type.offset <= offset &&
+ offset <= entity.type.end) {
+ optype.includeTypeNameSuggestions = true;
+ }
+ }
}
@override
@@ -460,8 +489,10 @@ class _OpTypeAstVisitor extends GeneralizingAstVisitor {
@override
void visitNormalFormalParameter(NormalFormalParameter node) {
- optype.includeReturnValueSuggestions = true;
- optype.includeTypeNameSuggestions = true;
+ if (node.identifier != entity) {
+ optype.includeReturnValueSuggestions = true;
+ optype.includeTypeNameSuggestions = true;
+ }
}
void visitParenthesizedExpression(ParenthesizedExpression node) {
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/completion/suggestion_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698