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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library services.completion.dart.optype; 5 library services.completion.dart.optype;
6 6
7 import 'package:analysis_server/src/provisional/completion/dart/completion_targe t.dart'; 7 import 'package:analysis_server/src/provisional/completion/dart/completion_targe t.dart';
8 import 'package:analyzer/src/generated/ast.dart'; 8 import 'package:analyzer/src/generated/ast.dart';
9 import 'package:analyzer/src/generated/scanner.dart'; 9 import 'package:analyzer/src/generated/scanner.dart';
10 10
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 } 318 }
319 } 319 }
320 if (identical(entity, node.iterable)) { 320 if (identical(entity, node.iterable)) {
321 optype.includeReturnValueSuggestions = true; 321 optype.includeReturnValueSuggestions = true;
322 optype.includeTypeNameSuggestions = true; 322 optype.includeTypeNameSuggestions = true;
323 } 323 }
324 } 324 }
325 325
326 @override 326 @override
327 void visitFormalParameterList(FormalParameterList node) { 327 void visitFormalParameterList(FormalParameterList node) {
328 optype.includeTypeNameSuggestions = true; 328 dynamic entity = this.entity;
329 if (entity is Token && entity.previous != null) {
330 TokenType type = entity.previous.type;
331 if (type == TokenType.OPEN_PAREN || type == TokenType.COMMA) {
332 optype.includeTypeNameSuggestions = true;
333 }
334 }
335 // Handle default normal parameter just as a normal parameter.
336 if (entity is DefaultFormalParameter) {
337 entity = entity.parameter;
338 }
339 // "(^ this.field)"
340 if (entity is FieldFormalParameter) {
341 if (offset < entity.thisKeyword.offset) {
342 optype.includeTypeNameSuggestions = true;
343 }
344 }
345 // "(Type name)"
346 if (entity is SimpleFormalParameter) {
347 // "(Type^)" is parsed as a parameter with the _name_ "Type".
348 if (entity.type == null) {
349 optype.includeTypeNameSuggestions = true;
350 }
351 // If inside of "Type" in "(Type^ name)", then include types.
352 if (entity.type != null &&
353 entity.type.offset <= offset &&
354 offset <= entity.type.end) {
355 optype.includeTypeNameSuggestions = true;
356 }
357 }
329 } 358 }
330 359
331 @override 360 @override
332 void visitForStatement(ForStatement node) { 361 void visitForStatement(ForStatement node) {
333 optype.includeReturnValueSuggestions = true; 362 optype.includeReturnValueSuggestions = true;
334 optype.includeTypeNameSuggestions = true; 363 optype.includeTypeNameSuggestions = true;
335 optype.includeVoidReturnSuggestions = true; 364 optype.includeVoidReturnSuggestions = true;
336 // TODO (danrubel) void return suggestions only belong after 365 // TODO (danrubel) void return suggestions only belong after
337 // the 2nd semicolon. Return value suggestions only belong after the 366 // the 2nd semicolon. Return value suggestions only belong after the
338 // e1st or second semicolon. 367 // e1st or second semicolon.
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 } 482 }
454 } 483 }
455 484
456 @override 485 @override
457 void visitNode(AstNode node) { 486 void visitNode(AstNode node) {
458 // no suggestion by default 487 // no suggestion by default
459 } 488 }
460 489
461 @override 490 @override
462 void visitNormalFormalParameter(NormalFormalParameter node) { 491 void visitNormalFormalParameter(NormalFormalParameter node) {
463 optype.includeReturnValueSuggestions = true; 492 if (node.identifier != entity) {
464 optype.includeTypeNameSuggestions = true; 493 optype.includeReturnValueSuggestions = true;
494 optype.includeTypeNameSuggestions = true;
495 }
465 } 496 }
466 497
467 void visitParenthesizedExpression(ParenthesizedExpression node) { 498 void visitParenthesizedExpression(ParenthesizedExpression node) {
468 if (identical(entity, node.expression)) { 499 if (identical(entity, node.expression)) {
469 optype.includeReturnValueSuggestions = true; 500 optype.includeReturnValueSuggestions = true;
470 optype.includeTypeNameSuggestions = true; 501 optype.includeTypeNameSuggestions = true;
471 } 502 }
472 } 503 }
473 504
474 @override 505 @override
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 void visitVariableDeclarationStatement(VariableDeclarationStatement node) {} 672 void visitVariableDeclarationStatement(VariableDeclarationStatement node) {}
642 673
643 @override 674 @override
644 void visitWhileStatement(WhileStatement node) { 675 void visitWhileStatement(WhileStatement node) {
645 if (identical(entity, node.condition)) { 676 if (identical(entity, node.condition)) {
646 optype.includeReturnValueSuggestions = true; 677 optype.includeReturnValueSuggestions = true;
647 optype.includeTypeNameSuggestions = true; 678 optype.includeTypeNameSuggestions = true;
648 } 679 }
649 } 680 }
650 } 681 }
OLDNEW
« 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