| Index: pkg/analysis_server/lib/src/services/completion/keyword_computer.dart
|
| diff --git a/pkg/analysis_server/lib/src/services/completion/keyword_computer.dart b/pkg/analysis_server/lib/src/services/completion/keyword_computer.dart
|
| index b9588be40469dad2a070651fd668d949d93eb22b..baaef7bd84cc59f95c7e75979e5513e8369bbb30 100644
|
| --- a/pkg/analysis_server/lib/src/services/completion/keyword_computer.dart
|
| +++ b/pkg/analysis_server/lib/src/services/completion/keyword_computer.dart
|
| @@ -44,27 +44,47 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
|
|
|
| @override
|
| visitBlock(Block node) {
|
| - _addSuggestions(
|
| - [
|
| - Keyword.ASSERT,
|
| - Keyword.CASE,
|
| - Keyword.CONTINUE,
|
| - Keyword.DO,
|
| - Keyword.FACTORY,
|
| - Keyword.FINAL,
|
| - Keyword.FOR,
|
| - Keyword.IF,
|
| - Keyword.NEW,
|
| - Keyword.RETHROW,
|
| - Keyword.RETURN,
|
| - Keyword.SUPER,
|
| - Keyword.SWITCH,
|
| - Keyword.THIS,
|
| - Keyword.THROW,
|
| - Keyword.TRY,
|
| - Keyword.VAR,
|
| - Keyword.VOID,
|
| - Keyword.WHILE]);
|
| + if (_isInClassMemberBody(node)) {
|
| + _addSuggestions(
|
| + [
|
| + Keyword.ASSERT,
|
| + Keyword.CASE,
|
| + Keyword.CONTINUE,
|
| + Keyword.DO,
|
| + Keyword.FINAL,
|
| + Keyword.FOR,
|
| + Keyword.IF,
|
| + Keyword.NEW,
|
| + Keyword.RETHROW,
|
| + Keyword.RETURN,
|
| + Keyword.SUPER,
|
| + Keyword.SWITCH,
|
| + Keyword.THIS,
|
| + Keyword.THROW,
|
| + Keyword.TRY,
|
| + Keyword.VAR,
|
| + Keyword.VOID,
|
| + Keyword.WHILE]);
|
| + } else {
|
| + _addSuggestions(
|
| + [
|
| + Keyword.ASSERT,
|
| + Keyword.CASE,
|
| + Keyword.CONTINUE,
|
| + Keyword.DO,
|
| + Keyword.FINAL,
|
| + Keyword.FOR,
|
| + Keyword.IF,
|
| + Keyword.NEW,
|
| + Keyword.RETHROW,
|
| + Keyword.RETURN,
|
| + Keyword.SWITCH,
|
| + Keyword.THROW,
|
| + Keyword.TRY,
|
| + Keyword.VAR,
|
| + Keyword.VOID,
|
| + Keyword.WHILE]);
|
| + }
|
| }
|
|
|
| @override
|
| @@ -231,4 +251,18 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
|
| }
|
| return false;
|
| }
|
| +
|
| + static bool _isInClassMemberBody(AstNode node) {
|
| + while (true) {
|
| + AstNode body = node.getAncestor((n) => n is FunctionBody);
|
| + if (body == null) {
|
| + return false;
|
| + }
|
| + AstNode parent = body.parent;
|
| + if (parent is ConstructorDeclaration || parent is MethodDeclaration) {
|
| + return true;
|
| + }
|
| + node = parent;
|
| + }
|
| + }
|
| }
|
|
|