[java-refactoring] IntroduceVariableBase: move getCanonicalText() to alternative resolve

May help VarPostfixTemplateTest.testAnonymous flaky test

GitOrigin-RevId: d0d1726186d77e2eb24ee4d81f86fdb27fba9e49
This commit is contained in:
Tagir Valeev
2024-07-12 15:08:36 +02:00
committed by intellij-monorepo-bot
parent ea589c6c56
commit 9f190c4cad

View File

@@ -341,9 +341,9 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
}
try {
PsiType type = DumbService.getInstance(project)
.computeWithAlternativeResolveEnabled(() -> GenericsUtil.getVariableTypeByExpressionType(originalType));
JavaPsiFacade.getElementFactory(project).createTypeElementFromText(type.getCanonicalText(), expr);
String typeText = DumbService.getInstance(project)
.computeWithAlternativeResolveEnabled(() -> GenericsUtil.getVariableTypeByExpressionType(originalType).getCanonicalText());
JavaPsiFacade.getElementFactory(project).createTypeElementFromText(typeText, expr);
}
catch (IncorrectOperationException ignore) {
String message = RefactoringBundle.getCannotRefactorMessage(JavaRefactoringBundle.message("unknown.expression.type"));