Changed visibility of getCol function.
This commit is contained in:
parent
1e78b289e1
commit
345acb559f
|
@ -103,22 +103,24 @@ public class RangePosition extends AbstractSourcePosition implements Position {
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getCol(int line, int offset) {
|
private int getCol(int line, int offset) {
|
||||||
if (line == 1) {
|
int col = -1;
|
||||||
return offset + 1;
|
|
||||||
}
|
|
||||||
String content;
|
|
||||||
Reader reader = null;
|
Reader reader = null;
|
||||||
try {
|
try {
|
||||||
reader = getReader();
|
reader = getReader();
|
||||||
content = IOUtils.toString(reader);
|
col = getCol(IOUtils.toString(reader), line, offset);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
IOUtils.closeQuietly(reader);
|
|
||||||
return -1;
|
|
||||||
} finally {
|
} finally {
|
||||||
IOUtils.closeQuietly(reader);
|
IOUtils.closeQuietly(reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return col;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getCol(String content, int line, int offset) {
|
||||||
|
if (line == 1) {
|
||||||
|
return offset + 1;
|
||||||
|
}
|
||||||
int pos = -1;
|
int pos = -1;
|
||||||
for (int i = 0; i < line - 1; i++) {
|
for (int i = 0; i < line - 1; i++) {
|
||||||
pos = content.indexOf('\n', pos + 1);
|
pos = content.indexOf('\n', pos + 1);
|
||||||
|
@ -130,8 +132,7 @@ public class RangePosition extends AbstractSourcePosition implements Position {
|
||||||
|
|
||||||
return offset - pos + (NUMBER_OF_CHARS_IN_TAB - 1) * nrOfTabs;
|
return offset - pos + (NUMBER_OF_CHARS_IN_TAB - 1) * nrOfTabs;
|
||||||
} catch (StringIndexOutOfBoundsException e) {
|
} catch (StringIndexOutOfBoundsException e) {
|
||||||
System.err.println("Could not determine column for file " + getURL() + " (" +
|
System.err.println("Could not determine column!");
|
||||||
getFirstOffset() + " -> " + getLastOffset() + ", line " + line + ", offset " + offset);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue