You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
3710: Inlay hints for method chaining pattern r=matklad a=M-J-Hooper
This PR adds inlay hints on method call chains:

It is not only explicit `MethodCall`s where this can be helpful. The heuristic used here is that whenever any expression is followed by a new line and then a dot, it resembles a call chain and type information can be #useful.
Changes:
- A new `InlayKind` for chaining.
- New option for disabling this type of hints.
- Tree traversal rules for identifying the chaining hints.
- VSCode decorators in the extension layer (and associated types).
Notes:
- IntelliJ has additional rules and configuration on this topic. Eg. minimum length of chain to start displaying hints and only displaying distinct types in the chain.
- I am checking for chaining on every `ast::Expr` in the tree; Are there performance concerns there?
This is my first contribution (to RA and to Rust in general) so would appreciate any feedback.
The only issue I can find the references this feature is #2741.
Co-authored-by: Matt Hooper <matthewjhooper94@gmail.com>
Copy file name to clipboardExpand all lines: docs/user/features.md
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -185,13 +185,15 @@ These contain extended information on the hovered language item.
185
185
Two types of inlay hints are displayed currently:
186
186
187
187
* type hints, displaying the minimal information on the type of the expression (if the information is available)
188
+
* method chaining hints, type information for multi-line method chains
188
189
* parameter name hints, displaying the names of the parameters in the corresponding methods
189
190
190
191
#### VS Code
191
192
192
193
In VS Code, the following settings can be used to configure the inlay hints:
193
194
194
195
*`rust-analyzer.inlayHints.typeHints` - enable hints for inferred types.
196
+
*`rust-analyzer.inlayHints.chainingHints` - enable hints for inferred types on method chains.
195
197
*`rust-analyzer.inlayHints.parameterHints` - enable hints for function parameters.
196
198
*`rust-analyzer.inlayHints.maxLength` — shortens the hints if their length exceeds the value specified. If no value is specified (`null`), no shortening is applied.
0 commit comments