mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
introduce array from varargs expression: preserve the method call (IDEA-75519)
This commit is contained in:
+1
-1
@@ -674,7 +674,7 @@ public abstract class BaseExpressionToFieldHandler extends IntroduceHandlerBase
|
||||
myOutOfCodeBlockExtraction = selectedExpr.getUserData(ElementToWorkOn.OUT_OF_CODE_BLOCK);
|
||||
myDeleteSelf = myOutOfCodeBlockExtraction != null;
|
||||
myElement = getPhysicalElement(selectedExpr);
|
||||
if (myElement.getParent() instanceof PsiExpressionStatement && getNormalizedAnchor(myAnchorElement).equals(myAnchorElement)) {
|
||||
if (myElement.getParent() instanceof PsiExpressionStatement && getNormalizedAnchor(myAnchorElement).equals(myAnchorElement) && selectedExpr.isPhysical()) {
|
||||
PsiStatement statement = (PsiStatement)myElement.getParent();
|
||||
if (statement.getParent() instanceof PsiCodeBlock) {
|
||||
myDeleteSelf = true;
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
class B1 {
|
||||
public B1(int i, String... s) {}
|
||||
}
|
||||
class A1 extends B1 {
|
||||
A1() {
|
||||
super(1, <selection>"a", "b"</selection>);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
class B1 {
|
||||
public B1(int i, String... s) {}
|
||||
}
|
||||
class A1 extends B1 {
|
||||
public static final String[] xxx = new String[]{"a", "b"};
|
||||
|
||||
A1() {
|
||||
super(1, xxx);
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,6 @@ package com.intellij.refactoring;
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.refactoring.ui.TypeSelectorManagerImpl;
|
||||
@@ -85,6 +83,12 @@ public class IntroduceConstantTest extends LightCodeInsightTestCase {
|
||||
checkResultByFile(BASE_PATH + getTestName(false) + "_after.java");
|
||||
}
|
||||
|
||||
public void testArrayFromVarargs() throws Exception {
|
||||
configureByFile(BASE_PATH + getTestName(false) + ".java");
|
||||
new MockIntroduceConstantHandler(null).invoke(getProject(), getEditor(), getFile(), null);
|
||||
checkResultByFile(BASE_PATH + getTestName(false) + "_after.java");
|
||||
}
|
||||
|
||||
|
||||
public void testEscalateVisibility() throws Exception {
|
||||
configureByFile(BASE_PATH + getTestName(false) + ".java");
|
||||
|
||||
Reference in New Issue
Block a user