java.lang.Object
com.jozufozu.flywheel.core.source.span.Span
All Implemented Interfaces:
CharSequence
Direct Known Subclasses:
ErrorSpan, StringSpan

public abstract class Span extends Object implements CharSequence
A segment of code in a SourceFile.

Spans are used for pretty-printing errors.

  • Field Details

  • Constructor Details

  • Method Details

    • getSourceFile

      public SourceFile getSourceFile()
      Returns:
      The file that contains this code segment.
    • getStart

      public CharPos getStart()
    • getEnd

      public CharPos getEnd()
    • getStartPos

      public int getStartPos()
      Returns:
      the string index at the (inclusive) beginning of this code segment.
    • getEndPos

      public int getEndPos()
      Returns:
      the string index at the (exclusive) end of this code segment.
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface CharSequence
      Returns:
      true if this span has no width.
    • lines

      public int lines()
      Returns:
      how many lines this span spans.
    • firstLine

      public int firstLine()
    • subSpan

      public abstract Span subSpan(int from, int to)
      Get a span referring to a code segment inside this code segment.
    • get

      public abstract String get()
      Returns:
      the portion of code represented by this span.
    • isErr

      public abstract boolean isErr()
    • length

      public int length()
      Specified by:
      length in interface CharSequence
    • charAt

      public char charAt(int index)
      Specified by:
      charAt in interface CharSequence
    • subSequence

      public CharSequence subSequence(int start, int end)
      Specified by:
      subSequence in interface CharSequence
    • toString

      public String toString()
      Specified by:
      toString in interface CharSequence
      Overrides:
      toString in class Object
    • fromMatcher

      public static Span fromMatcher(SourceFile src, Matcher m, int group)
    • fromMatcher

      public static Span fromMatcher(Span superSpan, Matcher m, int group)
    • fromMatcher

      public static Span fromMatcher(SourceFile src, Matcher m)
    • fromMatcher

      public static Span fromMatcher(Span superSpan, Matcher m)