use of org.eclipse.xtext.util.LineAndColumn in project xtext-core by eclipse.
the class DiagnosticConverterImpl method getLocationForNode.
/**
* Computes {@link IssueLocation} for the given offset and length in the given node.
*
* @since 2.21
*/
protected IssueLocation getLocationForNode(INode node, int offset, int length) {
IssueLocation result = new IssueLocation();
result.offset = offset;
result.length = length;
LineAndColumn lineAndColumnStart = NodeModelUtils.getLineAndColumn(node, offset);
result.lineNumber = lineAndColumnStart.getLine();
result.column = lineAndColumnStart.getColumn();
LineAndColumn lineAndColumnEnd = NodeModelUtils.getLineAndColumn(node, offset + length);
result.lineNumberEnd = lineAndColumnEnd.getLine();
result.columnEnd = lineAndColumnEnd.getColumn();
return result;
}
use of org.eclipse.xtext.util.LineAndColumn in project xtext-core by eclipse.
the class LineAndColumnTest method doAssertLineAndColumn.
protected void doAssertLineAndColumn(String text, int offset, int line, int column) {
int[] lineBreaks = AccessibleNodeModelUtils.computeLineBreaks(text);
LineAndColumn lineAndColumn = AccessibleNodeModelUtils.getLineAndColumn(text, lineBreaks, offset);
Assert.assertEquals("line", line, lineAndColumn.getLine());
Assert.assertEquals("column", column, lineAndColumn.getColumn());
LineAndColumn offsetZero = AccessibleNodeModelUtils.getLineAndColumn(text, lineBreaks, 0);
Assert.assertEquals("line", 1, offsetZero.getLine());
Assert.assertEquals("column", 1, offsetZero.getColumn());
}
Aggregations