Skip to content

Commit b668fc8

Browse files
FMorschelCommit Queue
authored andcommitted
[DAS] Fixes hover for try/catch error/stack
Fixes: #55907 Change-Id: I385483eaf5cba4fbac10b402cdb87ace51e9b020 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/456400 Commit-Queue: Samuel Rawlins <[email protected]> Auto-Submit: Felipe Morschel <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]> Reviewed-by: Samuel Rawlins <[email protected]>
1 parent 784024a commit b668fc8

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class DartUnitHoverComputer {
4646
}
4747

4848
if (node is CompilationUnitMember ||
49+
node is CatchClauseParameter ||
4950
node is Expression ||
5051
node is FormalParameter ||
5152
node is MethodDeclaration ||
@@ -188,6 +189,7 @@ class DartUnitHoverComputer {
188189
/// Returns `null` if there is no valid entity for this hover.
189190
SyntacticEntity? _locationEntity(AstNode node) {
190191
return switch (node) {
192+
CatchClauseParameter() => node.name,
191193
NamedCompilationUnitMember() => node.name,
192194
Expression() => node,
193195
ExtensionDeclaration() => node.name,

pkg/analysis_server/test/lsp/hover_test.dart

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,6 +1244,34 @@ Declared in _package:test/main.dart_.''';
12441244
await assertStringContents(content, equals(expected));
12451245
}
12461246

1247+
Future<void> test_tryCatch_error() async {
1248+
var content = '''
1249+
void foo() {
1250+
try {} on Exception catch ([!err^or!], stack) {}
1251+
}
1252+
''';
1253+
var expected = '''
1254+
```dart
1255+
Exception error
1256+
```
1257+
Type: `Exception`''';
1258+
await assertStringContents(content, equals(expected));
1259+
}
1260+
1261+
Future<void> test_tryCatch_stack() async {
1262+
var content = '''
1263+
void foo() {
1264+
try {} on Exception catch (error, [!stac^k!]) {}
1265+
}
1266+
''';
1267+
var expected = '''
1268+
```dart
1269+
StackTrace stack
1270+
```
1271+
Type: `StackTrace`''';
1272+
await assertStringContents(content, equals(expected));
1273+
}
1274+
12471275
Future<void> test_typeParameter() async {
12481276
var content = '''
12491277
class C<[!^T!]> {}

0 commit comments

Comments
 (0)