Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Types and functions for working with source code locations.
Synopsis
- data Location = Location {}
- noFilePath :: FilePath
- noRange :: Range
- data Position = Position {
- _line :: UInt
- _character :: UInt
- showPosition :: Position -> String
- data Range = Range {}
- newtype Uri = Uri {}
- data NormalizedUri
- toNormalizedUri :: Uri -> NormalizedUri
- fromNormalizedUri :: NormalizedUri -> Uri
- data NormalizedFilePath
- fromUri :: NormalizedUri -> NormalizedFilePath
- emptyFilePath :: NormalizedFilePath
- emptyPathUri :: NormalizedUri
- toNormalizedFilePath' :: FilePath -> NormalizedFilePath
- fromNormalizedFilePath :: NormalizedFilePath -> FilePath
- filePathToUri' :: NormalizedFilePath -> NormalizedUri
- uriToFilePath' :: Uri -> Maybe FilePath
- readSrcSpan :: ReadS RealSrcSpan
Documentation
Represents a location inside a resource, such as a line inside a text file.
Instances
FromJSON Location | |
ToJSON Location | |
Generic Location | |
Show Location | |
NFData Location | |
Eq Location | |
Ord Location | |
Hashable Location | |
Pretty Location | |
HasLocation DiagnosticRelatedInformation Location | |
HasLocation SymbolInformation Location | |
Defined in Language.LSP.Protocol.Internal.Lens | |
HasRange Location Range | |
HasUri Location Uri | |
HasLocation InlayHintLabelPart (Maybe Location) | |
Defined in Language.LSP.Protocol.Internal.Lens | |
type Rep Location | |
Defined in Language.LSP.Protocol.Internal.Types.Location type Rep Location = D1 ('MetaData "Location" "Language.LSP.Protocol.Internal.Types.Location" "lsp-types-2.1.0.0-4XLhOyhXn16LNWGw0cjrdM" 'False) (C1 ('MetaCons "Location" 'PrefixI 'True) (S1 ('MetaSel ('Just "_uri") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Uri) :*: S1 ('MetaSel ('Just "_range") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Range))) |
Position in a text document expressed as zero-based line and character
offset. Prior to 3.17 the offsets were always based on a UTF-16 string
representation. So a string of the form a𐐀b
the character offset of the
character a
is 0, the character offset of 𐐀
is 1 and the character
offset of b is 3 since 𐐀
is represented using two code units in UTF-16.
Since 3.17 clients and servers can agree on a different string encoding
representation (e.g. UTF-8). The client announces it's supported encoding
via the client capability `general.positionEncodings`.
The value is an array of position encodings the client supports, with
decreasing preference (e.g. the encoding at index `0` is the most preferred
one). To stay backwards compatible the only mandatory encoding is UTF-16
represented via the string `utf-16`. The server can pick one of the
encodings offered by the client and signals that encoding back to the
client via the initialize result's property
[`capabilities.positionEncoding`](#serverCapabilities). If the string value
`utf-16` is missing from the client's capability `general.positionEncodings`
servers can safely assume that the client supports UTF-16. If the server
omits the position encoding in its initialize result the encoding defaults
to the string value `utf-16`. Implementation considerations: since the
conversion from one encoding into another requires the content of the
file / line the conversion is best done where the file is read which is
usually on the server side.
Positions are line end character agnostic. So you can not specify a position that denotes `r|n` or `n|` where `|` represents the character offset.
@since 3.17.0 - support for negotiated position encoding.
Position | |
|
Instances
showPosition :: Position -> String Source #
A range in a text document expressed as (zero-based) start and end positions.
If you want to specify a range that contains a line including the line ending character(s) then use an end position denoting the start of the next line. For example: ```ts { start: { line: 5, character: 23 } end : { line 6, character : 0 } } ```
Instances
The Uri
type in the LSP specification.
Instances
data NormalizedUri #
A normalized Uri
.
If you want to use a URI as a map key, use this type. It is important to normalize the percent encoding in the URI since URIs that only differ when it comes to the percent-encoding should be treated as equivalent.
NormalizedUri
has a cached hash in order to make it especially fast in a hash map.
Instances
toNormalizedUri :: Uri -> NormalizedUri #
fromNormalizedUri :: NormalizedUri -> Uri #
data NormalizedFilePath #
A file path that is already normalized.
The NormalizedUri
is cached to avoided
repeated normalisation when we need to compute them (which is a lot).
This is one of the most performance critical parts of HLS, do not modify it without profiling.
Instances
fromNormalizedFilePath :: NormalizedFilePath -> FilePath #
Extracts FilePath
from NormalizedFilePath
.
uriToFilePath' :: Uri -> Maybe FilePath Source #
We use an empty string as a filepath when we don’t have a file. However, haskell-lsp doesn’t support that in uriToFilePath and given that it is not a valid filepath it does not make sense to upstream a fix. So we have our own wrapper here that supports empty filepaths.
readSrcSpan :: ReadS RealSrcSpan Source #
Parser for the GHC output format