Introduce pattern variable: ignore var setting

GitOrigin-RevId: a34a3b3398cb42c0cb89c4b3254198dea7355f0e
This commit is contained in:
Tagir Valeev
2020-03-17 20:53:55 +00:00
committed by intellij-monorepo-bot
parent 998ca6cb4c
commit 012d7e163f
2 changed files with 8 additions and 6 deletions
@@ -111,11 +111,11 @@ class VariableExtractor {
if (!(var instanceof PsiPatternVariable)) {
PsiUtil.setModifierProperty(var, PsiModifier.FINAL, mySettings.isDeclareFinal());
}
if (mySettings.isDeclareVarType()) {
PsiTypeElement typeElement = var.getTypeElement();
LOG.assertTrue(typeElement != null);
IntroduceVariableBase.expandDiamondsAndReplaceExplicitTypeWithVar(typeElement, var);
if (mySettings.isDeclareVarType()) {
PsiTypeElement typeElement = var.getTypeElement();
LOG.assertTrue(typeElement != null);
IntroduceVariableBase.expandDiamondsAndReplaceExplicitTypeWithVar(typeElement, var);
}
}
myFieldConflictsResolver.fix();
return SmartPointerManager.getInstance(myProject).createSmartPsiElementPointer(var);
@@ -134,7 +134,9 @@ public class IntroduceVariableTest extends LightJavaCodeInsightTestCase {
public void testPatternVariableNotUsedAfterwards() {
doTest("temp", true, false, false, "boolean");
}
public void testPatternVariableDeclarationJava14Preview() { doTest("temp", true, false, false, JAVA_LANG_STRING);}
public void testPatternVariableDeclarationJava14Preview() {
doTestWithVarType(new MockIntroduceVariableHandler("temp", true, false, false, JAVA_LANG_STRING));
}
public void testPatternVariableDeclarationUsedInLocalJava14Preview() { doTest("temp", true, false, false, JAVA_LANG_STRING);}
public void testPatternVariableDeclarationAfterIfJava14Preview() { doTest("temp", true, false, false, JAVA_LANG_STRING);}
public void testNonPatternDeclarationJava14Preview() { doTest("temp", true, false, false, JAVA_LANG_STRING);}