private static Language calcBaseLanguage(@NotNull VirtualFile file, @NotNull Project project) {
    if (file instanceof LightVirtualFile) {
      final Language language = ((LightVirtualFile) file).getLanguage();
      if (language != null) {
        return language;
      }
    }

    FileType fileType = file.getFileType();
    // Do not load content
    if (fileType == UnknownFileType.INSTANCE) {
      fileType = FileTypeRegistry.getInstance().detectFileTypeFromContent(file);
    }
    if (fileType.isBinary()) return Language.ANY;
    if (isTooLarge(file)) return PlainTextLanguage.INSTANCE;

    if (fileType instanceof LanguageFileType) {
      return LanguageSubstitutors.INSTANCE.substituteLanguage(
          ((LanguageFileType) fileType).getLanguage(), file, project);
    }

    final ContentBasedFileSubstitutor[] processors =
        Extensions.getExtensions(ContentBasedFileSubstitutor.EP_NAME);
    for (ContentBasedFileSubstitutor processor : processors) {
      Language language = processor.obtainLanguageForFile(file);
      if (language != null) return language;
    }

    return PlainTextLanguage.INSTANCE;
  }
  @NotNull
  @Override
  public EditorHighlighter createEditorHighlighter(
      @NotNull VirtualFile vFile, @NotNull EditorColorsScheme settings, @Nullable Project project) {
    FileType fileType = vFile.getFileType();
    if (fileType instanceof LanguageFileType) {
      LanguageFileType substFileType =
          substituteFileType(((LanguageFileType) fileType).getLanguage(), vFile, project);
      if (substFileType != null) {
        EditorHighlighterProvider provider =
            FileTypeEditorHighlighterProviders.INSTANCE.forFileType(substFileType);
        EditorHighlighter editorHighlighter =
            provider.getEditorHighlighter(project, fileType, vFile, settings);
        boolean isPlain =
            editorHighlighter.getClass() == LexerEditorHighlighter.class
                && ((LexerEditorHighlighter) editorHighlighter).isPlain();
        if (!isPlain) {
          return editorHighlighter;
        }
      }
      try {
        return FileTypeEditorHighlighterProviders.INSTANCE
            .forFileType(fileType)
            .getEditorHighlighter(project, fileType, vFile, settings);
      } catch (ProcessCanceledException e) {
        throw e;
      } catch (Exception e) {
        LOG.error(e);
      }
    }

    SyntaxHighlighter highlighter = null;
    for (ContentBasedFileSubstitutor processor :
        Extensions.getExtensions(ContentBasedFileSubstitutor.EP_NAME)) {
      boolean applicable;
      try {
        applicable = processor.isApplicable(project, vFile);
      } catch (Exception e) {
        LOG.error(e);
        continue;
      }
      if (applicable && processor instanceof ContentBasedClassFileProcessor) {
        highlighter =
            ((ContentBasedClassFileProcessor) processor).createHighlighter(project, vFile);
      }
    }
    if (highlighter == null) {
      highlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(fileType, project, vFile);
    }
    return createEditorHighlighter(highlighter, settings);
  }