Skip to content

Commit 840729a

Browse files
halildurmusCommit Queue
authored and
Commit Queue
committed
[analysis_server] Show library documentation when hovering over unnamed
library directives Closes: #53476 Change-Id: I33a8e0ebd3ed7999eba71985fabb90c17444bde6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/380520 Commit-Queue: Konstantin Shcheglov <[email protected]> Commit-Queue: Brian Wilkerson <[email protected]> Reviewed-by: Konstantin Shcheglov <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 9d61a35 commit 840729a

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ class DartUnitHoverComputer {
5656
node is VariableDeclaration ||
5757
node is VariablePattern ||
5858
node is PatternFieldName ||
59-
node is DartPattern) {
59+
node is DartPattern ||
60+
(node is LibraryDirective && node.name2 == null)) {
6061
var range = _hoverRange(node, locationEntity);
6162
var hover = HoverInformation(range.offset, range.length);
6263
// element
@@ -196,6 +197,7 @@ class DartUnitHoverComputer {
196197
VariablePattern() => node.name,
197198
PatternFieldName() => node.name,
198199
WildcardPattern() => node.name,
200+
LibraryDirective() => node.libraryKeyword,
199201
_ => null,
200202
};
201203
}

pkg/analysis_server/test/lsp/hover_test.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,22 @@ Type: `String?`
802802
803803
*package:test/main.dart*
804804
805+
---
806+
This is a string.''';
807+
await assertStringContents(content, equals(expected));
808+
}
809+
810+
Future<void> test_unnamed_library_directive() async {
811+
var content = '''
812+
/// This is a string.
813+
[!lib^rary!];
814+
''';
815+
var expected = '''
816+
```dart
817+
library package:test/main.dart
818+
```
819+
*package:test/main.dart*
820+
805821
---
806822
This is a string.''';
807823
await assertStringContents(content, equals(expected));

0 commit comments

Comments
 (0)