| Index: pkg/analysis_server/lib/src/services/completion/imported_computer.dart
|
| diff --git a/pkg/analysis_server/lib/src/services/completion/imported_computer.dart b/pkg/analysis_server/lib/src/services/completion/imported_computer.dart
|
| index ceed8ff882ddb58d92e920122ac9767b08a5626e..bd1fd8bc4d193a2bdd4f6c2683b8d6e7ebceab9f 100644
|
| --- a/pkg/analysis_server/lib/src/services/completion/imported_computer.dart
|
| +++ b/pkg/analysis_server/lib/src/services/completion/imported_computer.dart
|
| @@ -6,7 +6,8 @@ library services.completion.computer.dart.toplevel;
|
|
|
| import 'dart:async';
|
|
|
| -import 'package:analysis_server/src/protocol.dart' as protocol show Element, ElementKind;
|
| +import 'package:analysis_server/src/protocol.dart' as protocol show Element,
|
| + ElementKind;
|
| import 'package:analysis_server/src/protocol.dart' hide Element, ElementKind;
|
| import 'package:analysis_server/src/services/completion/dart_completion_manager.dart';
|
| import 'package:analysis_server/src/services/completion/suggestion_builder.dart';
|
| @@ -45,52 +46,38 @@ class _ImportedVisitor extends GeneralizingAstVisitor<Future<bool>> {
|
| _ImportedVisitor(this.request);
|
|
|
| @override
|
| - Future<bool> visitCombinator(Combinator node) {
|
| - NamespaceDirective directive =
|
| - node.getAncestor((parent) => parent is NamespaceDirective);
|
| - if (directive != null) {
|
| - LibraryElement library = directive.uriElement;
|
| - LibraryElementSuggestionBuilder.suggestionsFor(request, library);
|
| - return new Future.value(true);
|
| - }
|
| - return new Future.value(false);
|
| - }
|
| -
|
| - @override
|
| - Future<bool> visitExpressionStatement(ExpressionStatement node) {
|
| - Expression expression = node.expression;
|
| - if (expression is SimpleIdentifier) {
|
| - if (expression.end < request.offset) {
|
| - // Don't suggest imported elements for local var name
|
| - return new Future.value(false);
|
| - }
|
| - }
|
| - return visitNode(node);
|
| + Future<bool> visitBlock(Block node) {
|
| + return _addImportedElementSuggestions();
|
| }
|
|
|
| @override
|
| Future<bool> visitNode(AstNode node) {
|
| - return _addImportedElements();
|
| + return new Future.value(false);
|
| }
|
|
|
| @override
|
| Future<bool> visitSimpleIdentifier(SimpleIdentifier node) {
|
| - return node.parent.accept(this);
|
| + AstNode parent = node.parent;
|
| + if (parent is Combinator) {
|
| + return _addCombinatorSuggestions(parent);
|
| + }
|
| + if (parent is ExpressionStatement) {
|
| + return _addImportedElementSuggestions();
|
| + }
|
| + return new Future.value(false);
|
| }
|
|
|
| - @override
|
| - Future<bool> visitVariableDeclaration(VariableDeclaration node) {
|
| - // Do not add suggestions if editing the name in a var declaration
|
| - SimpleIdentifier name = node.name;
|
| - if (name == null ||
|
| - name.offset < request.offset ||
|
| - request.offset > name.end) {
|
| - return visitNode(node);
|
| + Future _addCombinatorSuggestions(Combinator node) {
|
| + var directive = node.getAncestor((parent) => parent is NamespaceDirective);
|
| + if (directive is NamespaceDirective) {
|
| + LibraryElement library = directive.uriElement;
|
| + LibraryElementSuggestionBuilder.suggestionsFor(request, library);
|
| + return new Future.value(true);
|
| }
|
| return new Future.value(false);
|
| }
|
|
|
| - Future<bool> _addImportedElements() {
|
| + Future<bool> _addImportedElementSuggestions() {
|
| var future = request.searchEngine.searchTopLevelDeclarations('');
|
| return future.then((List<SearchMatch> matches) {
|
|
|
|
|