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.contributor.dart.invocation; | 5 library services.completion.contributor.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/local_declaration_visito
r.dart'; | 10 import 'package:analysis_server/src/services/completion/local_declaration_visito
r.dart'; |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 } | 310 } |
311 | 311 |
312 @override | 312 @override |
313 Future<bool> visitElement(Element element) { | 313 Future<bool> visitElement(Element element) { |
314 return new Future.value(false); | 314 return new Future.value(false); |
315 } | 315 } |
316 | 316 |
317 @override | 317 @override |
318 Future<bool> visitPrefixElement(PrefixElement element) { | 318 Future<bool> visitPrefixElement(PrefixElement element) { |
319 bool modified = false; | 319 bool modified = false; |
| 320 |
| 321 // Suggested by LibraryMemberContributor |
| 322 |
320 // Find the import directive with the given prefix | 323 // Find the import directive with the given prefix |
321 for (Directive directive in request.unit.directives) { | 324 // for (Directive directive in request.unit.directives) { |
322 if (directive is ImportDirective) { | 325 // if (directive is ImportDirective) { |
323 if (directive.prefix != null) { | 326 // if (directive.prefix != null) { |
324 if (directive.prefix.name == element.name) { | 327 // if (directive.prefix.name == element.name) { |
325 // Suggest elements from the imported library | 328 // // Suggest elements from the imported library |
326 LibraryElement library = directive.uriElement; | 329 // LibraryElement library = directive.uriElement; |
327 AstNode node = request.target.containingNode; | 330 // AstNode node = request.target.containingNode; |
328 bool typesOnly = node.parent is TypeName; | 331 // bool typesOnly = node.parent is TypeName; |
329 bool instCreation = | 332 // bool instCreation = |
330 typesOnly && node.parent.parent is ConstructorName; | 333 // typesOnly && node.parent.parent is ConstructorName; |
331 LibraryElementSuggestionBuilder.suggestionsFor( | 334 // LibraryElementSuggestionBuilder.suggestionsFor( |
332 request, | 335 // request, |
333 CompletionSuggestionKind.INVOCATION, | 336 // CompletionSuggestionKind.INVOCATION, |
334 library, | 337 // library, |
335 typesOnly, | 338 // typesOnly, |
336 instCreation); | 339 // instCreation); |
337 modified = true; | 340 // modified = true; |
338 if (directive.deferredKeyword != null) { | 341 // if (directive.deferredKeyword != null) { |
339 FunctionElement loadLibFunct = library.loadLibraryFunction; | 342 // FunctionElement loadLibFunct = library.loadLibraryFunction; |
340 request.addSuggestion(createSuggestion(loadLibFunct)); | 343 // request.addSuggestion(createSuggestion(loadLibFunct)); |
341 } | 344 // } |
342 } | 345 // } |
343 } | 346 // } |
344 } | 347 // } |
345 } | 348 // } |
346 return new Future.value(modified); | 349 return new Future.value(modified); |
347 } | 350 } |
348 | 351 |
349 @override | 352 @override |
350 Future<bool> visitPropertyAccessorElement(PropertyAccessorElement element) { | 353 Future<bool> visitPropertyAccessorElement(PropertyAccessorElement element) { |
351 if (element != null) { | 354 if (element != null) { |
352 PropertyInducingElement elemVar = element.variable; | 355 PropertyInducingElement elemVar = element.variable; |
353 if (elemVar != null) { | 356 if (elemVar != null) { |
354 InterfaceTypeSuggestionBuilder.suggestionsFor(request, elemVar.type); | 357 InterfaceTypeSuggestionBuilder.suggestionsFor(request, elemVar.type); |
355 } | 358 } |
356 return new Future.value(true); | 359 return new Future.value(true); |
357 } | 360 } |
358 return new Future.value(false); | 361 return new Future.value(false); |
359 } | 362 } |
360 | 363 |
361 @override | 364 @override |
362 Future<bool> visitVariableElement(VariableElement element) { | 365 Future<bool> visitVariableElement(VariableElement element) { |
363 InterfaceTypeSuggestionBuilder.suggestionsFor(request, element.type); | 366 InterfaceTypeSuggestionBuilder.suggestionsFor(request, element.type); |
364 return new Future.value(true); | 367 return new Future.value(true); |
365 } | 368 } |
366 } | 369 } |
OLD | NEW |