| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 // as they will be included by the LocalComputer | 93 // as they will be included by the LocalComputer |
| 94 excludedLibs.add(request.unit.element.library); | 94 excludedLibs.add(request.unit.element.library); |
| 95 | 95 |
| 96 // Build the set of visible and excluded libraries | 96 // Build the set of visible and excluded libraries |
| 97 // and the list of names that should be shown or hidden | 97 // and the list of names that should be shown or hidden |
| 98 request.unit.directives.forEach((Directive directive) { | 98 request.unit.directives.forEach((Directive directive) { |
| 99 if (directive is ImportDirective) { | 99 if (directive is ImportDirective) { |
| 100 ImportElement element = directive.element; | 100 ImportElement element = directive.element; |
| 101 if (element != null) { | 101 if (element != null) { |
| 102 LibraryElement lib = element.importedLibrary; | 102 LibraryElement lib = element.importedLibrary; |
| 103 if (directive.prefix == null) { | 103 SimpleIdentifier prefix = directive.prefix; |
| 104 if (prefix == null) { |
| 104 visibleLibs.add(lib); | 105 visibleLibs.add(lib); |
| 105 directive.combinators.forEach((Combinator combinator) { | 106 directive.combinators.forEach((Combinator combinator) { |
| 106 if (combinator is ShowCombinator) { | 107 if (combinator is ShowCombinator) { |
| 107 showNames[lib] = | 108 showNames[lib] = |
| 108 combinator.shownNames.map((SimpleIdentifier id) => id.name
).toSet(); | 109 combinator.shownNames.map((SimpleIdentifier id) => id.name
).toSet(); |
| 109 } else if (combinator is HideCombinator) { | 110 } else if (combinator is HideCombinator) { |
| 110 hideNames[lib] = | 111 hideNames[lib] = |
| 111 combinator.hiddenNames.map((SimpleIdentifier id) => id.nam
e).toSet(); | 112 combinator.hiddenNames.map((SimpleIdentifier id) => id.nam
e).toSet(); |
| 112 } | 113 } |
| 113 }); | 114 }); |
| 114 } else { | 115 } else { |
| 116 String completion = prefix.name; |
| 117 if (completion != null && completion.length > 0) { |
| 118 CompletionSuggestion suggestion = new CompletionSuggestion( |
| 119 CompletionSuggestionKind.LIBRARY_PREFIX, |
| 120 CompletionRelevance.DEFAULT, |
| 121 completion, |
| 122 completion.length, |
| 123 0, |
| 124 element.isDeprecated, |
| 125 false); |
| 126 suggestion.element = new protocol.Element.fromEngine(lib); |
| 127 request.suggestions.add(suggestion); |
| 128 } |
| 115 excludedLibs.add(lib); | 129 excludedLibs.add(lib); |
| 116 } | 130 } |
| 117 } | 131 } |
| 118 } | 132 } |
| 119 }); | 133 }); |
| 120 | 134 |
| 121 // Compute the set of possible classes, functions, and top level variables | 135 // Compute the set of possible classes, functions, and top level variables |
| 122 matches.forEach((SearchMatch match) { | 136 matches.forEach((SearchMatch match) { |
| 123 if (match.kind == MatchKind.DECLARATION) { | 137 if (match.kind == MatchKind.DECLARATION) { |
| 124 Element element = match.element; | 138 Element element = match.element; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 | 180 |
| 167 request.suggestions.add(suggestion); | 181 request.suggestions.add(suggestion); |
| 168 } | 182 } |
| 169 } | 183 } |
| 170 } | 184 } |
| 171 }); | 185 }); |
| 172 return true; | 186 return true; |
| 173 }); | 187 }); |
| 174 } | 188 } |
| 175 } | 189 } |
| OLD | NEW |