Skip to content

Commit 92f7ebc

Browse files
author
Dimitri Ratz
committed
Major changes in the References interface.
- Introduced query-able Reference interface - Introduced Reference as new response type in the method references - Extended ReferenceParams
1 parent 55159b7 commit 92f7ebc

3 files changed

Lines changed: 178 additions & 2 deletions

File tree

_specifications/lsp/3.18/language/references.md

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,72 @@ _Request_:
4444

4545
<div class="anchorHolder"><a href="#referenceParams" name="referenceParams" class="linkableAnchor"></a></div>
4646

47+
```typescript
48+
export namespace ReferenceKind {
49+
/**
50+
* Statement with l-value usage of the selected variable.
51+
*/
52+
export const Lvalue = 1;
53+
/**
54+
* Statement with r-value usage of the selected variable.
55+
*/
56+
export const Rvalue = 2;
57+
/**
58+
* Location that constructs a variable of the selected type.
59+
*/
60+
export const Type = 3;
61+
/**
62+
* Location with super-type of the selected type.
63+
*/
64+
export const SuperType = 4;
65+
/**
66+
* Location with sub-type of the selected type.
67+
*/
68+
export const SubType = 5;
69+
/**
70+
* Expression that converts a value to the selected type.
71+
* For example, in Go, 'writer = file' might implicitly convert
72+
* an *os.File to an io.Writer.
73+
*/
74+
export const TypeConversion = 6;
75+
/**
76+
* Implicit reference to the selected identifier.
77+
* For example, in C++, 'Point2D {1, 2}' is shorthand to
78+
* initialize the public fields X and Y, and it might be useful to
79+
* highlight it when finding references to X or Y.
80+
*/
81+
export const Implicit = 7;
82+
/**
83+
* Free variable of the selected code block.
84+
* A variable is "free" if it is referenced from within the
85+
* selected code block but defined outside of it.
86+
*/
87+
export const FreeVariable = 8;
88+
/**
89+
* Function declaration (including anonymous lambdas) that
90+
* satisfies a particular function type (and vice versa).
91+
*/
92+
export const FunctionDeclaration = 9;
93+
/**
94+
* Argument expression that assigns the selected parameter.
95+
* For example, in Go, a query on y 'func f(x, y int)' might
96+
* report the expression 456 in the call f(123, 456).
97+
*/
98+
export const ArgumentExpression = 10;
99+
}
100+
101+
export type ReferenceKind = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
102+
```
103+
47104
```typescript
48105
export interface ReferenceParams extends TextDocumentPositionParams,
49106
WorkDoneProgressParams, PartialResultParams {
50107
context: ReferenceContext;
108+
/**
109+
* The requested reference kinds to filter by.
110+
* Clients may send an empty array to request all kinds of references.
111+
*/
112+
referenceKind?: ReferenceKind[];
51113
}
52114
```
53115

@@ -62,6 +124,6 @@ export interface ReferenceContext {
62124
}
63125
```
64126
_Response_:
65-
* result: [`Location`](#location)[] \| `null`
66-
* partial result: [`Location`](#location)[]
127+
* result: [`Reference`](#reference)[] \| `null`
128+
* partial result: [`Reference`](#reference)[]
67129
* error: code and message set in case an exception happens during the reference request.

_specifications/lsp/3.18/metaModel/metaModel.json

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5543,6 +5543,23 @@
55435543
"kind": "reference",
55445544
"name": "ReferenceContext"
55455545
}
5546+
},
5547+
{
5548+
"name": "referenceKind",
5549+
"kind": "or",
5550+
"items": [
5551+
{
5552+
"kind": "array",
5553+
"element": {
5554+
"kind": "reference",
5555+
"name": "ReferenceKind"
5556+
}
5557+
},
5558+
{
5559+
"kind": "base",
5560+
"name": "null"
5561+
}
5562+
]
55465563
}
55475564
],
55485565
"extends": [
@@ -16077,6 +16094,94 @@
1607716094
"kind": "base",
1607816095
"name": "string"
1607916096
}
16097+
},
16098+
{
16099+
"name": "ReferenceKind",
16100+
"type": {
16101+
"kind": "base",
16102+
"name": "uinteger"
16103+
},
16104+
"values": [
16105+
{
16106+
"name": "Lvalue",
16107+
"value": 1,
16108+
"documentation": "Statement with l-value usage of the selected variable.",
16109+
"since": "3.18"
16110+
},
16111+
{
16112+
"name": "Rvalue",
16113+
"value": 2,
16114+
"documentation": "Statement with r-value usage of the selected variable.",
16115+
"since": "3.18"
16116+
},
16117+
{
16118+
"name": "Type",
16119+
"value": 3,
16120+
"documentation": "Location that constructs a variable of the selected type.",
16121+
"since": "3.18"
16122+
},
16123+
{
16124+
"name": "SuperType",
16125+
"value": 4,
16126+
"documentation": "Location with super-type of the selected type.",
16127+
"since": "3.18"
16128+
},
16129+
{
16130+
"name": "SubType",
16131+
"value": 5,
16132+
"documentation": "Location with sub-type of the selected type.",
16133+
"since": "3.18"
16134+
},
16135+
{
16136+
"name": "TypeConversion",
16137+
"value": 6,
16138+
"documentation": "Expression that converts a value to the selected type.\n For example, in Go, 'writer = file' might implicitly convert\n an *os.File to an io.Writer.",
16139+
"since": "3.18"
16140+
},
16141+
{
16142+
"name": "Implicit",
16143+
"value": 7,
16144+
"documentation": "Implicit reference to the selected identifier.\n For example, in C++, 'Point2D {1, 2}' is shorthand to\n initialize the public fields X and Y, and it might be useful to\n highlight it when finding references to X or Y.",
16145+
"since": "3.18"
16146+
},
16147+
{
16148+
"name": "FreeVariable",
16149+
"value": 8,
16150+
"documentation": "Free variable of the selected code block.\n A variable is 'free' if it is referenced from within the\n selected code block but defined outside of it.",
16151+
"since": "3.18"
16152+
},
16153+
{
16154+
"name": "FunctionDeclaration",
16155+
"value": 9,
16156+
"documentation": "Function declaration (including anonymous lambdas) that\n satisfies a particular function type (and vice versa).",
16157+
"since": "3.18"
16158+
},
16159+
{
16160+
"name": "ArgumentExpression",
16161+
"value": 10,
16162+
"documentation": "Argument expression that assigns the selected parameter.\n For example, in Go, a query on y 'func f(x, y int)' might\n report the expression 456 in the call f(123, 456).",
16163+
"since": "3.18"
16164+
}
16165+
]
16166+
},
16167+
{
16168+
"name": "Reference",
16169+
"properties": [
16170+
{
16171+
"name": "location",
16172+
"type": {
16173+
"kind": "base",
16174+
"name": "Location"
16175+
}
16176+
},
16177+
{
16178+
"name": "referenceKind",
16179+
"type": {
16180+
"kind": "reference",
16181+
"name": "ReferenceKind"
16182+
}
16183+
}
16184+
]
1608016185
}
1608116186
]
1608216187
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#### <a href="#reference" name="reference" class="anchor">Reference</a>
2+
3+
Represents a reference inside a workspace. A reference has a location and a specific kind.
4+
```typescript
5+
interface Reference {
6+
location: Location;
7+
referenceKind: ReferenceKind;
8+
}
9+
```

0 commit comments

Comments
 (0)