void (PsiVariable psiVariable) { Project project = psiVariable.getProject(); psiVariable.normalizeDeclaration(); PsiTypeElement typeElement = psiVariable.getTypeElement(); if (typeElement == null || typeElement.isInferredType()) { return; } PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project); PsiClass variablePsiClass = JavaPsiFacade.getInstance(project).findClass(variableClassName, psiVariable.getResolveScope()); if (variablePsiClass == null) { return; } PsiJavaCodeReferenceElement referenceElementByFQClassName = elementFactory.createReferenceElementByFQClassName(variableClassName, psiVariable.getResolveScope()); typeElement = (PsiTypeElement) IntroduceVariableUtil.expandDiamondsAndReplaceExplicitTypeWithVar(typeElement, typeElement); typeElement.deleteChildRange(typeElement.getFirstChild(), typeElement.getLastChild()); typeElement.add(referenceElementByFQClassName); RemoveRedundantTypeArgumentsUtil.removeRedundantTypeArguments(psiVariable); executeAfterReplacing(psiVariable); CodeStyleManager.getInstance(project).reformat(psiVariable); }