public boolean acceptInput(final VirtualFile file) { if (!(file.getFileSystem() instanceof LocalFileSystem)) { return false; } final FileType fileType = file.getFileType(); if (!(fileType instanceof LanguageFileType)) { return false; } final LanguageFileType languageFileType = (LanguageFileType) fileType; final Language language = languageFileType.getLanguage(); return language instanceof TemplateLanguage || (language instanceof XMLLanguage && language != XMLLanguage.INSTANCE); }
private static List<LanguageDefinition> collectLibraryLanguages( final ConvertContext context, final Collection<PsiClass> allLanguages) { return ContainerUtil.mapNotNull( Language.getRegisteredLanguages(), (NullableFunction<Language, LanguageDefinition>) language -> { if (language.getID().isEmpty() || language instanceof DependentLanguage) { return null; } final PsiClass psiClass = DomJavaUtil.findClass( language.getClass().getName(), context.getInvocationElement(), true); if (psiClass == null || !allLanguages.contains(psiClass)) { return null; } final LanguageFileType type = language.getAssociatedFileType(); final Icon icon = type != null ? type.getIcon() : null; return new LanguageDefinition( language.getID(), psiClass, icon, language.getDisplayName()); }); }
@NotNull public static PsiFile createFileFromText( @NotNull Project project, @NotNull CharSequence text, @NotNull LanguageFileType fileType, @NotNull VirtualFile file, @NotNull String fileName) { final Language language = fileType.getLanguage(); final Language substitutedLanguage = LanguageSubstitutors.INSTANCE.substituteLanguage(language, file, project); return PsiFileFactory.getInstance(project) .createFileFromText(fileName, substitutedLanguage, text, false, false, true, file); }
private SubstitutedFileType( @NotNull FileType originalFileType, @NotNull LanguageFileType substitutionFileType) { super(substitutionFileType.getLanguage()); this.originalFileType = originalFileType; this.fileType = substitutionFileType; }
public AbstractLanguageParsingTestCase(final String dataPath, final LanguageFileType fileType) { this(dataPath, fileType.getDefaultExtension(), ((IXtextLanguage) fileType.getLanguage())); }