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