boolean typeRequiresRefinement = psiClass.isInterface() || psiClass.hasModifierProperty(PsiModifier.ABSTRACT);
String template = "new " + ref.getText() + "()";
if (typeRequiresRefinement) template += "{}";
PsiElementFactory factory = JavaPsiFacade.getInstance(context.getProject()).getElementFactory();
PsiNewExpression newExpression = (PsiNewExpression)factory.createExpressionFromText(template, context);
<BUG>PsiElement replace = ((PsiJavaReference)ref).getElement().replace(newExpression);
replace.getNode().addLeaf(JavaTokenType.SEMICOLON, ";", null);
int offset = calculateOffset((PsiNewExpression)replace, accessibility, typeRequiresRefinement);</BUG>
editor.getCaretModel().moveToOffset(offset);
}

boolean typeRequiresRefinement = psiClass.isInterface() || psiClass.hasModifierProperty(PsiModifier.ABSTRACT);
String template = "new " + ref.getText() + "()";
if (typeRequiresRefinement) template += "{}";
PsiElementFactory factory = JavaPsiFacade.getInstance(context.getProject()).getElementFactory();
PsiNewExpression newExpression = (PsiNewExpression)factory.createExpressionFromText(template, context);
PsiElement replace = ((PsiJavaReference)ref).getElement().replace(newExpression);
PsiStatement statement = PsiTreeUtil.getNonStrictParentOfType(replace, PsiStatement.class);
ASTNode existingSemicolon = statement instanceof CompositeElement
? ((CompositeElement)statement).findChildByRole(ChildRole.CLOSING_SEMICOLON)
: null;
if (statement == null || existingSemicolon == null) {
replace.getNode().addLeaf(JavaTokenType.SEMICOLON, ";", null);
