@@ -108,7 +108,7 @@ public Optional<Integer> getLocationOffset(int line, int column) {
108108 * Get the line and column in the source expression text for the given code point {@code offset}.
109109 */
110110 public Optional <CelSourceLocation > getOffsetLocation (int offset ) {
111- return getOffsetLocationImpl ( lineOffsets , offset );
111+ return CelSourceHelper . getOffsetLocation ( codePoints , offset );
112112 }
113113
114114 @ Override
@@ -134,30 +134,6 @@ private static Optional<Integer> getLocationOffsetImpl(
134134 return Optional .of (offset + column );
135135 }
136136
137- /**
138- * Get the line and column in the source expression text for the given code point {@code offset}.
139- */
140- public static Optional <CelSourceLocation > getOffsetLocationImpl (
141- List <Integer > lineOffsets , int offset ) {
142- checkArgument (offset >= 0 );
143- LineAndOffset lineAndOffset = findLine (lineOffsets , offset );
144- return Optional .of (CelSourceLocation .of (lineAndOffset .line , offset - lineAndOffset .offset ));
145- }
146-
147- private static LineAndOffset findLine (List <Integer > lineOffsets , int offset ) {
148- int line = 1 ;
149- for (int index = 0 ; index < lineOffsets .size (); index ++) {
150- if (lineOffsets .get (index ) > offset ) {
151- break ;
152- }
153- line ++;
154- }
155- if (line == 1 ) {
156- return new LineAndOffset (line , 0 );
157- }
158- return new LineAndOffset (line , lineOffsets .get (line - 2 ));
159- }
160-
161137 public Builder toBuilder () {
162138 return new Builder (codePoints , lineOffsets )
163139 .setDescription (description )
@@ -311,7 +287,7 @@ public Optional<Integer> getLocationOffset(int line, int column) {
311287 * offset}.
312288 */
313289 public Optional <CelSourceLocation > getOffsetLocation (int offset ) {
314- return getOffsetLocationImpl ( lineOffsets , offset );
290+ return CelSourceHelper . getOffsetLocation ( codePoints , offset );
315291 }
316292
317293 @ CheckReturnValue
@@ -335,17 +311,6 @@ public CelSource build() {
335311 }
336312 }
337313
338- private static final class LineAndOffset {
339-
340- private LineAndOffset (int line , int offset ) {
341- this .line = line ;
342- this .offset = offset ;
343- }
344-
345- private final int line ;
346- private final int offset ;
347- }
348-
349314 /**
350315 * Tag for an extension that were used while parsing or type checking the source expression. For
351316 * example, optimizations that require special runtime support may be specified. These are used to
0 commit comments