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

The following examples show how to use com.intellij.lang.Language#getRegisteredLanguages() . These examples are extracted from open source projects. 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 Project: consulo   File: RemoteFileUtil.java    License: Apache License 2.0 6 votes vote down vote up
@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.length() == 0) 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
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 3
@Nonnull
@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 4
private boolean calcHidden() {
  for(Language l: Language.getRegisteredLanguages()) {
    if (isAvailableForLanguage(l)) {
      return false;
    }
  }
  return true;
}