Skip to content

Commit ec8864f

Browse files
DanTupCommit Queue
authored andcommitted
[analysis_server] Combine the containing class + library into a single line in LSP hovers
Change-Id: I21a285eddcf855cf0ebfd59e6d6178ee6bfa1c59 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433481 Auto-Submit: Danny Tuppeny <[email protected]> Commit-Queue: Kallen Tu <[email protected]> Reviewed-by: Kallen Tu <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent f4e6182 commit ec8864f

File tree

4 files changed

+97
-81
lines changed

4 files changed

+97
-81
lines changed

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,23 @@ class HoverHandler
8787
..writeln();
8888
}
8989

90-
var containingClassDescription = hover.containingClassDescription;
91-
if (containingClassDescription != null &&
92-
containingClassDescription.isNotEmpty) {
93-
content
94-
..writeln('Declared in: `$containingClassDescription`')
95-
..writeln();
90+
var declaredInDescription = StringBuffer();
91+
if (hover.containingClassDescription?.isNotEmpty ?? false) {
92+
declaredInDescription
93+
..write(' in `')
94+
..write(hover.containingClassDescription)
95+
..write('`');
96+
}
97+
if (hover.containingLibraryName?.isNotEmpty ?? false) {
98+
declaredInDescription
99+
..write(' in _')
100+
..write(hover.containingLibraryName)
101+
..write('_');
96102
}
97103

98-
// Source library.
99-
var containingLibraryName = hover.containingLibraryName;
100-
if (containingLibraryName != null && containingLibraryName.isNotEmpty) {
104+
if (declaredInDescription.isNotEmpty) {
101105
content
102-
..writeln('*$containingLibraryName*')
106+
..writeln('Declared$declaredInDescription.')
103107
..writeln();
104108
}
105109

pkg/analysis_server/test/integration/lsp/handle_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class [!A^aa!] {}
9494
```dart
9595
class Aaa
9696
```
97-
*package:test/main.dart*
97+
Declared in _package:test/main.dart_.
9898
9999
---
100100
This is my class.
@@ -116,7 +116,7 @@ class [!A^aa!] {}
116116
```dart
117117
class Aaa
118118
```
119-
*package:test/main.dart*
119+
Declared in _package:test/main.dart_.
120120
121121
---
122122
This is my class.''';

0 commit comments

Comments
 (0)