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

The following examples show how to use com.intellij.lang.Language#getBaseLanguage() . 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: LanguageFolding.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public FoldingBuilder forLanguage(@Nonnull Language l) {
  FoldingBuilder cached = l.getUserData(getLanguageCache());
  if (cached != null) return cached;

  List<FoldingBuilder> extensions = forKey(l);
  FoldingBuilder result;
  if (extensions.isEmpty()) {

    Language base = l.getBaseLanguage();
    if (base != null) {
      result = forLanguage(base);
    }
    else {
      result = getDefaultImplementation();
    }
  }
  else {
    return extensions.size() == 1 ? extensions.get(0) : new CompositeFoldingBuilder(extensions);
  }

  l.putUserData(getLanguageCache(), result);
  return result;
}
 
Example 2
Source File: BreadcrumbsUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static BreadcrumbsProvider getInfoProvider(@Nonnull Language language) {
  List<BreadcrumbsProvider> providers = BreadcrumbsProvider.EP_NAME.getExtensionList();
  while (language != null) {
    for (BreadcrumbsProvider provider : providers) {
      Language supported = provider.getLanguage();
      if (language.is(supported)) {
        return provider;
      }
    }
    language = language.getBaseLanguage();
  }
  return null;
}
 
Example 3
Source File: CompletionContributor.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected List<CompletionContributor> buildExtensions(String stringKey, Language key) {
  final THashSet<String> allowed = new THashSet<String>();
  while (key != null) {
    allowed.add(keyToString(key));
    key = key.getBaseLanguage();
  }
  allowed.add("any");
  return buildExtensions(allowed);
}
 
Example 4
Source File: CommonCodeStyleSettingsManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
CommonCodeStyleSettings getCommonSettings(@Nullable Language lang) {
  Map<Language, CommonCodeStyleSettings> commonSettingsMap = getCommonSettingsMap();
  Language baseLang = ObjectUtil.notNull(lang, Language.ANY);
  while (baseLang != null) {
    CommonCodeStyleSettings settings = commonSettingsMap.get(baseLang);
    if (settings != null) return settings;
    baseLang = baseLang.getBaseLanguage();
  }
  return null;
}
 
Example 5
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();
}