Search in sources :

Example 6 with LineAndColumn

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;
}
Also used : LineAndColumn(org.eclipse.xtext.util.LineAndColumn)

Example 7 with LineAndColumn

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());
}
Also used : LineAndColumn(org.eclipse.xtext.util.LineAndColumn)

Aggregations

LineAndColumn (org.eclipse.xtext.util.LineAndColumn)7 Position (org.eclipse.lsp4j.Position)2 ICompositeNode (org.eclipse.xtext.nodemodel.ICompositeNode)2 CompletableFuture (java.util.concurrent.CompletableFuture)1 URI (org.eclipse.emf.common.util.URI)1 EObject (org.eclipse.emf.ecore.EObject)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1 CodeActionContext (org.eclipse.lsp4j.CodeActionContext)1 CodeActionParams (org.eclipse.lsp4j.CodeActionParams)1 Diagnostic (org.eclipse.lsp4j.Diagnostic)1 InitializeParams (org.eclipse.lsp4j.InitializeParams)1 InitializeResult (org.eclipse.lsp4j.InitializeResult)1 Range (org.eclipse.lsp4j.Range)1 TextDocumentIdentifier (org.eclipse.lsp4j.TextDocumentIdentifier)1 LanguageClient (org.eclipse.lsp4j.services.LanguageClient)1 Diagnostic (org.eclipse.xtext.diagnostics.Diagnostic)1 DiagnosticResolution (org.eclipse.xtext.ide.editor.quickfix.DiagnosticResolution)1 Document (org.eclipse.xtext.ide.server.Document)1 ILanguageServerAccess (org.eclipse.xtext.ide.server.ILanguageServerAccess)1