/** * Returns the position for the given node. This is the start position. The * end position can be obtained via {@link Position#getEnd()}. A specific * range within the node can be specified with the {@code start} and * {@code end} parameters. * * @param node the node to look up position for * @param start the relative offset within the node range to use as the * starting position, inclusive, or -1 to not limit the range * @param end the relative offset within the node range to use as the ending * position, or -1 to not limit the range * @return the position, or null if the node type is not supported for * position info */ @NonNull public static SourcePosition getPosition(@NonNull Node node, int start, int end) { Position p = getPositionHelper(node, start, end); return p == null ? SourcePosition.UNKNOWN : p.toSourcePosition(); }
@Nullable private static Node findNodeAtOffset(@NonNull Node node, int offset) { Position p = getPositionHelper(node, -1, -1); if (p != null) { if (offset < p.getOffset()) {
@Nullable private static Node findNodeAtLineAndCol(@NonNull Node node, int line, int column) { Position p = getPositionHelper(node, -1, -1); if (p != null) { if (line < p.getLine() || line == p.getLine() && column != -1