Skip to content
This repository was archived by the owner on Jun 10, 2020. It is now read-only.

xsbti.Position: add startOffset and endOffset #173

Merged
merged 3 commits into from
Aug 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions internal/util-interface/src/main/java/xsbti/Position.java
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }
}
46 changes: 44 additions & 2 deletions internal/util-logging/src/main/scala/sbt/util/InterfaceUtil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ object InterfaceUtil {
case None => Optional.empty[A]()
}

// Overload to preserve binary compatibility
def position(
line0: Option[Integer],
content: String,
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.2.0
sbt.version=1.2.1