Skip to content

Commit 90efa35

Browse files
pqCommit Queue
authored andcommitted
[element model] migrate computer_documentation
Change-Id: I7ff0a47ea8b9fc325932d1a9c9f65dd8c65e2714 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/400000 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Phil Quitslund <[email protected]>
1 parent 487c595 commit 90efa35

File tree

8 files changed

+12
-37
lines changed

8 files changed

+12
-37
lines changed

pkg/analysis_server/analyzer_use_new_elements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ lib/plugin/protocol/protocol_dart.dart
22
lib/src/analysis_server.dart
33
lib/src/cider/rename.dart
44
lib/src/computer/computer_call_hierarchy.dart
5-
lib/src/computer/computer_documentation.dart
65
lib/src/domains/analysis/occurrences_dart.dart
76
lib/src/handler/legacy/edit_get_available_refactorings.dart
87
lib/src/handler/legacy/search_find_element_references.dart

pkg/analysis_server/lib/src/computer/computer_documentation.dart

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,16 @@
44

55
import 'package:analysis_server/src/computer/computer_overrides.dart';
66
import 'package:analysis_server/src/utilities/extensions/element.dart';
7-
import 'package:analyzer/dart/element/element.dart';
87
import 'package:analyzer/dart/element/element2.dart';
98
import 'package:analyzer/src/dartdoc/dartdoc_directive_info.dart';
10-
import 'package:analyzer/src/utilities/extensions/element.dart';
119

12-
/// Computes documentation for an [Element].
10+
/// Computes documentation for an [Element2].
1311
class DartDocumentationComputer {
1412
final DartdocDirectiveInfo dartdocInfo;
1513

1614
DartDocumentationComputer(this.dartdocInfo);
1715

1816
Documentation? compute(
19-
Element elementBeingDocumented, {
20-
bool includeSummary = false,
21-
}) {
22-
// TODO(dantup): Remove this temporary implementation used to split
23-
// migration of this class and callers into separate changes.
24-
var element2 = elementBeingDocumented.asElement2;
25-
26-
return element2 != null
27-
? compute2(element2, includeSummary: includeSummary)
28-
: null;
29-
}
30-
31-
Documentation? compute2(
3217
Element2 elementBeingDocumented, {
3318
bool includeSummary = false,
3419
}) {
@@ -96,26 +81,14 @@ class DartDocumentationComputer {
9681
/// Compute documentation for [element] and return either the summary or full
9782
/// docs (or `null`) depending on `preference`.
9883
String? computePreferred(
99-
Element element,
100-
DocumentationPreference preference,
101-
) {
102-
// TODO(dantup): Remove this temporary implementation used to split
103-
// migration of this class and callers into separate changes.
104-
var element2 = element.asElement2;
105-
return element2 != null ? computePreferred2(element2, preference) : null;
106-
}
107-
108-
/// Compute documentation for [element] and return either the summary or full
109-
/// docs (or `null`) depending on `preference`.
110-
String? computePreferred2(
11184
Element2 element,
11285
DocumentationPreference preference,
11386
) {
11487
if (preference == DocumentationPreference.none) {
11588
return null;
11689
}
11790

118-
var doc = compute2(
91+
var doc = compute(
11992
element,
12093
includeSummary: preference == DocumentationPreference.summary,
12194
);

pkg/analysis_server/lib/src/computer/computer_hover.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class DartUnitHoverComputer {
8181
hover.containingLibraryPath = libraryInfo?.libraryPath;
8282
}
8383
// documentation
84-
hover.dartdoc = _documentationComputer.computePreferred2(
84+
hover.dartdoc = _documentationComputer.computePreferred(
8585
element,
8686
documentationPreference,
8787
);

pkg/analysis_server/lib/src/computer/computer_signature.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class DartUnitSignatureComputer {
102102
}
103103
}
104104

105-
var dartdoc = _documentationComputer.computePreferred2(
105+
var dartdoc = _documentationComputer.computePreferred(
106106
element,
107107
documentationPreference,
108108
);

pkg/analysis_server/lib/src/computer/computer_type_arguments_signature.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class DartTypeArgumentsSignatureComputer {
5757
_argumentList = argumentList;
5858

5959
var label = element.displayString2();
60-
var documentation = _documentationComputer.computePreferred2(
60+
var documentation = _documentationComputer.computePreferred(
6161
element,
6262
documentationPreference,
6363
);

pkg/analysis_server/lib/src/lsp/completion_utils.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,8 +626,10 @@ _ElementDocumentation? _getDocsFromComputer(
626626
Element element,
627627
DartCompletionRequest request,
628628
) {
629+
var element2 = element.asElement2;
630+
if (element2 == null) return null;
629631
var doc = request.documentationComputer.compute(
630-
element,
632+
element2,
631633
includeSummary: true,
632634
);
633635
if (doc is DocumentationWithSummary) {

pkg/analysis_server/lib/src/lsp/handlers/handler_completion_resolve.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import 'package:analyzer/dart/analysis/results.dart';
1313
import 'package:analyzer/dart/analysis/session.dart';
1414
import 'package:analyzer/src/dart/element/element.dart';
1515
import 'package:analyzer/src/utilities/extensions/analysis_session.dart';
16+
import 'package:analyzer/src/utilities/extensions/element.dart';
1617
import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
1718

1819
class CompletionResolveHandler
@@ -130,7 +131,7 @@ class CompletionResolveHandler
130131
Either2<MarkupContent, String>? documentation;
131132
var element =
132133
elementLocation != null
133-
? await session.locateElement(elementLocation)
134+
? (await session.locateElement(elementLocation)).asElement2
134135
: null;
135136
if (element != null) {
136137
var formats = clientCapabilities.completionDocumentationFormats;

pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,7 +1576,7 @@ class SuggestionBuilder {
15761576

15771577
/// If the [element] has a documentation comment, return it.
15781578
_ElementDocumentation? _getDocumentation(Element2 element) {
1579-
var doc = request.documentationComputer.compute2(
1579+
var doc = request.documentationComputer.compute(
15801580
element,
15811581
includeSummary: true,
15821582
);
@@ -1642,7 +1642,7 @@ class SuggestionBuilder {
16421642
/// If the [element] has a documentation comment, fill the [suggestion]'s
16431643
/// documentation fields.
16441644
void _setDocumentation(CompletionSuggestion suggestion, Element2 element) {
1645-
var doc = request.documentationComputer.compute2(
1645+
var doc = request.documentationComputer.compute(
16461646
element,
16471647
includeSummary: true,
16481648
);

0 commit comments

Comments
 (0)