Class Span
java.lang.Object
com.jozufozu.flywheel.core.source.span.Span
- All Implemented Interfaces:
CharSequence
- Direct Known Subclasses:
ErrorSpan,StringSpan
A segment of code in a
SourceFile.
Spans are used for pretty-printing errors.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSpan(SourceFile in, int start, int end) Span(SourceFile in, CharPos start, CharPos end) -
Method Summary
Modifier and TypeMethodDescriptioncharcharAt(int index) intstatic SpanfromMatcher(SourceFile src, Matcher m) static SpanfromMatcher(SourceFile src, Matcher m, int group) static SpanfromMatcher(Span superSpan, Matcher m) static SpanfromMatcher(Span superSpan, Matcher m, int group) abstract Stringget()getEnd()intgetStart()intbooleanisEmpty()abstract booleanisErr()intlength()intlines()subSequence(int start, int end) abstract SpansubSpan(int from, int to) Get a span referring to a code segment inside this code segment.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.CharSequence
chars, codePoints
-
Field Details
-
in
-
start
-
end
-
-
Constructor Details
-
Span
-
Span
-
-
Method Details
-
getSourceFile
- Returns:
- The file that contains this code segment.
-
getStart
-
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:
isEmptyin interfaceCharSequence- Returns:
- true if this span has no width.
-
lines
public int lines()- Returns:
- how many lines this span spans.
-
firstLine
public int firstLine() -
subSpan
Get a span referring to a code segment inside this code segment. -
get
- Returns:
- the portion of code represented by this span.
-
isErr
public abstract boolean isErr() -
length
public int length()- Specified by:
lengthin interfaceCharSequence
-
charAt
public char charAt(int index) - Specified by:
charAtin interfaceCharSequence
-
subSequence
- Specified by:
subSequencein interfaceCharSequence
-
toString
- Specified by:
toStringin interfaceCharSequence- Overrides:
toStringin classObject
-
fromMatcher
-
fromMatcher
-
fromMatcher
-
fromMatcher
-