mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inline method: avoid dbl substitution of return/param types
This commit is contained in:
@@ -634,9 +634,6 @@ public class InlineMethodProcessor extends BaseRefactoringProcessor {
|
||||
PsiSubstitutor callSubstitutor = getCallSubstitutor(methodCall);
|
||||
BlockData blockData = prepareBlock(ref, callSubstitutor, methodCall.getArgumentList(), tailCall);
|
||||
InlineUtil.solveVariableNameConflicts(blockData.block, ref, myMethodCopy.getBody());
|
||||
if (callSubstitutor != PsiSubstitutor.EMPTY) {
|
||||
substituteMethodTypeParams(blockData.block, callSubstitutor);
|
||||
}
|
||||
addParmAndThisVarInitializers(blockData, methodCall);
|
||||
|
||||
PsiElement anchor = RefactoringUtil.getParentStatement(methodCall, true);
|
||||
@@ -801,6 +798,9 @@ public class InlineMethodProcessor extends BaseRefactoringProcessor {
|
||||
final InlineUtil.TailCallType tailCallType)
|
||||
throws IncorrectOperationException {
|
||||
final PsiCodeBlock block = myMethodCopy.getBody();
|
||||
if (callSubstitutor != PsiSubstitutor.EMPTY) {
|
||||
substituteMethodTypeParams(block, callSubstitutor);
|
||||
}
|
||||
final PsiStatement[] originalStatements = block.getStatements();
|
||||
|
||||
PsiLocalVariable resultVar = null;
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
|
||||
class A {
|
||||
<T> void bar(List<T> root, LinkedHashSet<List<T>> list) {
|
||||
add<caret>IfNotNull(root, list);
|
||||
}
|
||||
|
||||
private static <T> void addIfNotNull(T element, Collection<T> result) {
|
||||
nested(result, element);
|
||||
}
|
||||
|
||||
|
||||
private static <S> void nested(Collection<S> result, S element) {}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
|
||||
class A {
|
||||
<T> void bar(List<T> root, LinkedHashSet<List<T>> list) {
|
||||
nested(list, root);
|
||||
}
|
||||
|
||||
|
||||
private static <S> void nested(Collection<S> result, S element) {}
|
||||
}
|
||||
@@ -330,6 +330,10 @@ public class InlineMethodTest extends LightRefactoringTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testAvoidMultipleSubstitutionInParameterTypes() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTestInlineThisOnly() {
|
||||
@NonNls String fileName = "/refactoring/inlineMethod/" + getTestName(false) + ".java";
|
||||
configureByFile(fileName);
|
||||
|
||||
Reference in New Issue
Block a user