Skip to content

Commit 1d4ebf7

Browse files
FMorschelCommit Queue
authored and
Commit Queue
committed
[DAS] Fixes extension and typedef dart docs
[email protected] Bug: #59724 Change-Id: I9a4a7390e71b1e1fd2daa0f3e548f28cd34834cf Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/411380 Reviewed-by: Samuel Rawlins <[email protected]> Auto-Submit: Felipe Morschel <[email protected]> Reviewed-by: Phil Quitslund <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]>
1 parent 6f1fe1a commit 1d4ebf7

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,11 @@ class InScopeCompletionPass extends SimpleAstVisitor<void> {
677677
}
678678
}
679679

680+
@override
681+
void visitComment(Comment node) {
682+
node.visitChildren(this);
683+
}
684+
680685
@override
681686
void visitCommentReference(CommentReference node) {
682687
collector.completionLocation = 'CommentReference_identifier';
@@ -1128,6 +1133,8 @@ class InScopeCompletionPass extends SimpleAstVisitor<void> {
11281133
if (offset == node.offset) {
11291134
_forCompilationUnitMemberBefore(node);
11301135
return;
1136+
} else if (node.documentationComment.coversOffset(offset)) {
1137+
return node.documentationComment?.accept(this);
11311138
} else if (offset < node.extensionKeyword.offset) {
11321139
// There are no modifiers for extensions.
11331140
return;
@@ -1519,6 +1526,8 @@ class InScopeCompletionPass extends SimpleAstVisitor<void> {
15191526
} else if (offset >= node.equals.end && offset <= node.semicolon.offset) {
15201527
collector.completionLocation = 'GenericTypeAlias_type';
15211528
_forTypeAnnotation(node);
1529+
} else if (node.documentationComment.coversOffset(offset)) {
1530+
node.documentationComment?.accept(this);
15221531
}
15231532
}
15241533

pkg/analysis_server/test/services/completion/dart/location/dart_doc_test.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ suggestions
6161
''');
6262
}
6363

64-
@FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/59724')
6564
Future<void> test_extension() async {
6665
allowedIdentifiers = const {'MyExt'};
6766
await computeSuggestions('''
@@ -73,7 +72,7 @@ replacement
7372
left: 3
7473
suggestions
7574
MyExt
76-
kind: extension
75+
kind: extensionInvocation
7776
''');
7877
}
7978

@@ -304,7 +303,6 @@ suggestions
304303
''');
305304
}
306305

307-
@FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/59724')
308306
Future<void> test_typedef() async {
309307
allowedIdentifiers = const {'MyTypedef'};
310308
await computeSuggestions('''
@@ -316,7 +314,7 @@ replacement
316314
left: 3
317315
suggestions
318316
MyTypedef
319-
kind: typedef
317+
kind: typeAlias
320318
''');
321319
}
322320

pkg/analyzer_plugin/lib/src/utilities/completion/completion_target.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,13 @@ class CompletionTarget {
512512
containingNode.parent.ifTypeOrNull() ??
513513
// SimpleString -> Configuration -> Directive
514514
containingNode.parent?.parent.ifTypeOrNull();
515+
} else if (containingNode is Comment) {
516+
for (var reference in containingNode.references) {
517+
if (reference.offset <= requestOffset &&
518+
reference.end >= requestOffset) {
519+
return SourceRange(reference.offset, reference.length);
520+
}
521+
}
515522
}
516523
// Replacement range for a URI.
517524
if (directive != null && uri is SimpleStringLiteral) {

0 commit comments

Comments
 (0)