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

Commit 05cecc3

Browse files
authored
Merge pull request #173 from smarter/position-range
xsbti.Position: add startOffset and endOffset
2 parents 6a9c7c9 + 5e3a102 commit 05cecc3

File tree

4 files changed

+55
-3
lines changed

4 files changed

+55
-3
lines changed

build.sbt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ lazy val utilLogging = (project in internalPath / "util-logging")
124124
exclude[DirectMissingMethodProblem]("sbt.internal.util.SuccessEvent.copy*"),
125125
exclude[DirectMissingMethodProblem]("sbt.internal.util.TraceEvent.copy*"),
126126
exclude[DirectMissingMethodProblem]("sbt.internal.util.StringEvent.copy*"),
127+
// Private final class constructor changed
128+
exclude[DirectMissingMethodProblem]("sbt.util.InterfaceUtil#ConcretePosition.this"),
127129
),
128130
)
129131
.configure(addSbtIO)

internal/util-interface/src/main/java/xsbti/Position.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,12 @@ public interface Position
1818

1919
Optional<String> sourcePath();
2020
Optional<File> sourceFile();
21+
22+
// Default values to avoid breaking binary compatibility
23+
default Optional<Integer> startOffset() { return Optional.empty(); }
24+
default Optional<Integer> endOffset() { return Optional.empty(); }
25+
default Optional<Integer> startLine() { return Optional.empty(); }
26+
default Optional<Integer> startColumn() { return Optional.empty(); }
27+
default Optional<Integer> endLine() { return Optional.empty(); }
28+
default Optional<Integer> endColumn() { return Optional.empty(); }
2129
}

internal/util-logging/src/main/scala/sbt/util/InterfaceUtil.scala

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ object InterfaceUtil {
3636
case None => Optional.empty[A]()
3737
}
3838

39+
// Overload to preserve binary compatibility
3940
def position(
4041
line0: Option[Integer],
4142
content: String,
@@ -45,7 +46,36 @@ object InterfaceUtil {
4546
sourcePath0: Option[String],
4647
sourceFile0: Option[File]
4748
): Position =
48-
new ConcretePosition(line0, content, offset0, pointer0, pointerSpace0, sourcePath0, sourceFile0)
49+
position(line0, content, offset0, pointer0, pointerSpace0, sourcePath0, sourceFile0, None, None, None, None, None, None)
50+
51+
def position(
52+
line0: Option[Integer],
53+
content: String,
54+
offset0: Option[Integer],
55+
pointer0: Option[Integer],
56+
pointerSpace0: Option[String],
57+
sourcePath0: Option[String],
58+
sourceFile0: Option[File],
59+
startOffset0: Option[Integer],
60+
endOffset0: Option[Integer],
61+
startLine0: Option[Integer],
62+
startColumn0: Option[Integer],
63+
endLine0: Option[Integer],
64+
endColumn0: Option[Integer]
65+
): Position =
66+
new ConcretePosition(line0,
67+
content,
68+
offset0,
69+
pointer0,
70+
pointerSpace0,
71+
sourcePath0,
72+
sourceFile0,
73+
startOffset0,
74+
endOffset0,
75+
startLine0,
76+
startColumn0,
77+
endLine0,
78+
endColumn0)
4979

5080
def problem(cat: String, pos: Position, msg: String, sev: Severity): Problem =
5181
new ConcreteProblem(cat, pos, msg, sev)
@@ -75,7 +105,13 @@ object InterfaceUtil {
75105
pointer0: Option[Integer],
76106
pointerSpace0: Option[String],
77107
sourcePath0: Option[String],
78-
sourceFile0: Option[File]
108+
sourceFile0: Option[File],
109+
startOffset0: Option[Integer],
110+
endOffset0: Option[Integer],
111+
startLine0: Option[Integer],
112+
startColumn0: Option[Integer],
113+
endLine0: Option[Integer],
114+
endColumn0: Option[Integer]
79115
) extends Position {
80116
val line = o2jo(line0)
81117
val lineContent = content
@@ -84,6 +120,12 @@ object InterfaceUtil {
84120
val pointerSpace = o2jo(pointerSpace0)
85121
val sourcePath = o2jo(sourcePath0)
86122
val sourceFile = o2jo(sourceFile0)
123+
override val startOffset = o2jo(startOffset0)
124+
override val endOffset = o2jo(endOffset0)
125+
override val startLine = o2jo(startLine0)
126+
override val startColumn = o2jo(startColumn0)
127+
override val endLine = o2jo(endLine0)
128+
override val endColumn = o2jo(endColumn0)
87129
}
88130

89131
private final class ConcreteProblem(

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.2.0
1+
sbt.version=1.2.1

0 commit comments

Comments
 (0)