Merge pull request #173 from smarter/position-range

xsbti.Position: add startOffset and endOffset
This commit is contained in:
eugene yokota 2018-08-16 16:25:11 -04:00 committed by GitHub
commit 05cecc378c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 55 additions and 3 deletions

View File

@ -124,6 +124,8 @@ lazy val utilLogging = (project in internalPath / "util-logging")
exclude[DirectMissingMethodProblem]("sbt.internal.util.SuccessEvent.copy*"),
exclude[DirectMissingMethodProblem]("sbt.internal.util.TraceEvent.copy*"),
exclude[DirectMissingMethodProblem]("sbt.internal.util.StringEvent.copy*"),
// Private final class constructor changed
exclude[DirectMissingMethodProblem]("sbt.util.InterfaceUtil#ConcretePosition.this"),
),
)
.configure(addSbtIO)

View File

@ -18,4 +18,12 @@ public interface Position
Optional<String> sourcePath();
Optional<File> sourceFile();
// Default values to avoid breaking binary compatibility
default Optional<Integer> startOffset() { return Optional.empty(); }
default Optional<Integer> endOffset() { return Optional.empty(); }
default Optional<Integer> startLine() { return Optional.empty(); }
default Optional<Integer> startColumn() { return Optional.empty(); }
default Optional<Integer> endLine() { return Optional.empty(); }
default Optional<Integer> endColumn() { return Optional.empty(); }
}

View File

@ -36,6 +36,7 @@ object InterfaceUtil {
case None => Optional.empty[A]()
}
// Overload to preserve binary compatibility
def position(
line0: Option[Integer],
content: String,
@ -45,7 +46,36 @@ object InterfaceUtil {
sourcePath0: Option[String],
sourceFile0: Option[File]
): Position =
new ConcretePosition(line0, content, offset0, pointer0, pointerSpace0, sourcePath0, sourceFile0)
position(line0, content, offset0, pointer0, pointerSpace0, sourcePath0, sourceFile0, None, None, None, None, None, None)
def position(
line0: Option[Integer],
content: String,
offset0: Option[Integer],
pointer0: Option[Integer],
pointerSpace0: Option[String],
sourcePath0: Option[String],
sourceFile0: Option[File],
startOffset0: Option[Integer],
endOffset0: Option[Integer],
startLine0: Option[Integer],
startColumn0: Option[Integer],
endLine0: Option[Integer],
endColumn0: Option[Integer]
): Position =
new ConcretePosition(line0,
content,
offset0,
pointer0,
pointerSpace0,
sourcePath0,
sourceFile0,
startOffset0,
endOffset0,
startLine0,
startColumn0,
endLine0,
endColumn0)
def problem(cat: String, pos: Position, msg: String, sev: Severity): Problem =
new ConcreteProblem(cat, pos, msg, sev)
@ -75,7 +105,13 @@ object InterfaceUtil {
pointer0: Option[Integer],
pointerSpace0: Option[String],
sourcePath0: Option[String],
sourceFile0: Option[File]
sourceFile0: Option[File],
startOffset0: Option[Integer],
endOffset0: Option[Integer],
startLine0: Option[Integer],
startColumn0: Option[Integer],
endLine0: Option[Integer],
endColumn0: Option[Integer]
) extends Position {
val line = o2jo(line0)
val lineContent = content
@ -84,6 +120,12 @@ object InterfaceUtil {
val pointerSpace = o2jo(pointerSpace0)
val sourcePath = o2jo(sourcePath0)
val sourceFile = o2jo(sourceFile0)
override val startOffset = o2jo(startOffset0)
override val endOffset = o2jo(endOffset0)
override val startLine = o2jo(startLine0)
override val startColumn = o2jo(startColumn0)
override val endLine = o2jo(endLine0)
override val endColumn = o2jo(endColumn0)
}
private final class ConcreteProblem(

View File

@ -1 +1 @@
sbt.version=1.2.0
sbt.version=1.2.1