| 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' hide Element; | 9 import 'package:analysis_server/src/protocol.dart' hide Element; |
| 10 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; | 10 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 new Map<LibraryElement, Set<String>>(); | 102 new Map<LibraryElement, Set<String>>(); |
| 103 | 103 |
| 104 // Exclude elements from the local library | 104 // Exclude elements from the local library |
| 105 // as they will be included by the LocalComputer | 105 // as they will be included by the LocalComputer |
| 106 excludedLibs.add(request.unit.element.library); | 106 excludedLibs.add(request.unit.element.library); |
| 107 | 107 |
| 108 // Build the set of visible and excluded libraries | 108 // Build the set of visible and excluded libraries |
| 109 // and the list of names that should be shown or hidden | 109 // and the list of names that should be shown or hidden |
| 110 request.unit.directives.forEach((Directive directive) { | 110 request.unit.directives.forEach((Directive directive) { |
| 111 if (directive is ImportDirective) { | 111 if (directive is ImportDirective) { |
| 112 LibraryElement lib = directive.element.importedLibrary; | 112 ImportElement element = directive.element; |
| 113 if (directive.prefix == null) { | 113 if (element != null) { |
| 114 visibleLibs.add(lib); | 114 LibraryElement lib = element.importedLibrary; |
| 115 directive.combinators.forEach((Combinator combinator) { | 115 if (directive.prefix == null) { |
| 116 if (combinator is ShowCombinator) { | 116 visibleLibs.add(lib); |
| 117 showNames[lib] = | 117 directive.combinators.forEach((Combinator combinator) { |
| 118 combinator.shownNames.map((SimpleIdentifier id) => id.name).
toSet(); | 118 if (combinator is ShowCombinator) { |
| 119 } else if (combinator is HideCombinator) { | 119 showNames[lib] = |
| 120 hideNames[lib] = | 120 combinator.shownNames.map((SimpleIdentifier id) => id.name
).toSet(); |
| 121 combinator.hiddenNames.map((SimpleIdentifier id) => id.name)
.toSet(); | 121 } else if (combinator is HideCombinator) { |
| 122 } | 122 hideNames[lib] = |
| 123 }); | 123 combinator.hiddenNames.map((SimpleIdentifier id) => id.nam
e).toSet(); |
| 124 } else { | 124 } |
| 125 excludedLibs.add(lib); | 125 }); |
| 126 } else { |
| 127 excludedLibs.add(lib); |
| 128 } |
| 126 } | 129 } |
| 127 } | 130 } |
| 128 }); | 131 }); |
| 129 | 132 |
| 130 // Compute the set of possible classes, functions, and top level variables | 133 // Compute the set of possible classes, functions, and top level variables |
| 131 matches.forEach((SearchMatch match) { | 134 matches.forEach((SearchMatch match) { |
| 132 if (match.kind == MatchKind.DECLARATION) { | 135 if (match.kind == MatchKind.DECLARATION) { |
| 133 Element element = match.element; | 136 Element element = match.element; |
| 134 LibraryElement lib = element.library; | 137 LibraryElement lib = element.library; |
| 135 if (element.isPublic && !excludedLibs.contains(lib)) { | 138 if (element.isPublic && !excludedLibs.contains(lib)) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 176 |
| 174 request.suggestions.add(suggestion); | 177 request.suggestions.add(suggestion); |
| 175 } | 178 } |
| 176 } | 179 } |
| 177 } | 180 } |
| 178 }); | 181 }); |
| 179 return true; | 182 return true; |
| 180 }); | 183 }); |
| 181 } | 184 } |
| 182 } | 185 } |
| OLD | NEW |