| 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.suggestion.builder; | 5 library services.completion.suggestion.builder; |
| 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' as protocol; | 10 import 'package:analysis_server/src/protocol_server.dart' as protocol; |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 | 387 |
| 388 /** | 388 /** |
| 389 * This class visits elements in a library and provides suggestions based upon | 389 * This class visits elements in a library and provides suggestions based upon |
| 390 * the visible members in that library. Clients should call | 390 * the visible members in that library. Clients should call |
| 391 * [LibraryElementSuggestionBuilder.suggestionsFor]. | 391 * [LibraryElementSuggestionBuilder.suggestionsFor]. |
| 392 */ | 392 */ |
| 393 class LibraryElementSuggestionBuilder extends GeneralizingElementVisitor | 393 class LibraryElementSuggestionBuilder extends GeneralizingElementVisitor |
| 394 with ElementSuggestionBuilder { | 394 with ElementSuggestionBuilder { |
| 395 final DartCompletionRequest request; | 395 final DartCompletionRequest request; |
| 396 final CompletionSuggestionKind kind; | 396 final CompletionSuggestionKind kind; |
| 397 final bool typesOnly; |
| 397 | 398 |
| 398 LibraryElementSuggestionBuilder(this.request, this.kind); | 399 LibraryElementSuggestionBuilder(this.request, this.kind, this.typesOnly); |
| 399 | 400 |
| 400 @override | 401 @override |
| 401 visitClassElement(ClassElement element) { | 402 visitClassElement(ClassElement element) { |
| 402 addSuggestion(element); | 403 addSuggestion(element); |
| 403 } | 404 } |
| 404 | 405 |
| 405 @override | 406 @override |
| 406 visitCompilationUnitElement(CompilationUnitElement element) { | 407 visitCompilationUnitElement(CompilationUnitElement element) { |
| 407 element.visitChildren(this); | 408 element.visitChildren(this); |
| 408 } | 409 } |
| 409 | 410 |
| 410 @override | 411 @override |
| 411 visitElement(Element element) { | 412 visitElement(Element element) { |
| 412 // ignored | 413 // ignored |
| 413 } | 414 } |
| 414 | 415 |
| 415 @override | 416 @override |
| 416 visitFunctionElement(FunctionElement element) { | 417 visitFunctionElement(FunctionElement element) { |
| 417 addSuggestion(element); | 418 if (!typesOnly) { |
| 419 addSuggestion(element); |
| 420 } |
| 418 } | 421 } |
| 419 | 422 |
| 420 @override | 423 @override |
| 421 visitFunctionTypeAliasElement(FunctionTypeAliasElement element) { | 424 visitFunctionTypeAliasElement(FunctionTypeAliasElement element) { |
| 422 addSuggestion(element); | 425 addSuggestion(element); |
| 423 } | 426 } |
| 424 | 427 |
| 425 @override | 428 @override |
| 426 visitTopLevelVariableElement(TopLevelVariableElement element) { | 429 visitTopLevelVariableElement(TopLevelVariableElement element) { |
| 427 addSuggestion(element); | 430 if (!typesOnly) { |
| 431 addSuggestion(element); |
| 432 } |
| 428 } | 433 } |
| 429 | 434 |
| 430 /** | 435 /** |
| 431 * Add suggestions for the visible members in the given library | 436 * Add suggestions for the visible members in the given library |
| 432 */ | 437 */ |
| 433 static void suggestionsFor(DartCompletionRequest request, | 438 static void suggestionsFor(DartCompletionRequest request, |
| 434 CompletionSuggestionKind kind, LibraryElement library) { | 439 CompletionSuggestionKind kind, LibraryElement library, bool typesOnly) { |
| 435 if (library != null) { | 440 if (library != null) { |
| 436 library.visitChildren(new LibraryElementSuggestionBuilder(request, kind)); | 441 library.visitChildren(new LibraryElementSuggestionBuilder(request, kind, t
ypesOnly)); |
| 437 } | 442 } |
| 438 } | 443 } |
| 439 } | 444 } |
| 440 | 445 |
| 441 /** | 446 /** |
| 442 * This class visits elements in a class and provides suggestions based upon | 447 * This class visits elements in a class and provides suggestions based upon |
| 443 * the visible named constructors in that class. | 448 * the visible named constructors in that class. |
| 444 */ | 449 */ |
| 445 class NamedConstructorSuggestionBuilder extends GeneralizingElementVisitor | 450 class NamedConstructorSuggestionBuilder extends GeneralizingElementVisitor |
| 446 with ElementSuggestionBuilder implements SuggestionBuilder { | 451 with ElementSuggestionBuilder implements SuggestionBuilder { |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 * or `false` if [computeFull] should be called. | 573 * or `false` if [computeFull] should be called. |
| 569 */ | 574 */ |
| 570 bool computeFast(AstNode node); | 575 bool computeFast(AstNode node); |
| 571 | 576 |
| 572 /** | 577 /** |
| 573 * Return a future that computes the suggestions given a fully resolved AST. | 578 * Return a future that computes the suggestions given a fully resolved AST. |
| 574 * The future returns `true` if suggestions were added, else `false`. | 579 * The future returns `true` if suggestions were added, else `false`. |
| 575 */ | 580 */ |
| 576 Future<bool> computeFull(AstNode node); | 581 Future<bool> computeFull(AstNode node); |
| 577 } | 582 } |
| OLD | NEW |