Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Development.IDE.Types.Location
Description
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
Instances
FromJSON Location | |
ToJSON Location | |
Defined in Language.LSP.Types.Location | |
Generic Location | |
Read Location | |
Show Location | |
NFData Location | |
Defined in Language.LSP.Types.Location | |
Eq Location | |
Ord Location | |
Defined in Language.LSP.Types.Location | |
Hashable Location | |
Defined in Language.LSP.Types.Location | |
HasLocation DiagnosticRelatedInformation Location | |
Defined in Language.LSP.Types.Lens Methods | |
HasLocation SymbolInformation Location | |
Defined in Language.LSP.Types.Lens Methods | |
HasRange Location Range | |
HasUri Location Uri | |
type Rep Location | |
Defined in Language.LSP.Types.Location type Rep Location = D1 ('MetaData "Location" "Language.LSP.Types.Location" "lsp-types-1.6.0.0-FihZFgb8178DwGXRVjXCAI" 'False) (C1 ('MetaCons "Location" 'PrefixI 'True) (S1 ('MetaSel ('Just "_uri") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Uri) :*: S1 ('MetaSel ('Just "_range") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Range))) |
A position in a document. Note that the character offsets in a line are given in UTF-16 code units, *not* Unicode code points.
Constructors
Position | |
Fields
|
Instances
showPosition :: Position -> String Source #
Constructors
Range | |
Fields
|
Instances
Instances
data NormalizedUri #
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.
Adoption Plan of OsPath
Currently we store Text
. We may change it to OsPath in the future if
the following steps are executed.
- In the client codebase, use
osPathToNormalizedFilePath
andnormalizedFilePathToOsPath
instead offromNormalizedFilePath
andtoNormalizedFilePath
. For HLS, we could wait until GHC 9.6 becomes the oldest GHC we support, then changeFilePath
to OsPath everywhere in the codebase. - Deprecate and remove
fromNormalizedFilePath
andtoNormalizedFilePath
. - Change
Text
to OsPath and benchmark it to make sure performance doesn't go down. Don't forget to check Windows, as OsPath on Windows uses UTF-16, which may consume more memory.
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