refactorings: give synthetic target a chance: try refactoring on reference (IDEA-237759)

GitOrigin-RevId: 14e8734e38eae5c17db6fff3eac8b029f1f6a6e7
This commit is contained in:
Anna Kozlova
2020-04-30 06:15:58 +00:00
committed by intellij-monorepo-bot
parent fcd1363aee
commit 19cc7702ec
4 changed files with 24 additions and 2 deletions
@@ -0,0 +1,11 @@
enum E {
;
public static void m() {
E[] vs = values();
for (E value : vs) {
}
}
}
@@ -0,0 +1,10 @@
enum E {
;
public static void m() {
for (E value : val<caret>ues()) {
}
}
}
@@ -242,7 +242,8 @@ public class IntroduceVariableTest extends LightJavaCodeInsightTestCase {
public void testPolyadic() { doTest("b1", true, true, true, "boolean"); }
public void testAssignmentToUnresolvedReference() { doTest("collection", true, true, true, "java.util.List<? extends java.util.Collection<?>>"); }
public void testSubstringInSwitch() { doTest("ba", false, false, false, JAVA_LANG_STRING);}
public void testEnumValues() { doTest("vs", false, false, false, "E[]"); }
public void testNameSuggestion() {
String expectedTypeName = "Path";
doTest(new MockIntroduceVariableHandler("path", true, false, false, expectedTypeName) {
@@ -212,7 +212,7 @@ public abstract class BaseRefactoringAction extends AnAction implements UpdateIn
PsiFile file = dataContext.getData(CommonDataKeys.PSI_FILE);
PsiElement element = dataContext.getData(CommonDataKeys.PSI_ELEMENT);
Language[] languages = dataContext.getData(LangDataKeys.CONTEXT_LANGUAGES);
if (element == null || !isAvailableForLanguage(element.getLanguage())) {
if (element == null|| element instanceof SyntheticElement || !isAvailableForLanguage(element.getLanguage())) {
if (file == null || editor == null) {
return null;
}