aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/rust-analyzer-api.ts
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-03-24 23:28:57 +0000
committerGitHub <[email protected]>2020-03-24 23:28:57 +0000
commit6ad1a0711631d8017791a6dfe85bbe205d6c7414 (patch)
treece2d6448ff8770c8fe73086eefb85dab38d298d8 /editors/code/src/rust-analyzer-api.ts
parentfae627174aecae0b4f4d2c087a856eda1a97a1ac (diff)
parent7b35da04bf56a5461321a6dca515dcd29f44b57f (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 'editors/code/src/rust-analyzer-api.ts')
-rw-r--r--editors/code/src/rust-analyzer-api.ts4
1 files changed, 3 insertions, 1 deletions
diff --git a/editors/code/src/rust-analyzer-api.ts b/editors/code/src/rust-analyzer-api.ts
index 9846f7343..400ac3714 100644
--- a/editors/code/src/rust-analyzer-api.ts
+++ b/editors/code/src/rust-analyzer-api.ts
@@ -86,12 +86,13 @@ export interface Runnable {
86} 86}
87export const runnables = request<RunnablesParams, Vec<Runnable>>("runnables"); 87export const runnables = request<RunnablesParams, Vec<Runnable>>("runnables");
88 88
89export type InlayHint = InlayHint.TypeHint | InlayHint.ParamHint; 89export type InlayHint = InlayHint.TypeHint | InlayHint.ParamHint | InlayHint.ChainingHint;
90 90
91export namespace InlayHint { 91export namespace InlayHint {
92 export const enum Kind { 92 export const enum Kind {
93 TypeHint = "TypeHint", 93 TypeHint = "TypeHint",
94 ParamHint = "ParameterHint", 94 ParamHint = "ParameterHint",
95 ChainingHint = "ChainingHint",
95 } 96 }
96 interface Common { 97 interface Common {
97 range: lc.Range; 98 range: lc.Range;
@@ -99,6 +100,7 @@ export namespace InlayHint {
99 } 100 }
100 export type TypeHint = Common & { kind: Kind.TypeHint }; 101 export type TypeHint = Common & { kind: Kind.TypeHint };
101 export type ParamHint = Common & { kind: Kind.ParamHint }; 102 export type ParamHint = Common & { kind: Kind.ParamHint };
103 export type ChainingHint = Common & { kind: Kind.ChainingHint };
102} 104}
103export interface InlayHintsParams { 105export interface InlayHintsParams {
104 textDocument: lc.TextDocumentIdentifier; 106 textDocument: lc.TextDocumentIdentifier;