Java Code Examples for com.intellij.lang.Language#getDisplayName()

The following examples show how to use com.intellij.lang.Language#getDisplayName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QuickEditAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
protected Pair<PsiElement, TextRange> getRangePair(final PsiFile file, final Editor editor) {
  final int offset = editor.getCaretModel().getOffset();
  final PsiLanguageInjectionHost host =
          PsiTreeUtil.getParentOfType(file.findElementAt(offset), PsiLanguageInjectionHost.class, false);
  if (host == null || ElementManipulators.getManipulator(host) == null) return null;
  final List<Pair<PsiElement, TextRange>> injections = InjectedLanguageManager.getInstance(host.getProject()).getInjectedPsiFiles(host);
  if (injections == null || injections.isEmpty()) return null;
  final int offsetInElement = offset - host.getTextRange().getStartOffset();
  final Pair<PsiElement, TextRange> rangePair = ContainerUtil.find(injections, new Condition<Pair<PsiElement, TextRange>>() {
    @Override
    public boolean value(final Pair<PsiElement, TextRange> pair) {
      return pair.second.containsRange(offsetInElement, offsetInElement);
    }
  });
  if (rangePair != null) {
    final Language language = rangePair.first.getContainingFile().getLanguage();
    final Object action = language.getUserData(EDIT_ACTION_AVAILABLE);
    if (action != null && action.equals(false)) return null;

    myLastLanguageName = language.getDisplayName();
  }
  return rangePair;
}
 
Example 2
Source File: TemplateLanguageStructureViewBuilder.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nonnull
public StructureViewModel createStructureViewModel(@Nullable Editor editor) {
  List<StructureViewComposite.StructureViewDescriptor> viewDescriptors = new ArrayList<>();
  PsiFile psiFile = ObjectUtils.notNull(PsiManager.getInstance(myProject).findFile(myVirtualFile));
  for (Language language : getLanguages(psiFile)) {
    StructureViewBuilder builder = getBuilder(psiFile, language);
    if (!(builder instanceof TreeBasedStructureViewBuilder)) continue;
    StructureViewModel model = ((TreeBasedStructureViewBuilder)builder).createStructureViewModel(editor);
    String title = language.getDisplayName();
    Image icon = ObjectUtils.notNull(LanguageUtil.getLanguageFileType(language), UnknownFileType.INSTANCE).getIcon();
    viewDescriptors.add(new StructureViewComposite.StructureViewDescriptor(title, model, icon));
  }
  return new StructureViewCompositeModel(psiFile, editor, viewDescriptors);
}
 
Example 3
Source File: PostfixTemplatesChildConfigurable.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nls
@Override
public String getDisplayName() {
  Language languageByID = Language.findLanguageByID(myExtensionPoint.getKey());
  return languageByID == null ? myExtensionPoint.getKey() : languageByID.getDisplayName();
}
 
Example 4
Source File: LastRunReformatCodeOptionsProvider.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static String getRearrangeCodeKeyFor(@Nonnull Language language) {
  return REARRANGE_ENTRIES_KEY + language.getDisplayName();
}
 
Example 5
Source File: TemplateDataLanguageConfigurable.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected String visualize(@Nonnull final Language language) {
  return language.getDisplayName();
}
 
Example 6
Source File: ChooseByNameLanguageFilter.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected String textForFilterValue(@Nonnull Language value) {
  return value.getDisplayName();
}
 
Example 7
Source File: LanguageCodeStyleSettingsProvider.java    From consulo with Apache License 2.0 3 votes vote down vote up
/**
 * 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.
 */
@Nonnull
public static String getLanguageName(Language lang) {
  final LanguageCodeStyleSettingsProvider provider = forLanguage(lang);
  String providerLangName = provider != null ? provider.getLanguageName() : null;
  return providerLangName != null ? providerLangName : lang.getDisplayName();
}
 
Example 8
Source File: CodeStyleSettingsProvider.java    From consulo with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the name of the configurable page without creating a Configurable instance.
 *
 * @return the display name of the configurable page.
 * @since 9.0
 */
@Nullable
public String getConfigurableDisplayName() {
  Language lang = getLanguage();
  return lang == null ? null : lang.getDisplayName();
}