| 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' | 10 import 'package:analysis_server/src/protocol_server.dart' |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 DartCompletionCache cache = request.cache; | 136 DartCompletionCache cache = request.cache; |
| 137 _addFilteredSuggestions(filterText, cache.importedConstructorSuggestions); | 137 _addFilteredSuggestions(filterText, cache.importedConstructorSuggestions); |
| 138 _addFilteredSuggestions(filterText, cache.libraryPrefixSuggestions); | 138 _addFilteredSuggestions(filterText, cache.libraryPrefixSuggestions); |
| 139 } | 139 } |
| 140 | 140 |
| 141 /** | 141 /** |
| 142 * Add imported element suggestions. | 142 * Add imported element suggestions. |
| 143 */ | 143 */ |
| 144 void _addElementSuggestions(List<Element> elements, | 144 void _addElementSuggestions(List<Element> elements, |
| 145 {int relevance: DART_RELEVANCE_DEFAULT}) { | 145 {int relevance: DART_RELEVANCE_DEFAULT}) { |
| 146 elements.forEach((Element elem) { | 146 for (Element elem in elements) { |
| 147 if (elem is! ClassElement) { | 147 if (elem is! ClassElement) { |
| 148 if (optype.includeOnlyTypeNameSuggestions) { | 148 if (optype.includeOnlyTypeNameSuggestions) { |
| 149 return; | 149 return; |
| 150 } | 150 } |
| 151 if (elem is ExecutableElement) { | 151 if (elem is ExecutableElement) { |
| 152 DartType returnType = elem.returnType; | 152 DartType returnType = elem.returnType; |
| 153 if (returnType != null && returnType.isVoid) { | 153 if (returnType != null && returnType.isVoid) { |
| 154 if (!optype.includeVoidReturnSuggestions) { | 154 if (!optype.includeVoidReturnSuggestions) { |
| 155 return; | 155 return; |
| 156 } | 156 } |
| 157 } | 157 } |
| 158 } | 158 } |
| 159 } | 159 } |
| 160 addSuggestion(elem, relevance: relevance); | 160 addSuggestion(elem, relevance: relevance); |
| 161 }); | 161 }; |
| 162 } | 162 } |
| 163 | 163 |
| 164 /** | 164 /** |
| 165 * Add suggestions which start with the given text. | 165 * Add suggestions which start with the given text. |
| 166 */ | 166 */ |
| 167 _addFilteredSuggestions( | 167 _addFilteredSuggestions( |
| 168 String filterText, List<CompletionSuggestion> unfiltered) { | 168 String filterText, List<CompletionSuggestion> unfiltered) { |
| 169 //TODO (danrubel) Revisit this filtering once paged API has been added | 169 //TODO (danrubel) Revisit this filtering once paged API has been added |
| 170 unfiltered.forEach((CompletionSuggestion suggestion) { | 170 unfiltered.forEach((CompletionSuggestion suggestion) { |
| 171 if (filterText.length > 0) { | 171 if (filterText.length > 0) { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 _addFilteredSuggestions(filterText, cache.libraryPrefixSuggestions); | 253 _addFilteredSuggestions(filterText, cache.libraryPrefixSuggestions); |
| 254 } | 254 } |
| 255 if (optype.includeReturnValueSuggestions) { | 255 if (optype.includeReturnValueSuggestions) { |
| 256 _addFilteredSuggestions(filterText, cache.otherImportedSuggestions); | 256 _addFilteredSuggestions(filterText, cache.otherImportedSuggestions); |
| 257 } | 257 } |
| 258 if (optype.includeVoidReturnSuggestions) { | 258 if (optype.includeVoidReturnSuggestions) { |
| 259 _addFilteredSuggestions(filterText, cache.importedVoidReturnSuggestions); | 259 _addFilteredSuggestions(filterText, cache.importedVoidReturnSuggestions); |
| 260 } | 260 } |
| 261 } | 261 } |
| 262 } | 262 } |
| OLD | NEW |