Class SourceLines

java.lang.Object
org.ek9lang.compiler.repair.SourceLines

final class SourceLines extends Object
Line-level helpers the text rules share: indentation, a line with its literals masked out, the top-level comma split. Package-private on purpose - a rule outside this package uses SourceRepairs.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) static final char
    What a masked character inside a String, backtick String or character literal is replaced by.
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) static int
    indent(String line)
    The number of leading spaces of line.
    (package private) static String
    join(List<String> lines)
     
    (package private) static String
    masked(String line)
    line with the content of every String, backtick String and character literal replaced by MASK, and a trailing // comment likewise - same length, so an index found in the mask is an index in the line.
    (package private) static int
    nextContent(List<String> lines, int index)
    The index of the nearest line after index with content, or -1.
    (package private) static int
    previousContent(List<String> lines, int index)
    The index of the nearest line before index with content, or -1.
    (package private) static String
    quoted(String line)
    line quoted for a note, stripped.
    (package private) static List<String>
    split(String text)
    text split into lines, keeping a trailing empty line (so a join gives the text back).
    (package private) static List<String>
    The parts of text between its top-level commas - a comma inside brackets or a literal does not split - each stripped.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MASK

      static final char MASK
      What a masked character inside a String, backtick String or character literal is replaced by.
      See Also:
  • Method Details

    • split

      static List<String> split(String text)
      text split into lines, keeping a trailing empty line (so a join gives the text back).
    • join

      static String join(List<String> lines)
    • indent

      static int indent(String line)
      The number of leading spaces of line.
    • masked

      static String masked(String line)
      line with the content of every String, backtick String and character literal replaced by MASK, and a trailing // comment likewise - same length, so an index found in the mask is an index in the line. A rule searching for code (&&, a comma, /*) searches the mask, so it never rewrites text inside a literal.
    • topLevelParts

      static List<String> topLevelParts(String text)
      The parts of text between its top-level commas - a comma inside brackets or a literal does not split - each stripped. One part when there is no such comma.
    • previousContent

      static int previousContent(List<String> lines, int index)
      The index of the nearest line before index with content, or -1.
    • nextContent

      static int nextContent(List<String> lines, int index)
      The index of the nearest line after index with content, or -1.
    • quoted

      static String quoted(String line)
      line quoted for a note, stripped.