-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add assignment type analysis for ide-completion #20381
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
Conversation
@@ -1870,3 +1882,23 @@ fn next_non_trivia_sibling(ele: SyntaxElement) -> Option<SyntaxElement> { | |||
} | |||
None | |||
} | |||
|
|||
fn prev_assign_token_at_whitespace(mut token: SyntaxToken) -> SyntaxToken { | |||
while token.kind() == SyntaxKind::WHITESPACE |
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.
while token.kind() == SyntaxKind::WHITESPACE | |
while token.kind().is_trivia() |
This includes comments.
Generally it'd be better to use the parsed tree, but given completion works with malformed trees (and speculative execution is not yet a thing) I don't think it's viable.
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.
This includes comments.
ok
@@ -562,6 +562,7 @@ fn expected_type_and_name<'db>( | |||
token: &SyntaxToken, | |||
name_like: &ast::NameLike, | |||
) -> (Option<Type<'db>>, Option<NameOrNameRef>) { | |||
let token = prev_assign_token_at_whitespace(token.clone()); |
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.
Why do we need this? That is, why doesn't just adding ast::BinExpr
to the match below works?
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.
For { x = $0 }
, token
is }
Thanks! |
Fixes #20361