Class UnifiedDiffText

java.lang.Object
org.eclipse.compare.unifieddiff.internal.UnifiedDiffText

public final class UnifiedDiffText extends Object
Side-effect free text and style-range helpers used to lay out the unified diff code minings.
  • Field Details

    • BORDER_SCALE

      public static final double BORDER_SCALE
      Border color scale; matches TextMergeViewer's normal color.
      See Also:
    • FILL_SCALE

      public static final double FILL_SCALE
      Fill band color scale.
      See Also:
  • Method Details

    • borderColor

      public static RGB borderColor(RGB diffColor, RGB background)
      Border color of an addition/deletion hunk; darker than the fill band.
    • interpolate

      public static RGB interpolate(RGB fg, RGB bg, double scale)
      Linearly interpolates between fg and bg: scale 0 returns fg, scale 1 returns bg.
    • countLines

      public static int countLines(String str)
      Returns the number of lines of the given string, counting a trailing line delimiter as starting a new (empty) line. An empty string is one line.
    • countLines

      public static int countLines(String str, int end)
      Returns the number of lines of the first end characters of the given string, like countLines(String) on that prefix.
    • removeTrailingNewLines

      public static String removeTrailingNewLines(String str)
    • removeLeadingNewLines

      public static String removeLeadingNewLines(String str)
    • replaceTabWithSpaces

      public static String replaceTabWithSpaces(String str, int tabWidth)
      Expands every tab into tabWidth spaces. GC#stringExtent does not account for tabs, so widths are always measured on the expanded string.
    • mapOffsetToTabExpanded

      public static int mapOffsetToTabExpanded(String originalStr, int offset, int tabWidth)
      Maps an offset in originalStr to the corresponding offset in replaceTabWithSpaces(String, int) of the same string.
    • mergeStyleRanges

      public static List<StyleRange> mergeStyleRanges(List<StyleRange> backgrounds, List<StyleRange> foregrounds)
      Overlays the detailed-diff background ranges onto the syntax coloring ranges. Both lists must be sorted by offset and must not overlap within themselves. The returned ranges keep the foreground styling and cover exactly the extent of foregrounds.
    • clampDetailedDiffLength

      public static int clampDetailedDiffLength(int start, int length, int trimmedEnd)
      Clamps length so that start + length does not exceed trimmedEnd. Returns the clamped length, or <= 0 when the range falls entirely outside.