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
REF: Fix introduce variable when first expression is inside nested block #5053
REF: Fix introduce variable when first expression is inside nested block #5053
Conversation
while (exprs.any { !PsiTreeUtil.isAncestor(anchor.parent, it, true) }) { | ||
anchor = anchor.parent | ||
} | ||
return anchor |
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.
Looks like the following version does the same but faster
val parent = PsiTreeUtil.findCommonParent(anchor.parent, *exprs.toTypedArray())
while (anchor.parent != parent) {
anchor = anchor.parent
}
Also, maybe it's worth to extract while
loop into separate function because we have the same code in findAnchor
above
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.
Yes, thank you, updated
fb96f81
to
a38b460
Compare
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.
bors r+
bors r- |
bors r+ |
@mchernyavsky Looks like it's bors bug. The same was with #5057 |
a38b460
to
0938d93
Compare
@Undin yes, rebased |
bors r+ |
Fix that when extracting
7
to variable from this code:it was transformed to
while correct result would be