| 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; |
| 11 import 'package:analysis_server/src/protocol_server.dart' | 11 import 'package:analysis_server/src/protocol_server.dart' |
| 12 hide Element, ElementKind; | 12 hide Element, ElementKind; |
| 13 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; | 13 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; |
| 14 import 'package:analysis_server/src/utilities/documentation.dart'; | |
| 15 import 'package:analyzer/src/generated/ast.dart'; | 14 import 'package:analyzer/src/generated/ast.dart'; |
| 16 import 'package:analyzer/src/generated/element.dart'; | 15 import 'package:analyzer/src/generated/element.dart'; |
| 16 import 'package:analyzer/src/generated/utilities_dart.dart'; |
| 17 import 'package:analyzer/src/generated/source.dart'; | 17 import 'package:analyzer/src/generated/source.dart'; |
| 18 import 'package:analyzer/src/generated/utilities_dart.dart'; | |
| 19 import 'package:path/path.dart' as path; | 18 import 'package:path/path.dart' as path; |
| 20 | 19 |
| 21 const String DYNAMIC = 'dynamic'; | 20 const String DYNAMIC = 'dynamic'; |
| 22 | 21 |
| 23 /** | 22 /** |
| 24 * Return a suggestion based upon the given element | 23 * Return a suggestion based upon the given element |
| 25 * or `null` if a suggestion is not appropriate for the given element. | 24 * or `null` if a suggestion is not appropriate for the given element. |
| 26 * If the suggestion is not currently in scope, then specify | 25 * If the suggestion is not currently in scope, then specify |
| 27 * importForSource as the source to which an import should be added. | 26 * importForSource as the source to which an import should be added. |
| 28 */ | 27 */ |
| (...skipping 11 matching lines...) Expand all Loading... |
| 40 } | 39 } |
| 41 bool isDeprecated = element.isDeprecated; | 40 bool isDeprecated = element.isDeprecated; |
| 42 CompletionSuggestion suggestion = new CompletionSuggestion( | 41 CompletionSuggestion suggestion = new CompletionSuggestion( |
| 43 kind, | 42 kind, |
| 44 isDeprecated ? DART_RELEVANCE_LOW : relevance, | 43 isDeprecated ? DART_RELEVANCE_LOW : relevance, |
| 45 completion, | 44 completion, |
| 46 completion.length, | 45 completion.length, |
| 47 0, | 46 0, |
| 48 isDeprecated, | 47 isDeprecated, |
| 49 false); | 48 false); |
| 50 { | |
| 51 String doc = element.computeDocumentationComment(); | |
| 52 doc = removeDartDocDelimiters(doc); | |
| 53 suggestion.docComplete = doc; | |
| 54 suggestion.docSummary = getDartDocSummary(doc); | |
| 55 } | |
| 56 suggestion.element = protocol.newElement_fromEngine(element); | 49 suggestion.element = protocol.newElement_fromEngine(element); |
| 57 Element enclosingElement = element.enclosingElement; | 50 Element enclosingElement = element.enclosingElement; |
| 58 if (enclosingElement is ClassElement) { | 51 if (enclosingElement is ClassElement) { |
| 59 suggestion.declaringType = enclosingElement.displayName; | 52 suggestion.declaringType = enclosingElement.displayName; |
| 60 } | 53 } |
| 61 suggestion.returnType = getReturnTypeString(element); | 54 suggestion.returnType = getReturnTypeString(element); |
| 62 if (element is ExecutableElement && element is! PropertyAccessorElement) { | 55 if (element is ExecutableElement && element is! PropertyAccessorElement) { |
| 63 suggestion.parameterNames = element.parameters | 56 suggestion.parameterNames = element.parameters |
| 64 .map((ParameterElement parameter) => parameter.name) | 57 .map((ParameterElement parameter) => parameter.name) |
| 65 .toList(); | 58 .toList(); |
| (...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 * or `false` if [computeFull] should be called. | 668 * or `false` if [computeFull] should be called. |
| 676 */ | 669 */ |
| 677 bool computeFast(AstNode node); | 670 bool computeFast(AstNode node); |
| 678 | 671 |
| 679 /** | 672 /** |
| 680 * Return a future that computes the suggestions given a fully resolved AST. | 673 * Return a future that computes the suggestions given a fully resolved AST. |
| 681 * The future returns `true` if suggestions were added, else `false`. | 674 * The future returns `true` if suggestions were added, else `false`. |
| 682 */ | 675 */ |
| 683 Future<bool> computeFull(AstNode node); | 676 Future<bool> computeFull(AstNode node); |
| 684 } | 677 } |
| OLD | NEW |