commit | b0ac65ab01a853dd31da5632b551e3ef4a0535fe | [log] [tgz] |
---|---|---|
author | Danny Tuppeny <danny@tuppeny.com> | Fri Sep 16 18:53:20 2022 +0000 |
committer | Commit Bot <commit-bot@chromium.org> | Fri Sep 16 18:53:20 2022 +0000 |
tree | 87cdbd7240a22d165a38b413dba4a4d5ea7fe56d | |
parent | e5f3b0dc0e86cab0ce43634b027e14ff9c3d77a6 [diff] |
[analysis_server] Don't show return type Inlay Hints on setters Change-Id: I3f1d63cf0d71c1028ee3cbf3b780edcefb561aac Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/259588 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/analysis_server/lib/src/computer/computer_inlay_hint.dart b/pkg/analysis_server/lib/src/computer/computer_inlay_hint.dart index bdbbed5..4c13095 100644 --- a/pkg/analysis_server/lib/src/computer/computer_inlay_hint.dart +++ b/pkg/analysis_server/lib/src/computer/computer_inlay_hint.dart
@@ -96,6 +96,11 @@ return; } + // Don't add "void" for setters. + if (node.isSetter) { + return; + } + final declaration = node.declaredElement2; if (declaration != null) { // For getters/setters, the type must come before the property keyword,
diff --git a/pkg/analysis_server/test/lsp/inlay_hint_test.dart b/pkg/analysis_server/test/lsp/inlay_hint_test.dart index 641f95e..634ca9a 100644 --- a/pkg/analysis_server/test/lsp/inlay_hint_test.dart +++ b/pkg/analysis_server/test/lsp/inlay_hint_test.dart
@@ -250,8 +250,9 @@ final content = ''' set f(int i) {} '''; + // Setters are always `void` so we don't show a label there. final expected = ''' -(Type:void) set f(int i) {} +set f(int i) {} '''; await _testHints(content, expected); }