@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);
    }
  }
  public static String checkMethodReferenceContext(
      PsiMethodReferenceExpression methodRef, PsiElement resolve, PsiType functionalInterfaceType) {
    final PsiClass containingClass =
        resolve instanceof PsiMethod
            ? ((PsiMethod) resolve).getContainingClass()
            : (PsiClass) resolve;
    final boolean isStaticSelector = isStaticallyReferenced(methodRef);
    final PsiElement qualifier = methodRef.getQualifier();

    boolean isMethodStatic = false;
    boolean receiverReferenced = false;
    boolean isConstructor = true;

    if (resolve instanceof PsiMethod) {
      final PsiMethod method = (PsiMethod) resolve;

      isMethodStatic = method.hasModifierProperty(PsiModifier.STATIC);
      isConstructor = method.isConstructor();
      receiverReferenced = hasReceiver(methodRef, method, functionalInterfaceType);

      if (method.hasModifierProperty(PsiModifier.ABSTRACT)
          && qualifier instanceof PsiSuperExpression) {
        return "Abstract method '" + method.getName() + "' cannot be accessed directly";
      }
    }

    if (!receiverReferenced && isStaticSelector && !isMethodStatic && !isConstructor) {
      return "Non-static method cannot be referenced from a static context";
    }

    if (!receiverReferenced && !isStaticSelector && isMethodStatic) {
      return "Static method referenced through non-static qualifier";
    }

    if (receiverReferenced && isStaticSelector && isMethodStatic && !isConstructor) {
      return "Static method referenced through receiver";
    }

    if (isMethodStatic && isStaticSelector && qualifier instanceof PsiTypeElement) {
      final PsiJavaCodeReferenceElement referenceElement =
          PsiTreeUtil.getChildOfType(qualifier, PsiJavaCodeReferenceElement.class);
      if (referenceElement != null) {
        final PsiReferenceParameterList parameterList = referenceElement.getParameterList();
        if (parameterList != null && parameterList.getTypeArguments().length > 0) {
          return "Parameterized qualifier on static method reference";
        }
      }
    }

    if (isConstructor) {
      if (containingClass != null
          && PsiUtil.isInnerClass(containingClass)
          && containingClass.isPhysical()) {
        PsiClass outerClass = containingClass.getContainingClass();
        if (outerClass != null
            && !InheritanceUtil.hasEnclosingInstanceInScope(outerClass, methodRef, true, false)) {
          return "An enclosing instance of type "
              + PsiFormatUtil.formatClass(outerClass, PsiFormatUtilBase.SHOW_NAME)
              + " is not in scope";
        }
      }
    }
    return null;
  }