mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inlineMethodCall: encodeContextInfo for prepared block
Sometimes during the transformations we generate statements/expressions from text, thus context info is not preserved. Luckily it could be encoded after the preparation. Fixes IDEA-228512 Method inlining may behave incorrectly when return type is ignored GitOrigin-RevId: 58cc2013cd6286be88e9d85b2b7ec69e08d1815f
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3203d9178b
commit
fb8f978e49
@@ -604,14 +604,13 @@ public class InlineMethodProcessor extends BaseRefactoringProcessor {
|
||||
}
|
||||
|
||||
public void inlineMethodCall(PsiReferenceExpression ref) throws IncorrectOperationException {
|
||||
ChangeContextUtil.encodeContextInfo(myMethod, false);
|
||||
myMethodCopy = (PsiMethod)myMethod.copy();
|
||||
ChangeContextUtil.clearContextInfo(myMethod);
|
||||
|
||||
PsiMethodCallExpression methodCall = (PsiMethodCallExpression)ref.getParent();
|
||||
|
||||
InlineMethodHelper helper = new InlineMethodHelper(myProject, myMethod, myMethodCopy, methodCall);
|
||||
BlockData blockData = prepareBlock(ref, helper);
|
||||
ChangeContextUtil.encodeContextInfo(blockData.block, false);
|
||||
InlineUtil.solveVariableNameConflicts(blockData.block, ref, myMethodCopy.getBody());
|
||||
helper.initializeParameters(blockData.parmVars);
|
||||
addThisInitializer(methodCall, blockData.thisVar);
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
class Foo {
|
||||
void method() {
|
||||
new Bar().<caret>nonVoidMethod();
|
||||
}
|
||||
}
|
||||
class Bar {
|
||||
Bar nonVoidMethod() {
|
||||
return this.innerMethod();
|
||||
}
|
||||
Bar innerMethod() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
class Foo {
|
||||
void method() {
|
||||
new Bar().innerMethod();
|
||||
}
|
||||
}
|
||||
class Bar {
|
||||
Bar innerMethod() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -546,6 +546,10 @@ public class InlineMethodTest extends LightRefactoringTestCase {
|
||||
public void testTypeParameterMethodRefArgument() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIgnoreReturnValue() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getProjectJDK() {
|
||||
|
||||
Reference in New Issue
Block a user