| 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.invocation; | 5 library services.completion.computer.dart.invocation; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; | 9 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; |
| 10 import 'package:analysis_server/src/services/completion/suggestion_builder.dart'
; | 10 import 'package:analysis_server/src/services/completion/suggestion_builder.dart'
; |
| 11 import 'package:analyzer/src/generated/ast.dart'; | 11 import 'package:analyzer/src/generated/ast.dart'; |
| 12 import 'package:analyzer/src/generated/element.dart'; | 12 import 'package:analyzer/src/generated/element.dart'; |
| 13 import 'package:analyzer/src/generated/scanner.dart'; | 13 import 'package:analyzer/src/generated/scanner.dart'; |
| 14 | 14 |
| 15 import '../../protocol_server.dart' show CompletionSuggestionKind; |
| 16 |
| 15 /** | 17 /** |
| 16 * A computer for calculating invocation / access suggestions | 18 * A computer for calculating invocation / access suggestions |
| 17 * `completion.getSuggestions` request results. | 19 * `completion.getSuggestions` request results. |
| 18 */ | 20 */ |
| 19 class InvocationComputer extends DartCompletionComputer { | 21 class InvocationComputer extends DartCompletionComputer { |
| 20 | 22 |
| 21 @override | 23 @override |
| 22 bool computeFast(DartCompletionRequest request) { | 24 bool computeFast(DartCompletionRequest request) { |
| 23 // TODO: implement computeFast | 25 // TODO: implement computeFast |
| 24 return false; | 26 return false; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 { | 135 { |
| 134 final DartCompletionRequest request; | 136 final DartCompletionRequest request; |
| 135 | 137 |
| 136 _InvocationElementVisitor(this.request); | 138 _InvocationElementVisitor(this.request); |
| 137 | 139 |
| 138 @override | 140 @override |
| 139 Future<bool> visitClassElement(ClassElement element) { | 141 Future<bool> visitClassElement(ClassElement element) { |
| 140 if (element != null) { | 142 if (element != null) { |
| 141 InterfaceType type = element.type; | 143 InterfaceType type = element.type; |
| 142 if (type != null) { | 144 if (type != null) { |
| 143 ClassElementSuggestionBuilder.staticSuggestionsFor(request, type.element
); | 145 ClassElementSuggestionBuilder.suggestionsFor( |
| 146 request, |
| 147 type.element, |
| 148 staticOnly: true); |
| 144 } | 149 } |
| 145 } | 150 } |
| 146 return new Future.value(false); | 151 return new Future.value(false); |
| 147 } | 152 } |
| 148 | 153 |
| 149 @override | 154 @override |
| 150 Future<bool> visitElement(Element element) { | 155 Future<bool> visitElement(Element element) { |
| 151 return new Future.value(false); | 156 return new Future.value(false); |
| 152 } | 157 } |
| 153 | 158 |
| 154 @override | 159 @override |
| 155 Future<bool> visitPrefixElement(PrefixElement element) { | 160 Future<bool> visitPrefixElement(PrefixElement element) { |
| 156 //TODO (danrubel) reimplement to use prefixElement.importedLibraries | 161 //TODO (danrubel) reimplement to use prefixElement.importedLibraries |
| 157 // once that accessor is implemented and available in Dart | 162 // once that accessor is implemented and available in Dart |
| 158 bool modified = false; | 163 bool modified = false; |
| 159 // Find the import directive with the given prefix | 164 // Find the import directive with the given prefix |
| 160 request.unit.directives.forEach((Directive directive) { | 165 request.unit.directives.forEach((Directive directive) { |
| 161 if (directive is ImportDirective) { | 166 if (directive is ImportDirective) { |
| 162 if (directive.prefix != null) { | 167 if (directive.prefix != null) { |
| 163 if (directive.prefix.name == element.name) { | 168 if (directive.prefix.name == element.name) { |
| 164 // Suggest elements from the imported library | 169 // Suggest elements from the imported library |
| 165 LibraryElement library = directive.uriElement; | 170 LibraryElement library = directive.uriElement; |
| 166 LibraryElementSuggestionBuilder.suggestionsFor(request, library); | 171 LibraryElementSuggestionBuilder.suggestionsFor( |
| 172 request, |
| 173 CompletionSuggestionKind.INVOCATION, |
| 174 library); |
| 167 modified = true; | 175 modified = true; |
| 168 } | 176 } |
| 169 } | 177 } |
| 170 } | 178 } |
| 171 }); | 179 }); |
| 172 return new Future.value(modified); | 180 return new Future.value(modified); |
| 173 } | 181 } |
| 174 | 182 |
| 175 @override | 183 @override |
| 176 Future<bool> visitPropertyAccessorElement(PropertyAccessorElement element) { | 184 Future<bool> visitPropertyAccessorElement(PropertyAccessorElement element) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 189 | 197 |
| 190 @override | 198 @override |
| 191 Future<bool> visitVariableElement(VariableElement element) { | 199 Future<bool> visitVariableElement(VariableElement element) { |
| 192 DartType type = element.type; | 200 DartType type = element.type; |
| 193 if (type != null) { | 201 if (type != null) { |
| 194 ClassElementSuggestionBuilder.suggestionsFor(request, type.element); | 202 ClassElementSuggestionBuilder.suggestionsFor(request, type.element); |
| 195 } | 203 } |
| 196 return new Future.value(true); | 204 return new Future.value(true); |
| 197 } | 205 } |
| 198 } | 206 } |
| OLD | NEW |