@NotNull public static Language[] getLanguagesWithCodeStyleSettings() { final ArrayList<Language> languages = new ArrayList<>(); for (LanguageCodeStyleSettingsProvider provider : Extensions.getExtensions(EP_NAME)) { languages.add(provider.getLanguage()); } return languages.toArray(new Language[languages.size()]); }
@Nullable public static LanguageCodeStyleSettingsProvider forLanguage(final Language language) { for (LanguageCodeStyleSettingsProvider provider : Extensions.getExtensions(EP_NAME)) { if (provider.getLanguage().equals(language)) { return provider; } } return null; }
@Nullable public static Language getLanguage(String langName) { for (LanguageCodeStyleSettingsProvider provider : Extensions.getExtensions(EP_NAME)) { String name = provider.getLanguageName(); if (name == null) name = provider.getLanguage().getDisplayName(); if (langName.equals(name)) { return provider.getLanguage(); } } return null; }
@SuppressWarnings("unused") public static DisplayPriority getDisplayPriority(Language language) { LanguageCodeStyleSettingsProvider langProvider = forLanguage(language); if (langProvider == null) return DisplayPriority.LANGUAGE_SETTINGS; return langProvider.getDisplayPriority(); }
@Nullable public static PsiFile createFileFromText( final Language language, final Project project, final String text) { final LanguageCodeStyleSettingsProvider provider = forLanguage(language); return provider != null ? provider.createFileFromText(project, text) : null; }
/** * Returns a language name to be shown in UI. Used to overwrite language's display name by another * name to be shown in UI. * * @param lang The language whose display name must be return. * @return Alternative UI name defined by provider.getLanguageName() method or (if the method * returns null) language's own display name. */ @Nullable public static String getLanguageName(Language lang) { final LanguageCodeStyleSettingsProvider provider = forLanguage(lang); String providerLangName = provider != null ? provider.getLanguageName() : null; return providerLangName != null ? providerLangName : lang.getDisplayName(); }
@Nullable public static String getFileExt(Language lang) { final LanguageCodeStyleSettingsProvider provider = forLanguage(lang); return provider != null ? provider.getFileExt() : null; }
@Nullable public static CommonCodeStyleSettings getDefaultCommonSettings(Language lang) { final LanguageCodeStyleSettingsProvider provider = forLanguage(lang); return provider != null ? provider.getDefaultCommonSettings() : null; }
public static int getRightMargin(Language lang, @NotNull SettingsType settingsType) { final LanguageCodeStyleSettingsProvider provider = forLanguage(lang); return provider != null ? provider.getRightMargin(settingsType) : -1; }
@Nullable public static String getCodeSample(Language lang, @NotNull SettingsType settingsType) { final LanguageCodeStyleSettingsProvider provider = forLanguage(lang); return provider != null ? provider.getCodeSample(settingsType) : null; }