Template (PsiField field, Object expectedTypes, PsiClass targetClass, Editor editor, PsiElement context, boolean createConstantField, @NotNull PsiSubstitutor substitutor) { Project project = field.getProject(); PsiElementFactory factory = JavaPsiFacade.getElementFactory(project); field = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(field); TemplateBuilderImpl builder = new TemplateBuilderImpl(field); if (!(expectedTypes instanceof ExpectedTypeInfo[])) { expectedTypes = ExpectedTypeInfo.EMPTY_ARRAY; } new GuessTypeParameters(project, factory, builder, substitutor).setupTypeElement( field.getTypeElement(), (ExpectedTypeInfo[])expectedTypes, context, targetClass ); if (createConstantField && !field.hasInitializer()) { field.setInitializer(factory.createExpressionFromText("0", null)); builder.replaceElement(field.getInitializer(), new EmptyExpression()); PsiIdentifier identifier = field.getNameIdentifier(); builder.setEndVariableAfter(identifier); } field = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(field); editor.getCaretModel().moveToOffset(field.getTextRange().getStartOffset()); Template template = builder.buildInlineTemplate(); if (disableShortenLongNames(project, ((ExpectedTypeInfo[])expectedTypes))) { template.setToShortenLongNames(false); } return template; }