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.
  • Method Details

    • 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.
    • 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.