private boolean customize(Object value) {
   final Object userObject = ((DefaultMutableTreeNode) value).getUserObject();
   if (!(userObject instanceof TreeElementWrapper)) {
     return false;
   }
   final TreeElement treeElement = ((TreeElementWrapper) userObject).getValue();
   if (treeElement == null) {
     return false;
   }
   final ItemPresentation presentation = treeElement.getPresentation();
   if (presentation instanceof TextAttributesPresentation) {
     final TextAttributesPresentation textAttributesPresentation =
         (TextAttributesPresentation) presentation;
     final String text = textAttributesPresentation.getPresentableText();
     if (text != null) {
       final SimpleTextAttributes attr =
           SimpleTextAttributes.fromTextAttributes(
               textAttributesPresentation.getTextAttributes(getColorsScheme()));
       append(
           text,
           new SimpleTextAttributes(
               attr.getBgColor(),
               attr.getFgColor(),
               attr.getWaveColor(),
               attr.getStyle() | SimpleTextAttributes.STYLE_OPAQUE));
       return true;
     }
   }
   return false;
 }
 public static SimpleTextAttributes patchAttr(
     InspectionTreeNode node, SimpleTextAttributes attributes) {
   if (node.isResolved()) {
     return new SimpleTextAttributes(
         attributes.getBgColor(),
         attributes.getFgColor(),
         attributes.getWaveColor(),
         attributes.getStyle() | SimpleTextAttributes.STYLE_STRIKEOUT);
   }
   return attributes;
 }
  void update() {
    clear();

    setIcon(myIcon);

    final boolean focused = isFocusedOrPopupElement();
    final boolean selected = isSelected();

    setFocusBorderAroundIcon(false);
    setBackground(myUI.getBackground(selected, focused));

    Color fg = myUI.getForeground(selected, focused, isInactive());
    if (fg == null) fg = myAttributes.getFgColor();

    final Color bg = getBackground();
    append(
        myText,
        new SimpleTextAttributes(bg, fg, myAttributes.getWaveColor(), myAttributes.getStyle()));

    // repaint();
  }
    private static SimpleTextAttributes getMainForegroundAttributes(InspectionTreeNode node) {
      SimpleTextAttributes foreground = SimpleTextAttributes.REGULAR_ATTRIBUTES;
      if (node instanceof RefElementNode) {
        RefEntity refElement = ((RefElementNode) node).getElement();

        if (refElement instanceof RefElement) {
          refElement = ((RefElement) refElement).getContainingEntry();
          if (((RefElement) refElement).isEntry() && ((RefElement) refElement).isPermanentEntry()) {
            foreground = new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, JBColor.blue);
          }
        }
      }
      final FileStatus nodeStatus = node.getNodeStatus();
      if (nodeStatus != FileStatus.NOT_CHANGED) {
        foreground =
            new SimpleTextAttributes(
                foreground.getBgColor(),
                nodeStatus.getColor(),
                foreground.getWaveColor(),
                foreground.getStyle());
      }
      return foreground;
    }
  @Override
  public void customizeCellRendererFor(@NotNull SliceUsage sliceUsage) {
    boolean isForcedLeaf = sliceUsage instanceof JavaSliceDereferenceUsage;
    // might come SliceTooComplexDFAUsage
    JavaSliceUsage javaSliceUsage =
        sliceUsage instanceof JavaSliceUsage ? (JavaSliceUsage) sliceUsage : null;

    TextChunk[] text = sliceUsage.getText();
    final List<TextRange> usageRanges = new SmartList<TextRange>();
    sliceUsage.processRangeMarkers(
        new Processor<Segment>() {
          @Override
          public boolean process(Segment segment) {
            usageRanges.add(TextRange.create(segment));
            return true;
          }
        });
    boolean isInsideContainer = javaSliceUsage != null && javaSliceUsage.indexNesting != 0;
    for (int i = 0, length = text.length; i < length; i++) {
      TextChunk textChunk = text[i];
      SimpleTextAttributes attributes = textChunk.getSimpleAttributesIgnoreBackground();
      if (isForcedLeaf) {
        attributes =
            attributes.derive(
                attributes.getStyle(),
                JBColor.LIGHT_GRAY,
                attributes.getBgColor(),
                attributes.getWaveColor());
      }
      boolean inUsage = (attributes.getFontStyle() & Font.BOLD) != 0;
      if (isInsideContainer && inUsage) {
        // Color darker = Color.BLACK;//attributes.getBgColor() == null ? Color.BLACK :
        // attributes.getBgColor().darker();
        // attributes = attributes.derive(SimpleTextAttributes.STYLE_OPAQUE,
        // attributes.getFgColor(), UIUtil.getTreeBackground().brighter(),
        // attributes.getWaveColor());
        // setMyBorder(IdeBorderFactory.createRoundedBorder(10, 3));
        // setPaintFocusBorder(true);
      }
      append(textChunk.getText(), attributes);
      if (i == 0) {
        append(FontUtil.spaceAndThinSpace());
      }
    }

    if (javaSliceUsage != null) {
      for (int i = 0; i < javaSliceUsage.indexNesting; i++) {
        append(
            " (Tracking container contents"
                + (javaSliceUsage.syntheticField.isEmpty()
                    ? ""
                    : " '" + javaSliceUsage.syntheticField + "'")
                + ")",
            SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
      }
    }

    PsiElement element = sliceUsage.getElement();
    PsiMethod method;
    PsiClass aClass;
    while (true) {
      method = PsiTreeUtil.getParentOfType(element, PsiMethod.class);
      aClass =
          method == null
              ? PsiTreeUtil.getParentOfType(element, PsiClass.class)
              : method.getContainingClass();
      if (aClass instanceof PsiAnonymousClass) {
        element = aClass;
      } else {
        break;
      }
    }
    int methodOptions =
        PsiFormatUtilBase.SHOW_NAME
            | PsiFormatUtilBase.SHOW_PARAMETERS
            | PsiFormatUtilBase.SHOW_CONTAINING_CLASS;
    String location =
        method != null
            ? PsiFormatUtil.formatMethod(
                method, PsiSubstitutor.EMPTY, methodOptions, PsiFormatUtilBase.SHOW_TYPE, 2)
            : aClass != null
                ? PsiFormatUtil.formatClass(aClass, PsiFormatUtilBase.SHOW_NAME)
                : null;
    if (location != null) {
      SimpleTextAttributes attributes = SimpleTextAttributes.GRAY_ATTRIBUTES;
      append(" in " + location, attributes);
    }
  }