| 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 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import 'package:analysis_server/src/protocol_server.dart' hide Element, | 10 import 'package:analysis_server/src/protocol_server.dart' hide Element, |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 if (future != null) { | 105 if (future != null) { |
| 106 return future.then(addSuggestions); | 106 return future.then(addSuggestions); |
| 107 } | 107 } |
| 108 return addSuggestions(true); | 108 return addSuggestions(true); |
| 109 } | 109 } |
| 110 | 110 |
| 111 /** | 111 /** |
| 112 * Add imported element suggestions. | 112 * Add imported element suggestions. |
| 113 */ | 113 */ |
| 114 void _addElementSuggestions(List<Element> elements, {int relevance: | 114 void _addElementSuggestions(List<Element> elements, {int relevance: |
| 115 COMPLETION_RELEVANCE_DEFAULT}) { | 115 DART_RELEVANCE_DEFAULT}) { |
| 116 elements.forEach((Element elem) { | 116 elements.forEach((Element elem) { |
| 117 if (elem is! ClassElement) { | 117 if (elem is! ClassElement) { |
| 118 if (typesOnly) { | 118 if (typesOnly) { |
| 119 return; | 119 return; |
| 120 } | 120 } |
| 121 if (elem is ExecutableElement) { | 121 if (elem is ExecutableElement) { |
| 122 DartType returnType = elem.returnType; | 122 DartType returnType = elem.returnType; |
| 123 if (returnType != null && returnType.isVoid) { | 123 if (returnType != null && returnType.isVoid) { |
| 124 if (excludeVoidReturn) { | 124 if (excludeVoidReturn) { |
| 125 return; | 125 return; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 } | 191 } |
| 192 | 192 |
| 193 //TODO (danrubel) Revisit this filtering once paged API has been added | 193 //TODO (danrubel) Revisit this filtering once paged API has been added |
| 194 addFilteredSuggestions(List<CompletionSuggestion> unfiltered) { | 194 addFilteredSuggestions(List<CompletionSuggestion> unfiltered) { |
| 195 unfiltered.forEach((CompletionSuggestion suggestion) { | 195 unfiltered.forEach((CompletionSuggestion suggestion) { |
| 196 if (filterText.length > 0) { | 196 if (filterText.length > 0) { |
| 197 if (suggestion.completion.startsWith(filterText)) { | 197 if (suggestion.completion.startsWith(filterText)) { |
| 198 request.suggestions.add(suggestion); | 198 request.suggestions.add(suggestion); |
| 199 } | 199 } |
| 200 } else { | 200 } else { |
| 201 if (suggestion.relevance != COMPLETION_RELEVANCE_LOW) { | 201 if (suggestion.relevance != DART_RELEVANCE_LOW) { |
| 202 request.suggestions.add(suggestion); | 202 request.suggestions.add(suggestion); |
| 203 } | 203 } |
| 204 } | 204 } |
| 205 }); | 205 }); |
| 206 } | 206 } |
| 207 | 207 |
| 208 DartCompletionCache cache = request.cache; | 208 DartCompletionCache cache = request.cache; |
| 209 addFilteredSuggestions(cache.importedTypeSuggestions); | 209 addFilteredSuggestions(cache.importedTypeSuggestions); |
| 210 addFilteredSuggestions(cache.libraryPrefixSuggestions); | 210 addFilteredSuggestions(cache.libraryPrefixSuggestions); |
| 211 if (!typesOnly) { | 211 if (!typesOnly) { |
| 212 addFilteredSuggestions(cache.otherImportedSuggestions); | 212 addFilteredSuggestions(cache.otherImportedSuggestions); |
| 213 if (!excludeVoidReturn) { | 213 if (!excludeVoidReturn) { |
| 214 addFilteredSuggestions(cache.importedVoidReturnSuggestions); | 214 addFilteredSuggestions(cache.importedVoidReturnSuggestions); |
| 215 } | 215 } |
| 216 } | 216 } |
| 217 } | 217 } |
| 218 } | 218 } |
| OLD | NEW |