Result (ExpressionContext context) { PsiDocumentManager.getInstance(context.getProject()).commitAllDocuments(); PsiType type = myTypePointer.getType(); if (type != null) { if (myAddDefType && (type.equalsToText(CommonClassNames.JAVA_LANG_OBJECT) || mySelectDef)) { return new TextResult(GrModifier.DEF); } type = TypesUtil.unboxPrimitiveTypeWrapper(type); if (type == null) return null; final PsiType finalType = type; return new PsiTypeResult(finalType, context.getProject()) { @Override public void handleRecalc(PsiFile psiFile, Document document, int segmentStart, int segmentEnd) { if (myItems.size() <= 1) { super.handleRecalc(psiFile, document, segmentStart, segmentEnd); } else { JavaTemplateUtil.updateTypeBindings(getType(), psiFile, document, segmentStart, segmentEnd, true); } } @Override public String toString() { return myItems.size() == 1 ? super.toString() : finalType.getPresentableText(); } }; } return null; }