static SourceSection findNearest(Source source, SourceElement[] sourceElements, int line, int column, SuspendAnchor anchor, TruffleInstrument.Env env) { int boundLine = line; int boundColumn = column; int maxLine = source.getLineCount(); if (boundLine > maxLine) { boundLine = maxLine; } int maxColumn = source.getLineLength(boundLine) + 1; if (boundColumn > maxColumn) { boundColumn = maxColumn; } return findNearestBound(source, getElementTags(sourceElements), boundLine, boundColumn, anchor, env); }
@Override SourceSection adjustLocation(Source source, TruffleInstrument.Env env, SuspendAnchor suspendAnchor) { if (sourceSection != null) { return sourceSection; } if (key == null) { return null; } boolean hasColumn = column > 0; SourceSection location = SuspendableLocationFinder.findNearest(source, sourceElements, line, column, suspendAnchor, env); if (location != null) { switch (suspendAnchor) { case BEFORE: line = location.getStartLine(); if (hasColumn) { column = location.getStartColumn(); } break; case AFTER: line = location.getEndLine(); if (hasColumn) { column = location.getEndColumn(); } break; default: throw new IllegalArgumentException("Unknown suspend anchor: " + suspendAnchor); } } return location; }
SourceSection adjustLocation(Source source, TruffleInstrument.Env env, SuspendAnchor suspendAnchor) { if (sourceSection != null) { return sourceSection; } if (key == null) { return null; } boolean hasColumn = column > 0; SourceSection location = SuspendableLocationFinder.findNearest(source, sourceElements, line, column, suspendAnchor, env); if (location != null) { switch (suspendAnchor) { case BEFORE: line = location.getStartLine(); if (hasColumn) { column = location.getStartColumn(); } break; case AFTER: line = location.getEndLine(); if (hasColumn) { column = location.getEndColumn(); } break; default: throw new IllegalArgumentException("Unknown suspend anchor: " + suspendAnchor); } } return location; }
static SourceSection findNearest(Source source, SourceElement[] sourceElements, int line, int column, SuspendAnchor anchor, TruffleInstrument.Env env) { if (!source.hasCharacters()) { return null; } int boundLine = line; int boundColumn = column; int maxLine = source.getLineCount(); if (boundLine > maxLine) { boundLine = maxLine; } int maxColumn = source.getLineLength(boundLine) + 1; if (boundColumn > maxColumn) { boundColumn = maxColumn; } return findNearestBound(source, getElementTags(sourceElements), boundLine, boundColumn, anchor, env); }