mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-17 07:20:53 +07:00
introduce constant/field: static/final should be set before actual add - anchor detection (IDEA-52969)
This commit is contained in:
@@ -9,6 +9,7 @@ import com.intellij.psi.PsiLocalVariable;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.testFramework.LightCodeInsightTestCase;
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import com.intellij.util.VisibilityUtil;
|
||||
import junit.framework.Assert;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
@@ -65,6 +66,27 @@ public class IntroduceConstantTest extends LightCodeInsightTestCase {
|
||||
checkResultByFile(BASE_PATH + getTestName(false) + "_after.java");
|
||||
}
|
||||
|
||||
public void testPartialStringLiteralAnchor() 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");
|
||||
final PsiClass[] classes = ((PsiJavaFile)getFile()).getClasses();
|
||||
Assert.assertTrue(classes.length == 2);
|
||||
final PsiClass targetClass = classes[1];
|
||||
Assert.assertNotNull(targetClass);
|
||||
new MockIntroduceConstantHandler(targetClass){
|
||||
@Override
|
||||
protected String getVisibility() {
|
||||
return VisibilityUtil.ESCALATE_VISIBILITY;
|
||||
}
|
||||
}.invoke(getProject(), getEditor(), getFile(), null);
|
||||
checkResultByFile(BASE_PATH + getTestName(false) + "_after.java");
|
||||
}
|
||||
|
||||
protected Sdk getProjectJDK() {
|
||||
return JavaSdkImpl.getMockJdk15("java 1.5");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user