-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
"Insert explicit type " assist fix #2869, fix typo #2877
Conversation
@@ -34,6 +35,14 @@ pub(crate) fn add_explicit_type(ctx: AssistCtx<impl HirDatabase>) -> Option<Assi | |||
// The binding must have a name | |||
let name = pat.name()?; | |||
let name_range = name.syntax().text_range(); | |||
// Assist should only be applicable if cursor is between 'let' and '=' | |||
let stmt_range = stmt.syntax().text_range(); | |||
let eq_range = stmt.syntax().descendants_with_tokens().find(|t| t.kind() == EQ)?.text_range(); |
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.
Let’s add an eq_token method to ast::LetStmt, so that it can be used elsewhere. There’s extensions.rs module for that
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.
Other than this, looks good to me!
|
||
pub fn eq_token(&self) -> Option<SyntaxToken> { | ||
self.syntax() | ||
.descendants_with_tokens() |
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.
Oh, we should also use children instead of descendants here: descendants is recursive, and so can be much slower. Everything is ok!
bors d+
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.
Oh, I see. Is there any documentation for Rowan ?
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.
Nope :-(
Though, the API is stable-ish now, so writing docs should be a good investment. There's api_walkthoruh test which might be helpful.
bors r+ |
2877: "Insert explicit type " assist fix #2869, fix typo r=matklad a=TomasKralCZ So this was quite straightforward. I basically looked at how the other assists work and tried doing something simillar. I also fixed a typo in the other assist. Co-authored-by: TomasKralCZ <tomas@kral.hk>
Build succeeded
|
So this was quite straightforward. I basically looked at how the other assists work and tried doing something simillar. I also fixed a typo in the other assist.