PsiElement (@NotNull String text) { Object source = getSource(); try { if (source instanceof PsiViewerExtension) { return ((PsiViewerExtension)source).createElement(myProject, text); } if (source instanceof FileType type) { String ext = type.getDefaultExtension(); if (myExtensionComboBox.isVisible() && myExtensionComboBox.getSelectedItem() != null) { ext = StringUtil.toLowerCase(myExtensionComboBox.getSelectedItem().toString()); } if (type instanceof LanguageFileType) { Language dialect = (Language)myDialectComboBox.getSelectedItem(); if (dialect != null) { return PsiFileFactory.getInstance(myProject).createFileFromText("Dummy." + ext, dialect, text); } } return PsiFileFactory.getInstance(myProject).createFileFromText("Dummy." + ext, type, text); } } catch (IncorrectOperationException e) { Messages.showMessageDialog(myProject, e.getMessage(), CommonBundle.message("title.error"), Messages.getErrorIcon()); } return null; }