EA-228757 - IOE: PsiElementFactoryImpl.createVariableDeclarationStatement

GitOrigin-RevId: 0bbefa07fde8fb4dd234aa221c4a360ae9d9b829
This commit is contained in:
Tagir Valeev
2020-03-26 05:31:51 +00:00
committed by intellij-monorepo-bot
parent 4fd1e215aa
commit a6bbf74b78
4 changed files with 15 additions and 1 deletions
@@ -1055,7 +1055,7 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
final JavaReplaceChoice replaceChoice) {
final boolean replaceAll = replaceChoice.isAll();
final SuggestedNameInfo suggestedName = getSuggestedName(typeSelectorManager.getDefaultType(), expr, anchor);
final String variableName = suggestedName.names.length > 0 ? suggestedName.names[0] : "";
final String variableName = suggestedName.names.length > 0 ? suggestedName.names[0] : "v";
final boolean declareFinal = replaceAll && declareFinalIfAll || !anyAssignmentLHS && createFinals(anchor.getContainingFile()) ||
anchor instanceof PsiSwitchLabelStatementBase;
final boolean declareVarType = canBeExtractedWithoutExplicitType(expr) && createVarType() && !replaceChoice.isChain();
@@ -0,0 +1,5 @@
class _ {
{
new<caret> _();
}
}
@@ -0,0 +1,5 @@
class _ {
{
_ xyz = new _();
}
}
@@ -73,6 +73,10 @@ public class InplaceIntroduceVariableTest extends AbstractJavaInplaceIntroduceTe
type("expr");
});
}
public void testNoNameSuggested() {
doTest(introducer -> type("xyz"));
}
public void testPlaceInsideLoopAndRename() {
doTest(introducer -> type("expr"));