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

The following examples show how to use com.intellij.lang.Language#getID() . 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: ParsingTestCase.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static void doCheckResult(String myFullDataPath,
                                 PsiFile file,
                                 boolean checkAllPsiRoots,
                                 String targetDataName,
                                 boolean skipSpaces,
                                 boolean printRanges) throws IOException {
  FileViewProvider provider = file.getViewProvider();
  Set<Language> languages = provider.getLanguages();

  if (!checkAllPsiRoots || languages.size() == 1) {
    doCheckResult(myFullDataPath, targetDataName + ".txt", toParseTreeText(file, skipSpaces, printRanges).trim());
    return;
  }

  for (Language language : languages) {
    PsiFile root = provider.getPsi(language);
    String expectedName = targetDataName + "." + language.getID() + ".txt";
    doCheckResult(myFullDataPath, expectedName, toParseTreeText(root, skipSpaces, printRanges).trim());
  }
}
 
Example 2
Source File: FileContentImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@RequiredReadAction
public static PsiFile createFileFromText(@Nonnull Project project, @Nonnull CharSequence text, @Nonnull LanguageFileType fileType, @Nonnull VirtualFile file, @Nonnull String fileName) {
  Language language = fileType.getLanguage();
  Language substitutedLanguage = LanguageSubstitutors.INSTANCE.substituteLanguage(language, file, project);
  LanguageVersion languageVersion = LanguageVersionResolvers.INSTANCE.forLanguage(substitutedLanguage).getLanguageVersion(substitutedLanguage, project, file);
  PsiFile psiFile = PsiFileFactory.getInstance(project).createFileFromText(fileName, languageVersion, text, false, false, false, file);
  if (psiFile == null) {
    throw new IllegalStateException("psiFile is null. language = " + language.getID() + ", substitutedLanguage = " + substitutedLanguage.getID());
  }
  return psiFile;
}
 
Example 3
Source File: LanguagePostfixTemplate.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void validateTemplatesForLanguage(Language key, List<PostfixTemplateProvider> providers) {
  Set<String> templateKeys = ContainerUtil.newHashSet();
  for (PostfixTemplateProvider provider : providers) {
    for (PostfixTemplate template : provider.getTemplates()) {
      if (!templateKeys.add(template.getKey())) {
        throw new IllegalStateException("Duplicated key " + template.getKey() + " for language " + key.getID());
      }
    }
  }
}
 
Example 4
Source File: BreadcrumbsUtilEx.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static String findLanguageWithBreadcrumbSettings(Language language) {
  EditorSettingsExternalizable settings = EditorSettingsExternalizable.getInstance();
  Language base = language;
  while (base != null) {
    if (settings.hasBreadcrumbSettings(base.getID())) {
      return base.getID();
    }
    base = base.getBaseLanguage();
  }
  return language.getID();
}
 
Example 5
Source File: RainbowHighlighter.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
private static String getKey(@Nullable Language language) {
  return RAINBOW_TYPE + " " + (language == null ? "Default language" : language.getID());
}
 
Example 6
Source File: CompletionContributor.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected String keyToString(Language key) {
  return key.getID();
}
 
Example 7
Source File: Identikit.java    From consulo with Apache License 2.0 4 votes vote down vote up
private ByType(@Nonnull Class<? extends PsiElement> elementClass, @Nullable IElementType elementType, @Nonnull Language fileLanguage) {
  myElementClassName = elementClass.getName();
  myElementTypeId = elementType != null ? elementType.getIndex() : -1;
  myFileLanguageId = fileLanguage.getID();
}
 
Example 8
Source File: ParameterNameHintsSettings.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
private Set<String> getAddedPatterns(Language language) {
  String key = language.getID();
  Set<String> set = myAddedPatterns.get(key);
  return set == null ? Collections.<String>emptySet() : set;
}
 
Example 9
Source File: ParameterNameHintsSettings.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
private Set<String> getRemovedPatterns(Language language) {
  String key = language.getID();
  Set<String> set = myRemovedPatterns.get(key);
  return set == null ? Collections.<String>emptySet() : set;
}
 
Example 10
Source File: ParameterNameHintsSettings.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void setRemovedPatterns(Language language, Set<String> removed) {
  String key = language.getID();
  myRemovedPatterns.put(key, removed);
}
 
Example 11
Source File: ParameterNameHintsSettings.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void setAddedPatterns(Language language, Set<String> added) {
  String key = language.getID();
  myAddedPatterns.put(key, added);
}
 
Example 12
Source File: CodeStyleMainPanel.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
private static String getSelectedTabPropertyName(@Nonnull TabbedLanguageCodeStylePanel panel) {
  Language language = panel.getDefaultLanguage();
  return SELECTED_TAB + (language != null ? "." + language.getID() : "");
}
 
Example 13
Source File: TemplateDataLanguageMappings.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected String serialize(final Language language) {
  return language.getID();
}
 
Example 14
Source File: ScratchFileServiceImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
protected String serialize(Language language) {
  return language.getID();
}
 
Example 15
Source File: GotoClassSymbolConfiguration.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected String nameForElement(Language type) {
  return type.getID();
}