| 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 4187b61228014780e793c8f87a774ca536f3e135..4137c7d99f4b1e6a980e1e3fdb29b7e2d1514349 100644
|
| --- a/pkg/analysis_server/lib/src/services/completion/keyword_computer.dart
|
| +++ b/pkg/analysis_server/lib/src/services/completion/keyword_computer.dart
|
| @@ -62,6 +62,13 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
|
| int startOfDeclarations = node.end;
|
| if (node.declarations.length > 0) {
|
| startOfDeclarations = node.declarations[0].offset;
|
| + // If the first token is a simple identifier
|
| + // and cursor position in within that first token
|
| + // then consider cursor to be before the first declaration
|
| + Token token = node.declarations[0].firstTokenAfterCommentAndMetadata;
|
| + if (token.offset <= request.offset && request.offset <= token.end) {
|
| + startOfDeclarations = token.end;
|
| + }
|
| }
|
|
|
| // Simplistic check for library as first directive
|
| @@ -103,6 +110,20 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
|
| }
|
| }
|
|
|
| + visitSimpleIdentifier(SimpleIdentifier node) {
|
| + AstNode parent =
|
| + node.getAncestor((n) => n is TopLevelVariableDeclaration);
|
| + if (parent is TopLevelVariableDeclaration) {
|
| + if (parent.variables != null && parent.variables.type != null
|
| + && parent.variables.type.name == node) {
|
| + AstNode unit = node.getAncestor((n) => n is CompilationUnit);
|
| + if (unit is CompilationUnit) {
|
| + visitCompilationUnit(unit);
|
| + }
|
| + }
|
| + }
|
| + }
|
| +
|
| void _addSuggestion(Keyword keyword) {
|
| String completion = keyword.syntax;
|
| request.suggestions.add(
|
|
|