mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 22:00:09 +00:00
Fix for suggesting methods as a *name* of a local variable declaration.
R=brianwilkerson@google.com, danrubel@google.com BUG= Review URL: https://codereview.chromium.org/1417603002 .
This commit is contained in:
parent
4249335a0e
commit
ea947094ae
|
@ -187,9 +187,13 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
|
|||
|
||||
@override
|
||||
visitForStatement(ForStatement node) {
|
||||
if (entity == node.rightSeparator && entity.toString() != ';') {
|
||||
// Handle the degenerate case while typing - for (int x i^)
|
||||
_addSuggestion(Keyword.IN, DART_RELEVANCE_HIGH);
|
||||
// Handle the degenerate case while typing - for (int x i^)
|
||||
if (node.condition == entity && entity is SimpleIdentifier) {
|
||||
Token entityToken = (entity as SimpleIdentifier).beginToken;
|
||||
if (entityToken.previous.isSynthetic &&
|
||||
entityToken.previous.type == TokenType.SEMICOLON) {
|
||||
_addSuggestion(Keyword.IN, DART_RELEVANCE_HIGH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4224,6 +4224,14 @@ abstract class AbstractSelectorSuggestionTest extends AbstractCompletionTest {
|
|||
});
|
||||
}
|
||||
|
||||
test_localVariableDeclarationName() {
|
||||
addTestSource('main() {String m^}');
|
||||
return computeFull((bool result) {
|
||||
assertNotSuggested('main');
|
||||
assertNotSuggested('min');
|
||||
});
|
||||
}
|
||||
|
||||
test_PrefixedIdentifier_trailingStmt_param2() {
|
||||
// SimpleIdentifier PrefixedIdentifier ExpressionStatement
|
||||
addTestSource('f(String g) {g.^ int y = 0;}');
|
||||
|
|
|
@ -1160,18 +1160,18 @@ class C2 {
|
|||
assertOpType(typeNames: false);
|
||||
}
|
||||
|
||||
test_SimpleFormalParameter_type_optionalPositional() {
|
||||
// SimpleIdentifier DefaultFormalParameter FormalParameterList
|
||||
addTestSource('m([Str^]) {}');
|
||||
assertOpType(typeNames: true);
|
||||
}
|
||||
|
||||
test_SimpleFormalParameter_type_optionalNamed() {
|
||||
// SimpleIdentifier DefaultFormalParameter FormalParameterList
|
||||
addTestSource('m({Str^}) {}');
|
||||
assertOpType(typeNames: true);
|
||||
}
|
||||
|
||||
test_SimpleFormalParameter_type_optionalPositional() {
|
||||
// SimpleIdentifier DefaultFormalParameter FormalParameterList
|
||||
addTestSource('m([Str^]) {}');
|
||||
assertOpType(typeNames: true);
|
||||
}
|
||||
|
||||
test_SimpleFormalParameter_type_withName() {
|
||||
// SimpleIdentifier SimpleFormalParameter FormalParameterList
|
||||
addTestSource('m(Str^ name) {}');
|
||||
|
@ -1368,6 +1368,20 @@ class C2 {
|
|||
assertOpType();
|
||||
}
|
||||
|
||||
test_VariableDeclaration_name_hasSome_parameterizedType() {
|
||||
// SimpleIdentifier VariableDeclaration VariableDeclarationList
|
||||
// VariableDeclarationStatement Block
|
||||
addTestSource('main() {List<int> m^}');
|
||||
assertOpType();
|
||||
}
|
||||
|
||||
test_VariableDeclaration_name_hasSome_simpleType() {
|
||||
// SimpleIdentifier VariableDeclaration VariableDeclarationList
|
||||
// VariableDeclarationStatement Block
|
||||
addTestSource('main() {String m^}');
|
||||
assertOpType();
|
||||
}
|
||||
|
||||
test_VariableDeclarationList_final() {
|
||||
// VariableDeclarationList VariableDeclarationStatement Block
|
||||
addTestSource('main() {final ^}');
|
||||
|
|
Loading…
Reference in a new issue