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

The following examples show how to use com.intellij.lang.Language#getRegisteredLanguages() . 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: RemoteFileUtil.java    From consulo with 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
Source File: EditorSmartKeysConfigurable.java    From consulo with Apache License 2.0 5 votes vote down vote up
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
Source File: ChooseByNameLanguageFilter.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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
Source File: BasePlatformRefactoringAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
private boolean calcHidden() {
  for(Language l: Language.getRegisteredLanguages()) {
    if (isAvailableForLanguage(l)) {
      return false;
    }
  }
  return true;
}