PsiClass (final CreateTestDialog d, final FileTemplateDescriptor fileTemplateDescriptor, final PsiDirectory targetDirectory) { final String templateName = fileTemplateDescriptor.getFileName(); final FileTemplate fileTemplate = FileTemplateManager.getInstance(targetDirectory.getProject()).getCodeTemplate(templateName); final Properties defaultProperties = FileTemplateManager.getInstance(targetDirectory.getProject()).getDefaultProperties(); Properties properties = new Properties(defaultProperties); properties.setProperty(FileTemplate.ATTRIBUTE_NAME, d.getClassName()); final PsiClass targetClass = d.getTargetClass(); if (targetClass != null && targetClass.isValid()) { properties.setProperty(FileTemplate.ATTRIBUTE_CLASS_NAME, targetClass.getQualifiedName()); } try { final PsiElement psiElement = FileTemplateUtil.createFromTemplate(fileTemplate, templateName, properties, targetDirectory); if (psiElement instanceof PsiClass) { return (PsiClass)psiElement; } return null; } catch (Exception e) { return null; } }