You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _specifications/lsif/0.4.0/specification.md
+30-24Lines changed: 30 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ index: 2
11
11
12
12
The 0.4.0 version of LSIF is currently under construction.
13
13
14
-
## Language Server Index Format
14
+
## <ahref="#lsifIntro"name="lsifIntro"class="anchor">Language Server Index Format</a>
15
15
16
16
The purpose of the Language Server Index Format (LSIF) is it to define a standard format for language servers or other programming tools to dump their knowledge about a workspace. This dump can later be used to answer language server [LSP](https://microsoft.github.io/language-server-protocol/) requests for the same workspace without running the language server itself. Since much of the information would be invalidated by a change to the workspace, the dumped information typically excludes requests used when mutating a document. So, for example, the result of a code complete request is typically not part of such a dump.
17
17
@@ -23,7 +23,7 @@ Up to version 0.4.0 the focus of the LSIF format was to ease the generation of t
23
23
24
24
Since 0.4.0 changes some of the LSIF aspects more deeply an old 0.3.x version of the specification is available [here](./versions/specification-0-3-x.md)
For requests that take a position as its input, we need to store the position as well. Usually LSP requests return the same result for positions that point to the same word / name in a document. Take the following TypeScript example:
91
91
@@ -143,7 +143,7 @@ If a position in a document is mapped to a range and more than one range covers
Usually the hover result is the same whether you hover over a definition of a function or over a reference of that function. The same is actually true for many LSP requests like `textDocument/definition`, `textDocument/references` or `textDocument/typeDefinition`. In a naïve model, each range would have outgoing edges for all these LSP requests and would point to the corresponding results. To optimize this and to make the graph easier to understand, the concept of a `ResultSet` is introduced. A result set acts as a hub to be able to store information common to a lot of ranges. The `ResultSet` itself doesn't carry any information. So it looks like this:
149
149
@@ -181,7 +181,9 @@ The pattern of storing the result with the `ResultSet` will be used for other re
The same pattern of connecting a range, result set, or a document with a request edge to a method result is used for other requests as well. Let's next look at the `textDocument/definition` request using the following TypeScript sample:
187
189
@@ -244,11 +246,11 @@ Running **Go to Definition** on `X` in `let x: X` will show a dialog which lets
244
246
245
247
The `item` edge as an additional property document which indicate in which document these declaration are. We added this information to still make it easy to emit the data but also make it easy to process the data to store it in a database. Without that information we would either need to specific an order in which data needs to be emitted (e.g. a item edge and only refer to a range that got already added to a document using a `containes` edge) or we force processing tools to keep a lot of vertices and edges in memory. The approach of having this `document` property looks like a fair balance.
There are programming languages that have the concept of declarations and definitions (like C/C++). If this is the case, the dump can contain a corresponding `declarationResult` vertex and a `textDocument/declaration` edge to store the information. They are handled analogously to the entities emitted for the `textDocument/definition` request.
250
252
251
-
### More about Request: `textDocument/hover`
253
+
### <a href="#hover" name="hover" class="anchor">More about Request: `textDocument/hover`</a>
252
254
253
255
In the LSP, the hover is defined as follows:
254
256
@@ -276,7 +278,7 @@ This makes the hover different for every location so we can't really store it wi
Storing references will be done in the same way as storing a hover or go to definition ranges. It uses a reference result vertex and `item` edges to add ranges to the result.
282
284
@@ -461,7 +463,7 @@ In the above example, there will be three reference results
Again, fordocumentlinks, wedefinearesulttypeandacorrespondingedgetolinkittoadocument. Sincethelinklocationusuallyappearincomments, therangesdon't denote any symbol declarations or references. We therefore inline the range into the result like we do with folding ranges.
Theonlyinformationmissingthatisusefulinadumparethediagnosticsassociatedwithdocuments. DiagnosticsintheLSParemodeledasapushnotificationssentfromtheservertotheclient. Thisdoesn't work well with a dump modeled on request method names. However, the push notification can be emulated as a request where the request'sresultisthevaluesentduringthepushasaparameter.
750
752
@@ -782,7 +784,7 @@ Produces the following output:
OneusecaseoftheLSIFistocreatedumpsforreleasedversionsofaproduct, eitheralibraryoraprogram. Ifaproject**A**referencesalibrary**B**, itwouldalsobeusefuliftheinformationinthesetwodumpscouldberelated. Tomakethispossible, theLSIFintroducesoptionalmonikerswhichcanbelinkedtorangesusingacorrespondingedge. Themonikerscanbeusedtodescribewhataprojectexportsandwhatitimports. Let's first look at the export case.
857
861
@@ -1002,7 +1006,7 @@ The moniker for `x` looks like this:
1002
1006
1003
1007
In addition to this moniker schemes starting with `$` are reserved and shouldn't be used by a LSIF tool.
@@ -1011,7 +1015,7 @@ Ranges in LSIF have currently two meanings:
1011
1015
1012
1016
To fulfil the first LSIF specifies that ranges can't overlap or be the same. However this constraint is not necessary for the second meaning. To support equal or overlapping target ranges we introduce a vertex `resultRange`. It is not allowed to use a `resultRange` as a target in a `contains` edge.
1013
1017
1014
-
##Meta Data Vertex
1018
+
### <a href="#metaData" name="metaData" class="anchor">Meta Data Vertex</a>
1015
1019
1016
1020
To support versioning the LSIF defines a meta data vertex as follows:
The following emitting constraints (some of which have already mean mentioned in the document) exists:
1059
1063
@@ -1063,13 +1067,15 @@ The following emitting constraints (some of which have already mean mentioned in
1063
1067
- after a document end event has been emitted only result sets, reference or implementation results emitted through that document can be referenced in edges. It is for example not allowed to reference ranges or result ranges from that document. This also includes adding monikers to ranges or result sets. The document data so to speak can not be altered anymore.
1064
1068
- if ranges point to result sets and monikers are emitted, they must be emitted on the result set and can't be emitted on individual ranges.
1065
1069
1066
-
## Tools
1070
+
## <a href="#additionalInformation" name="additionalInformation" class="anchor">Additional Information </a>
While implementing this for TypeScript and npm we collected a list of [open questions](https://github.com/Microsoft/lsif-typescript/labels/discussion) in form of GitHub issues we are already aware of.
0 commit comments