Java Code Examples for com.intellij.lang.Language.getRegisteredLanguages()

The following are Jave code examples for showing how to use getRegisteredLanguages() of the com.intellij.lang.Language class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: intellij-ce-playground   File: RemoteFileUtil.java   Source Code and License Vote up 6 votes
@Nullable
public static FileType getFileType(@Nullable String contentType) {
  if (contentType == null) return null;

  int end = contentType.indexOf(';');
  String mimeType = end == -1 ? contentType : contentType.substring(0, end);
  if (mimeType.isEmpty()) {
    return null;
  }

  for (Language language : Language.getRegisteredLanguages()) {
    String[] types = language.getMimeTypes();
    for (String type : types) {
      if (type.equalsIgnoreCase(mimeType)) {
        FileType fileType = language.getAssociatedFileType();
        if (fileType != null) {
          return fileType;
        }
      }
    }
  }
  return null;
}
 
Example 2
Project: intellij-ce-playground   File: ScriptLanguageInjector.java   Source Code and License Vote up 6 votes
public void getLanguagesToInject(@NotNull final MultiHostRegistrar registrar, @NotNull final PsiElement host) {
  if (SCRIPT_PATTERN.accepts(host)) {
    final List<String> registeredLanguages = JavaFxPsiUtil.parseInjectedLanguages((XmlFile)host.getContainingFile());
    for (Language language : Language.getRegisteredLanguages()) {
      for (String registeredLanguage : registeredLanguages) {
        if (StringUtil.equalsIgnoreCase(language.getID(), registeredLanguage)) {
          registrar.startInjecting(language)
            .addPlace(null, null, (PsiLanguageInjectionHost) host,
                      TextRange.from(0, host.getTextLength() - 1))
            .doneInjecting();
          break;
        }
      }
    }
  }
}
 
Example 3
Project: manifold-ij   File: ManApplicationComponent.java   Source Code and License Vote up 5 votes
private void registerAnnotatorWithAllLanguages()
{
  for( Language lang: Language.getRegisteredLanguages() )
  {
    LanguageAnnotators.INSTANCE.addExplicitExtension( lang, new ManifoldPsiClassAnnotator() );
  }
}
 
Example 4
Project: intellij-ce-playground   File: EditorSmartKeysConfigurable.java   Source Code and License Vote up 5 votes
private static boolean hasAnyDocAwareCommenters() {
  final Collection<Language> languages = Language.getRegisteredLanguages();
  for (Language language : languages) {
    final Commenter commenter = LanguageCommenters.INSTANCE.forLanguage(language);
    if (commenter instanceof CodeDocumentationAwareCommenter) {
      final CodeDocumentationAwareCommenter docCommenter = (CodeDocumentationAwareCommenter)commenter;
      if (docCommenter.getDocumentationCommentLinePrefix() != null) {
        return true;
      }
    }
  }
  return false;
}
 
Example 5
Project: intellij-ce-playground   File: ChooseByNameLanguageFilter.java   Source Code and License Vote up 5 votes
@NotNull
@Override
protected Collection<Language> getAllFilterValues() {
  final Collection<Language> registeredLanguages = Language.getRegisteredLanguages();
  List<Language> accepted = new ArrayList<Language>();
  for (Language language : registeredLanguages) {
    if (language != Language.ANY && !(language instanceof DependentLanguage)) {
      accepted.add(language);
    }
  }
  Collections.sort(accepted, LanguageUtil.LANGUAGE_COMPARATOR);
  return accepted;
}
 
Example 6
Project: intellij-ce-playground   File: BasePlatformRefactoringAction.java   Source Code and License Vote up 5 votes
private boolean calcHidden() {
  for(Language l: Language.getRegisteredLanguages()) {
    if (isAvailableForLanguage(l)) {
      return false;
    }
  }
  return true;
}
 
Example 7
Project: intellij-ce-playground   File: InjectedLanguage.java   Source Code and License Vote up 5 votes
private static void initLanguageCache() {
  ourLanguageCache = new HashMap<String, Language>();

  Collection<Language> registeredLanguages;
  do {
    registeredLanguages = new ArrayList<Language>(Language.getRegisteredLanguages());
    for (Language language : registeredLanguages) {
      if (LanguageUtil.isInjectableLanguage(language)) {
        ourLanguageCache.put(language.getID(), language);
      }
    }
  } while (Language.getRegisteredLanguages().size() != registeredLanguages.size());

  ourLanguageCount = registeredLanguages.size();
}