diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-03-24 23:28:57 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-03-24 23:28:57 +0000 |
commit | 6ad1a0711631d8017791a6dfe85bbe205d6c7414 (patch) | |
tree | ce2d6448ff8770c8fe73086eefb85dab38d298d8 /docs/user | |
parent | fae627174aecae0b4f4d2c087a856eda1a97a1ac (diff) | |
parent | 7b35da04bf56a5461321a6dca515dcd29f44b57f (diff) |
Merge #3710
3710: Inlay hints for method chaining pattern r=matklad a=M-J-Hooper
This PR adds inlay hints on method call chains:
![image](https://user-images.githubusercontent.com/13765376/77472008-8dc2a880-6e13-11ea-9c18-2c2e2b809799.png)
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 <[email protected]>
Diffstat (limited to 'docs/user')
-rw-r--r-- | docs/user/features.md | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/docs/user/features.md b/docs/user/features.md index 45360c633..56d2969fd 100644 --- a/docs/user/features.md +++ b/docs/user/features.md | |||
@@ -185,6 +185,7 @@ These contain extended information on the hovered language item. | |||
185 | Two types of inlay hints are displayed currently: | 185 | Two types of inlay hints are displayed currently: |
186 | 186 | ||
187 | * type hints, displaying the minimal information on the type of the expression (if the information is available) | 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 | * parameter name hints, displaying the names of the parameters in the corresponding methods | 189 | * parameter name hints, displaying the names of the parameters in the corresponding methods |
189 | 190 | ||
190 | #### VS Code | 191 | #### VS Code |
@@ -192,6 +193,7 @@ Two types of inlay hints are displayed currently: | |||
192 | In VS Code, the following settings can be used to configure the inlay hints: | 193 | In VS Code, the following settings can be used to configure the inlay hints: |
193 | 194 | ||
194 | * `rust-analyzer.inlayHints.typeHints` - enable hints for inferred types. | 195 | * `rust-analyzer.inlayHints.typeHints` - enable hints for inferred types. |
196 | * `rust-analyzer.inlayHints.chainingHints` - enable hints for inferred types on method chains. | ||
195 | * `rust-analyzer.inlayHints.parameterHints` - enable hints for function parameters. | 197 | * `rust-analyzer.inlayHints.parameterHints` - enable hints for function parameters. |
196 | * `rust-analyzer.inlayHints.maxLength` — shortens the hints if their length exceeds the value specified. If no value is specified (`null`), no shortening is applied. | 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. |
197 | 199 | ||