Class Positions
java.lang.Object
org.clafer.lsp.Positions
Converts between the frontend's positions and LSP's, on the text of a
document.
The frontend's lines and columns start at 1, and its columns are the
compiler's: a tab moves to the column after the next multiple of 8, and
every other character, a carriage return included, is one column. LSP's
lines and characters start at 0, and a character is a UTF-16 code unit, as
a Java char is.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint[]fromLsp(org.eclipse.lsp4j.Position position) line(int line) inttext(org.eclipse.lsp4j.Range range) org.eclipse.lsp4j.PositiontoLsp(int line, int column) org.eclipse.lsp4j.RangetoLsp(SourceSpan span) org.eclipse.lsp4j.RangetoVisibleLsp(SourceSpan span)
-
Constructor Details
-
Positions
-
-
Method Details
-
line
-
lineCount
- Returns:
- the number of lines, the last one after the last newline included
-
toLsp
- Parameters:
line- a line of the frontend, from 1column- a column of the frontend, from 1- Returns:
- the LSP position: past the end of its line if the column is, and at the end of the document if the line is past it
-
fromLsp
- Parameters:
position- an LSP position- Returns:
- the frontend's line and column there, as {line, column}
-
toLsp
- Parameters:
span- a span of the frontend- Returns:
- its LSP range
-
toVisibleLsp
- Parameters:
span- a span of the frontend- Returns:
- its LSP range, widened to the character at its start if it is empty and there is one, so that every editor shows it
-
text
-