Skip to content

Commit a8bbc0e

Browse files
authored
Merge pull request #12838 from dos65/sbt_bridge_implement_range_position_methods
[Bridge] Position - implement methods for accesing range
2 parents e7f6a81 + 968f0fc commit a8bbc0e

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

sbt-bridge/src/dotty/tools/xsbt/PositionBridge.java

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,53 @@ public Optional<String> pointerSpace() {
125125
public String toString() {
126126
return pos.toString();
127127
}
128+
129+
@Override
130+
public Optional<Integer> startOffset() {
131+
if (src.content().length == 0)
132+
return Optional.empty();
133+
else
134+
return Optional.of(pos.start());
135+
}
136+
137+
@Override
138+
public Optional<Integer> endOffset() {
139+
if (src.content().length == 0)
140+
return Optional.empty();
141+
else
142+
return Optional.of(pos.end());
143+
}
144+
145+
@Override
146+
public Optional<Integer> startLine() {
147+
if (src.content().length == 0)
148+
return Optional.empty();
149+
else
150+
return Optional.of(pos.startLine() + 1);
151+
}
152+
153+
@Override
154+
public Optional<Integer> endLine() {
155+
if (src.content().length == 0)
156+
return Optional.empty();
157+
else
158+
return Optional.of(pos.endLine() + 1);
159+
}
160+
161+
@Override
162+
public Optional<Integer> startColumn() {
163+
if (src.content().length == 0)
164+
return Optional.empty();
165+
else
166+
return Optional.of(pos.startColumn());
167+
}
168+
169+
@Override
170+
public Optional<Integer> endColumn() {
171+
if (src.content().length == 0)
172+
return Optional.empty();
173+
else
174+
return Optional.of(pos.endColumn());
175+
}
176+
128177
}

0 commit comments

Comments
 (0)