-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add inlay hints for function parameters (#6513)
## Description Inlay hints are now displayed in function parameter locations if a variable with the same name is not present. This should be identical to the behaviour of rust-analyzer. The inlay_hints benchmark is slower because we are now also calculating inlay hints for function_params and variable decls in the same iteration. See screen shot below for all supported types. ![Screenshot 2024-09-21 at 10 47 12 AM](https://github.com/user-attachments/assets/c3aaa901-e01d-4e88-a405-f1077d2d2dce) closes #5196 ## Checklist - [x] I have linked to any relevant issues. - [x] I have commented my code, particularly in hard-to-understand areas. - [x] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [x] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [x] I have added tests that prove my fix is effective or that my feature works. - [x] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [x] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [x] I have requested a review from the relevant team or maintainers.
- Loading branch information
1 parent
e1546f6
commit 99f11c0
Showing
7 changed files
with
302 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
out | ||
target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[project] | ||
authors = ["Fuel Labs <[email protected]>"] | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
name = "inlay_hints" | ||
implicit-std = false | ||
|
||
[dependencies] | ||
std = { git = "https://github.com/FuelLabs/sway", tag = "v0.63.5" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
script; | ||
|
||
const CONSTANT: u64 = 42; | ||
|
||
enum MyEnum { | ||
A: u64, | ||
} | ||
struct MyStruct { | ||
a: u64, | ||
} | ||
fn my_function(foo: u64, bar: u64, long_argument_name: u64) -> u64 { | ||
foo + bar + long_argument_name | ||
} | ||
fn identity<T>(x: T) -> T { | ||
x | ||
} | ||
fn two_generics<A, B>(_a: A, b: B) -> B { | ||
b | ||
} | ||
fn three_generics<A, B, C>(a: A, b: B, _c: C) -> B { | ||
let _a: A = a; | ||
b | ||
} | ||
|
||
fn main() { | ||
let _x = my_function(1, 2, 3); | ||
let foo = 1; | ||
let _y = my_function(foo, 2, 3); | ||
let bar = 2; | ||
let _function_call = identity(my_function(1, bar, 3)); | ||
let _z = my_function(foo, bar, 3); | ||
let long_argument_name = 3; | ||
let _w = my_function(foo, bar, long_argument_name); | ||
let _a: bool = identity(true); | ||
let _b: u32 = identity(10u32); | ||
let _c: u64 = identity(42); | ||
let _e: str = identity("foo"); | ||
let _f: u64 = two_generics(true, 10); | ||
let _g: str = three_generics(true, "foo", 10); | ||
let _const = identity(CONSTANT); | ||
let _tuple = identity((1, 2, 3)); | ||
let _array = identity([1, 2, 3]); | ||
let _enum = identity(MyEnum::A(1)); | ||
let s = MyStruct { a: 1 }; | ||
let _struct_field_access = identity(s.a); | ||
let t = (0, 1, 9); | ||
let _tuple_elem_access = identity(t.2); | ||
let a = [1, 2, 3]; | ||
let _array_index = identity(a[1]); | ||
} | ||
|
Oops, something went wrong.