| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library services.completion.computer.dart.toplevel; | 5 library services.completion.computer.dart.toplevel; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/protocol.dart' as protocol show Element, | 9 import 'package:analysis_server/src/protocol.dart' as protocol show Element, |
| 10 ElementKind; | 10 ElementKind; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 59 |
| 60 @override | 60 @override |
| 61 Future<bool> visitSimpleIdentifier(SimpleIdentifier node) { | 61 Future<bool> visitSimpleIdentifier(SimpleIdentifier node) { |
| 62 AstNode parent = node.parent; | 62 AstNode parent = node.parent; |
| 63 if (parent is Combinator) { | 63 if (parent is Combinator) { |
| 64 return _addCombinatorSuggestions(parent); | 64 return _addCombinatorSuggestions(parent); |
| 65 } | 65 } |
| 66 if (parent is ExpressionStatement) { | 66 if (parent is ExpressionStatement) { |
| 67 return _addImportedElementSuggestions(); | 67 return _addImportedElementSuggestions(); |
| 68 } | 68 } |
| 69 if (parent is PrefixedIdentifier) { |
| 70 if (request.offset <= parent.prefix.end) { |
| 71 return _addImportedElementSuggestions(); |
| 72 } |
| 73 } |
| 69 return new Future.value(false); | 74 return new Future.value(false); |
| 70 } | 75 } |
| 71 | 76 |
| 72 Future _addCombinatorSuggestions(Combinator node) { | 77 Future _addCombinatorSuggestions(Combinator node) { |
| 73 var directive = node.getAncestor((parent) => parent is NamespaceDirective); | 78 var directive = node.getAncestor((parent) => parent is NamespaceDirective); |
| 74 if (directive is NamespaceDirective) { | 79 if (directive is NamespaceDirective) { |
| 75 LibraryElement library = directive.uriElement; | 80 LibraryElement library = directive.uriElement; |
| 76 LibraryElementSuggestionBuilder.suggestionsFor(request, library); | 81 LibraryElementSuggestionBuilder.suggestionsFor(request, library); |
| 77 return new Future.value(true); | 82 return new Future.value(true); |
| 78 } | 83 } |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 importElem.isDeprecated, | 189 importElem.isDeprecated, |
| 185 false); | 190 false); |
| 186 LibraryElement lib = importElem.importedLibrary; | 191 LibraryElement lib = importElem.importedLibrary; |
| 187 if (lib != null) { | 192 if (lib != null) { |
| 188 suggestion.element = new protocol.Element.fromEngine(lib); | 193 suggestion.element = new protocol.Element.fromEngine(lib); |
| 189 } | 194 } |
| 190 request.suggestions.add(suggestion); | 195 request.suggestions.add(suggestion); |
| 191 } | 196 } |
| 192 } | 197 } |
| 193 } | 198 } |
| OLD | NEW |