Language (@NotNull String languageId) { Language language = InjectedLanguage.findLanguageById(languageId); if (language != null) return language; ReferenceInjector injector = ReferenceInjector.findById(languageId); if (injector != null) return injector.toLanguage(); FileTypeManager fileTypeManager = FileTypeManager.getInstance(); FileType fileType = fileTypeManager.getFileTypeByExtension(languageId); if (fileType instanceof LanguageFileType) { return ((LanguageFileType)fileType).getLanguage(); } LightVirtualFile virtualFileNamedAsLanguageId = new LightVirtualFile(languageId); LightVirtualFile virtualFileWithLanguageIdAsExtension = new LightVirtualFile("textmate." + languageId); for (FileType registeredFileType : fileTypeManager.getRegisteredFileTypes()) { if (registeredFileType instanceof FileTypeIdentifiableByVirtualFile && registeredFileType instanceof LanguageFileType && (((FileTypeIdentifiableByVirtualFile)registeredFileType).isMyFileType(virtualFileNamedAsLanguageId) || ((FileTypeIdentifiableByVirtualFile)registeredFileType).isMyFileType(virtualFileWithLanguageIdAsExtension))) { return ((LanguageFileType)registeredFileType).getLanguage(); } } return null; }