private RangeHighlighter getSegmentHighlighter(int segmentNumber, @Nullable Variable var, boolean isSelected, boolean isEnd) {
    boolean newStyle = Registry.is("live.templates.highlight.all.variables");
    boolean mightStop = mightStopAtVariable(var, segmentNumber);
    TextAttributesKey attributesKey = isEnd ? null :
                                      isSelected ? EditorColors.LIVE_TEMPLATE_ATTRIBUTES :
                                      newStyle && mightStop ? EditorColors.LIVE_TEMPLATE_INACTIVE_SEGMENT :
                                      null;

    int start = getSegments().getSegmentStart(segmentNumber);
    int end = getSegments().getSegmentEnd(segmentNumber);
    MarkupModelEx markupModel = (MarkupModelEx)getEditor().getMarkupModel();
    return markupModel.addRangeHighlighterAndChangeAttributes(attributesKey, start, end, HighlighterLayer.ELEMENT_UNDER_CARET - 1,
                                                              HighlighterTargetArea.EXACT_RANGE, false, segmentHighlighter -> {
        segmentHighlighter.setGreedyToLeft(true);
        segmentHighlighter.setGreedyToRight(true);

        EditorColorsScheme scheme = getEditor().getColorsScheme();
        TextAttributes attributes = segmentHighlighter.getTextAttributes(scheme);
        if (attributes != null && attributes.getEffectType() == EffectType.BOXED && newStyle) {
          TextAttributes clone = attributes.clone();
          clone.setEffectType(EffectType.SLIGHTLY_WIDER_BOX);
          clone.setBackgroundColor(scheme.getDefaultBackground());
          segmentHighlighter.setTextAttributes(clone);
        }
        EditorActionAvailabilityHintKt.addActionAvailabilityHint(segmentHighlighter,
                                                                 new EditorActionAvailabilityHint("NextTemplateVariable", EditorActionAvailabilityHint.AvailabilityCondition.CaretInside),
                                                                 new EditorActionAvailabilityHint("PreviousTemplateVariable", EditorActionAvailabilityHint.AvailabilityCondition.CaretInside),
                                                                 new EditorActionAvailabilityHint("EditorEscape", EditorActionAvailabilityHint.AvailabilityCondition.CaretInside));
        segmentHighlighter.putUserData(TEMPLATE_RANGE_HIGHLIGHTER_KEY, mightStop);
      });
  }
private RangeHighlighter getSegmentHighlighter(int segmentNumber, @Nullable Variable var, boolean isSelected, boolean isEnd)