Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parameter inlay hint separate from variable type inlay? #2876 #3543
Parameter inlay hint separate from variable type inlay? #2876 #3543
Changes from 2 commits
e98aff1
cfb48df
974ed71
58248e2
a153b90
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#2741 have plans to add more various inlay hint types later.
I think we'd better allow to have various combinations of the types turned on simultaneously, since there will be requests for those.
So should we go with a set of
InlayKind
's instead of this enum?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bitset I guess?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imo, just the
HashSet<InlayKind>
is enough.Or its
fx
counterpart, since we useFxHashMap
in the project.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recall @matklad once said it's better not to use HashSet where Vec is enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still a bit of a beginner with rust, but @matklad suggested it be a POD (I'm assuming meaning that it implements
Copy
?). If I use a Vec or any of these structures it can't be a Copy type.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's already an enum for this entity:
https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/rust-analyzer/src/req.rs#L199
so let's not create a copy of it.
A few more observations, feel free to implement any (or none) of them, if you want to:
It could be a bit simpler to use a
match
to map between bothInlayKind
enums, similar to the https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/rust-analyzer/src/main_loop/handlers.rs#L1006Since you can easily deserialize a
Vec<InlayKind>
, you can ask for that in thepackage.json
instead and get rid of all changes in thera_project_model
crate.Less code with more flexibility for the end users (as long as they know which options are available)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to deduplicate the
InlayKind
as mentioned and then just use the serde remote feature so we don't even need to do the match in the first place?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I'd prefer using
match
, but if your way works, it's also good, thanks for the dedup.