private static @NotNull HighlightVisitor @NotNull [] cloneAndFilterHighlightVisitors(@NotNull PsiFile psiFile, @Nullable TextAttributesScheme colorsScheme) {
    Project project = psiFile.getProject();
    HighlightVisitor[] visitors = HighlightVisitor.EP_HIGHLIGHT_VISITOR.getExtensions(project);
    DumbService dumbService = DumbService.getInstance(project);
    int o = 0;
    HighlightVisitor[] clones = new HighlightVisitor[visitors.length];
    for (HighlightVisitor visitor : visitors) {
      if (!dumbService.isUsableInCurrentContext(visitor)) {
        continue;
      }
      if (visitor instanceof RainbowVisitor
          && !RainbowHighlighter.isRainbowEnabledWithInheritance(colorsScheme, psiFile.getLanguage())) {
        continue;
      }
      if (visitor.suitableForFile(psiFile)) {
        HighlightVisitor cloned;
        // clone highlight visitor because
        // 1) HighlightVisitor API is non-reentrant (with its weird analyze() method which inits a bunch of instance fields inside) and
        // 2) the old visitor instance might still be running, albeit in the canceled state.
        // we could cling to the "do not clone visitor if there's only one instance is running" optimization, but it would require complex RCU readers-style machinery which would track the complete finish of the visitor before reusing it,
        // or we can just clone the visitor, which is not expensive, given that all overrides are just a single new() call.
        cloned = visitor.clone();
        assert cloned.getClass() == visitor.getClass() : visitor.getClass()+".clone() must return a copy of "+visitor.getClass()+"; but got: "+cloned+" ("+cloned.getClass()+")";
        clones[o++] = cloned;
      }
    }
    if (o == 0) {
      GeneralHighlightingPass.LOG.error("No visitors registered. all visitors:" + Arrays.toString(visitors));
    }
    return ArrayUtil.realloc(clones, o, HighlightVisitor.ARRAY_FACTORY);
  }
private static @NotNull HighlightVisitor @NotNull [] cloneAndFilterHighlightVisitors(@NotNull PsiFile psiFile, @Nullable TextAttributesScheme colorsScheme)