in tools/query_breakdown/src/main/java/com/google/bigquery/LocationTracker.java [93:127]
public LocationTracker delete(int startLine, int startColumn, int endLine,
int endColumn) {
LocationTracker locationTracker = cloneTracker();
// same line case, just remove the corresponding locations
if (startLine == endLine) {
for (int i = startColumn; i < endColumn + 1; i++) {
locationTracker.remove(startLine, startColumn);
}
}
else {
/* different line case */
// startLine: note that we add a new line character to the startline in multi-line deletion
for (int x = startColumn; x < location.get(startLine - 1).size(); x++) {
locationTracker.remove(startLine, startColumn);
}
// endLine: if entire endline is removed vs part of it is removed
if (endColumn == locationTracker.getLocation().get(endLine - 1).size()) {
locationTracker.removeLine(endLine);
}
else {
for (int y = 1; y < endColumn + 1; y++) {
locationTracker.remove(endLine, 1);
}
}
// lines in the middle
if (endLine - startLine > 1) {
for (int z = startLine + 1; z < endLine; z++) {
locationTracker.removeLine(z);
}
}
}
return locationTracker;
}