Maps Composer data to the Language Server Protocol's shapes, as plain
maps with atom keys named like GenLSP's structure fields
(related_information, new_text, ...). Composer.LSP.Server turns
them into GenLSP structures; nothing here depends on GenLSP.
Positions are converted with Composer.LSP.Position, which needs each
line's text. A line_fun gives it: line_fun.(path, line) returns line
line (1-based) of the file at path, or nil. lines_for/1 builds
one from the files on disk.
Summary
Functions
The LSP diagnostic of d, a diagnostic in file d.file. One with no
position is placed at the start of the file. Its data carries the
code and the suggestions, for code actions.
Line line (1-based) of a tuple of lines, or nil.
A line_fun over the files at paths, each read once. A file that
cannot be read has no lines.
The file: URI of an absolute path.
The LSP range of a Composer range (nil is the start of the file).
line_of.(line) gives a line's text.
The LSP severity of a diagnostic severity.
The path of a file: URI, percent-decoded; nil for any other scheme.
Types
@type line_fun() :: (Path.t(), pos_integer() -> String.t() | nil)
@type lsp_position() :: %{line: non_neg_integer(), character: non_neg_integer()}
@type lsp_range() :: %{start: lsp_position(), end: lsp_position()}
Functions
@spec diagnostic( Composer.Lint.Diagnostic.t(), Composer.LSP.Position.encoding(), line_fun() ) :: map()
The LSP diagnostic of d, a diagnostic in file d.file. One with no
position is placed at the start of the file. Its data carries the
code and the suggestions, for code actions.
Line line (1-based) of a tuple of lines, or nil.
A line_fun over the files at paths, each read once. A file that
cannot be read has no lines.
The file: URI of an absolute path.
@spec range( Composer.Lint.Diagnostic.range() | nil, Composer.LSP.Position.encoding(), (pos_integer() -> String.t() | nil) ) :: lsp_range()
The LSP range of a Composer range (nil is the start of the file).
line_of.(line) gives a line's text.
@spec severity(:error | :warning) :: 1 | 2
The LSP severity of a diagnostic severity.
The path of a file: URI, percent-decoded; nil for any other scheme.