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

Side by Side Diff: pkg/analysis_server/lib/src/services/completion/dart/local_reference_contributor.dart

Issue 2728653004: Default arg support continued (flutter-intellij#553). (Closed)
Patch Set: Review tweaks. Created 3 years, 9 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/dart/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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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.contributor.dart.local_ref; 5 library services.completion.contributor.dart.local_ref;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/plugin/protocol/protocol.dart' as protocol 9 import 'package:analysis_server/plugin/protocol/protocol.dart' as protocol
10 show Element, ElementKind; 10 show Element, ElementKind;
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 .where((FormalParameter param) => param.kind == ParameterKind.REQUIRED) 475 .where((FormalParameter param) => param.kind == ParameterKind.REQUIRED)
476 .map((p) => p.element); 476 .map((p) => p.element);
477 suggestion.requiredParameterCount = requiredParameters.length; 477 suggestion.requiredParameterCount = requiredParameters.length;
478 478
479 Iterable<ParameterElement> namedParameters = paramList 479 Iterable<ParameterElement> namedParameters = paramList
480 .where((FormalParameter param) => param.kind == ParameterKind.NAMED) 480 .where((FormalParameter param) => param.kind == ParameterKind.NAMED)
481 .map((p) => p.element); 481 .map((p) => p.element);
482 suggestion.hasNamedParameters = namedParameters.isNotEmpty; 482 suggestion.hasNamedParameters = namedParameters.isNotEmpty;
483 483
484 suggestion.defaultArgumentListString = 484 suggestion.defaultArgumentListString =
485 _buildDefaultArgList(requiredParameters, namedParameters); 485 buildDefaultArgList(requiredParameters, namedParameters);
486 }
487
488 String _buildDefaultArgList(Iterable<ParameterElement> requiredParams,
489 Iterable<ParameterElement> namedParams) {
490 List<String> args = requiredParams.map((p) => p.name).toList();
491 List<String> requiredArgs = namedParams
492 .where((p) => p.isRequired)
493 .map((p) => '${p.name}: null')
494 .toList();
495 args.addAll(requiredArgs);
496 return args.join(', ');
497 } 486 }
498 487
499 bool _isVoid(TypeAnnotation returnType) { 488 bool _isVoid(TypeAnnotation returnType) {
500 if (returnType is TypeName) { 489 if (returnType is TypeName) {
501 Identifier id = returnType.name; 490 Identifier id = returnType.name;
502 if (id != null && id.name == 'void') { 491 if (id != null && id.name == 'void') {
503 return true; 492 return true;
504 } 493 }
505 } 494 }
506 return false; 495 return false;
(...skipping 17 matching lines...) Expand all
524 String text = documentationComment.tokens 513 String text = documentationComment.tokens
525 .map((Token t) => t.toString()) 514 .map((Token t) => t.toString())
526 .join('\n') 515 .join('\n')
527 .replaceAll('\r\n', '\n'); 516 .replaceAll('\r\n', '\n');
528 String doc = removeDartDocDelimiters(text); 517 String doc = removeDartDocDelimiters(text);
529 suggestion.docComplete = doc; 518 suggestion.docComplete = doc;
530 suggestion.docSummary = getDartDocSummary(doc); 519 suggestion.docSummary = getDartDocSummary(doc);
531 } 520 }
532 } 521 }
533 } 522 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698