improve completion for formal param initializers

R=pquitslund@google.com

Review-Url: https://codereview.chromium.org/2864233002 .
This commit is contained in:
danrubel 2017-05-08 06:50:41 -07:00
parent a4eb8b8fe3
commit 959b7c14b8
2 changed files with 35 additions and 0 deletions

View file

@ -208,6 +208,13 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
}
}
@override
visitDefaultFormalParameter(DefaultFormalParameter node) {
if (entity == node.defaultValue) {
_addExpressionKeywords(node);
}
}
@override
visitExpression(Expression node) {
_addExpressionKeywords(node);

View file

@ -1573,6 +1573,34 @@ class A {
expect(suggestions, isEmpty);
}
test_method_param_named_init() async {
addTestSource('class A { foo({bool bar: ^}) {}}');
await computeSuggestions();
expect(suggestions, isNotEmpty);
assertSuggestKeywords(EXPRESSION_START_NO_INSTANCE);
}
test_method_param_named_init2() async {
addTestSource('class A { foo({bool bar: f^}) {}}');
await computeSuggestions();
expect(suggestions, isNotEmpty);
assertSuggestKeywords(EXPRESSION_START_NO_INSTANCE);
}
test_method_param_positional_init() async {
addTestSource('class A { foo([bool bar = ^]) {}}');
await computeSuggestions();
expect(suggestions, isNotEmpty);
assertSuggestKeywords(EXPRESSION_START_NO_INSTANCE);
}
test_method_param_positional_init2() async {
addTestSource('class A { foo([bool bar = f^]) {}}');
await computeSuggestions();
expect(suggestions, isNotEmpty);
assertSuggestKeywords(EXPRESSION_START_NO_INSTANCE);
}
test_named_constructor_invocation() async {
addTestSource('void main() {new Future.^}');
await computeSuggestions();