mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
CodeInsightUtil#findExpressionInRange: tolerate single error element at the end of selection
Fixes IDEA-51483 Extract Variable: does nothing on a block with invalid parentheses GitOrigin-RevId: 4d69e9ec9521b1c962024512deef8fd0f71fe85e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
aeeb1ebd38
commit
f68c88e6cf
@@ -42,7 +42,7 @@ public class CodeInsightUtil {
|
||||
if (element2 instanceof PsiJavaToken) {
|
||||
final PsiJavaToken token = (PsiJavaToken)element2;
|
||||
final IElementType tokenType = token.getTokenType();
|
||||
if (tokenType.equals(JavaTokenType.SEMICOLON)) {
|
||||
if (tokenType.equals(JavaTokenType.SEMICOLON) || element2.getParent() instanceof PsiErrorElement) {
|
||||
expression = findElementInRange(file, startOffset, element2.getTextRange().getStartOffset(), PsiExpression.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
class Test {
|
||||
void foo(String s) {
|
||||
String x = s.trim();)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class Test {
|
||||
void foo(String s) {
|
||||
<selection>s.trim())</selection>
|
||||
}
|
||||
}
|
||||
@@ -190,6 +190,10 @@ public class IntroduceVariableTest extends LightJavaCodeInsightTestCase {
|
||||
doTest(new MockIntroduceVariableHandler("mi5", false, false, false, "int"));
|
||||
}
|
||||
|
||||
public void testSkipErroneousParen() {
|
||||
doTest(new MockIntroduceVariableHandler("x", false, false, false, CommonClassNames.JAVA_LANG_STRING));
|
||||
}
|
||||
|
||||
public void testInsideIf() {
|
||||
doTest(new MockIntroduceVariableHandler("s1", false, false, false, CommonClassNames.JAVA_LANG_STRING));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user