<div dir="ltr"><div>Currently compiler diagnostics are sent back with some positional information.  See <a href="https://docs.oracle.com/en/java/javase/21/docs/api/java.compiler/javax/tools/Diagnostic.html">https://docs.oracle.com/en/java/javase/21/docs/api/java.compiler/javax/tools/Diagnostic.html</a></div><div><br></div><div>The Diagnostic class contains range info...</div><div>  getStartPosition - file offset (no line or column number)</div><div>  getEndPosition - file offset (no line or column number)</div><div><br></div><div>And it contains more specific position info...</div><div>  getLineNumber - line number in file.</div><div>  getColumnNumber - column number in file.</div><div>  getPosition - file offset.</div><div><br></div><div>For LSP (Language Server Protocol) the requirements for a diagnostic location are startLine, startColumn, endLine, endColumn.</div><div><br></div><div>Because of this, taking a javac diagnostic and transforming it into LSP diagnostic requires parsing the source file and transforming `getStartPosition`, `getEndPosition` and sometimes `getPosition` into line/column numbers.</div><div><br></div><div>`getColumnNumber` can't be used (without source file parsing) because it returns a position based on the assumption that a tab is 8 spaces which isn't true in most code from what I've seen and tabs are treated as a single character in LSP.</div><div><br></div><div>So ideally I'd like methods `getStartLine`, `getEndLine`, `getStartColNumber`, `getEndColNumber` added to the Diagnostic class.  Where the `colNumber` methods treat a tab as a single character.</div><div><br></div><div>Is this possible?  I imagine the data is already available at the time the diagnostics are created.</div><div><br></div><div>regards</div><div>Arthur</div></div>