| 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_server.dart' hide Element, ElementK
ind; |
| 10 ElementKind; | |
| 11 import 'package:analysis_server/src/protocol.dart' hide Element, ElementKind; | |
| 12 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; | 10 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; |
| 13 import 'package:analysis_server/src/services/completion/suggestion_builder.dart'
; | 11 import 'package:analysis_server/src/services/completion/suggestion_builder.dart'
; |
| 14 import 'package:analysis_server/src/services/search/search_engine.dart'; | 12 import 'package:analysis_server/src/services/search/search_engine.dart'; |
| 15 import 'package:analyzer/src/generated/ast.dart'; | 13 import 'package:analyzer/src/generated/ast.dart'; |
| 16 import 'package:analyzer/src/generated/element.dart'; | 14 import 'package:analyzer/src/generated/element.dart'; |
| 17 import 'package:analyzer/src/generated/resolver.dart'; | 15 import 'package:analyzer/src/generated/resolver.dart'; |
| 18 import 'package:analyzer/src/generated/source.dart'; | 16 import 'package:analyzer/src/generated/source.dart'; |
| 19 | 17 |
| 20 /** | 18 /** |
| 21 * A computer for calculating imported class and top level variable | 19 * A computer for calculating imported class and top level variable |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 _addElementSuggestion(element, CompletionRelevance.LOW); | 136 _addElementSuggestion(element, CompletionRelevance.LOW); |
| 139 } | 137 } |
| 140 } | 138 } |
| 141 }); | 139 }); |
| 142 return true; | 140 return true; |
| 143 }); | 141 }); |
| 144 } | 142 } |
| 145 | 143 |
| 146 void _addElementSuggestion(Element element, CompletionRelevance relevance) { | 144 void _addElementSuggestion(Element element, CompletionRelevance relevance) { |
| 147 CompletionSuggestionKind kind = | 145 CompletionSuggestionKind kind = |
| 148 new CompletionSuggestionKind.fromElementKind(element.kind); | 146 newCompletionSuggestionKind_fromElementKind(element.kind); |
| 149 | 147 |
| 150 String completion = element.displayName; | 148 String completion = element.displayName; |
| 151 CompletionSuggestion suggestion = new CompletionSuggestion( | 149 CompletionSuggestion suggestion = new CompletionSuggestion( |
| 152 kind, | 150 kind, |
| 153 relevance, | 151 relevance, |
| 154 completion, | 152 completion, |
| 155 completion.length, | 153 completion.length, |
| 156 0, | 154 0, |
| 157 element.isDeprecated, | 155 element.isDeprecated, |
| 158 false); | 156 false); |
| 159 | 157 |
| 160 suggestion.element = new protocol.Element.fromEngine(element); | 158 suggestion.element = newElement_fromEngine(element); |
| 161 | 159 |
| 162 DartType type; | 160 DartType type; |
| 163 if (element is FunctionElement) { | 161 if (element is FunctionElement) { |
| 164 type = element.returnType; | 162 type = element.returnType; |
| 165 } else if (element is PropertyAccessorElement && element.isGetter) { | 163 } else if (element is PropertyAccessorElement && element.isGetter) { |
| 166 type = element.returnType; | 164 type = element.returnType; |
| 167 } else if (element is TopLevelVariableElement) { | 165 } else if (element is TopLevelVariableElement) { |
| 168 type = element.type; | 166 type = element.type; |
| 169 } | 167 } |
| 170 if (type != null) { | 168 if (type != null) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 183 CompletionSuggestion suggestion = new CompletionSuggestion( | 181 CompletionSuggestion suggestion = new CompletionSuggestion( |
| 184 CompletionSuggestionKind.LIBRARY_PREFIX, | 182 CompletionSuggestionKind.LIBRARY_PREFIX, |
| 185 CompletionRelevance.DEFAULT, | 183 CompletionRelevance.DEFAULT, |
| 186 completion, | 184 completion, |
| 187 completion.length, | 185 completion.length, |
| 188 0, | 186 0, |
| 189 importElem.isDeprecated, | 187 importElem.isDeprecated, |
| 190 false); | 188 false); |
| 191 LibraryElement lib = importElem.importedLibrary; | 189 LibraryElement lib = importElem.importedLibrary; |
| 192 if (lib != null) { | 190 if (lib != null) { |
| 193 suggestion.element = new protocol.Element.fromEngine(lib); | 191 suggestion.element = newElement_fromEngine(lib); |
| 194 } | 192 } |
| 195 request.suggestions.add(suggestion); | 193 request.suggestions.add(suggestion); |
| 196 } | 194 } |
| 197 } | 195 } |
| 198 } | 196 } |
| OLD | NEW |