Skip to content

Commit 691ef37

Browse files
liam923voodoos
authored andcommitted
Always include staleness in json
1 parent bae52fc commit 691ef37

22 files changed

+272
-141
lines changed

src/commands/query_json.ml

+2-6
Original file line numberDiff line numberDiff line change
@@ -492,11 +492,7 @@ let json_of_response (type a) (query : a t) (response : a) : json =
492492
let with_file = scope = `Project || scope = `Renaming in
493493
`List
494494
(List.map occurrences ~f:(fun occurrence ->
495-
let without_location =
496-
match occurrence.is_stale with
497-
| true -> [ ("stale", Json.bool true) ]
498-
| false -> []
499-
in
500-
with_location ~with_file occurrence.loc without_location))
495+
with_location ~with_file occurrence.loc
496+
[ ("stale", Json.bool occurrence.is_stale) ]))
501497
| Signature_help _, s -> json_of_signature_help s
502498
| Version, version -> `String version

tests/test-dirs/occurrences/basic.t/run.t

+32-16
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ Test getting occurrences of a function arg:
1212
"end": {
1313
"line": 1,
1414
"col": 15
15-
}
15+
},
16+
"stale": false
1617
},
1718
{
1819
"start": {
@@ -22,7 +23,8 @@ Test getting occurrences of a function arg:
2223
"end": {
2324
"line": 2,
2425
"col": 6
25-
}
26+
},
27+
"stale": false
2628
},
2729
{
2830
"start": {
@@ -32,7 +34,8 @@ Test getting occurrences of a function arg:
3234
"end": {
3335
"line": 2,
3436
"col": 13
35-
}
37+
},
38+
"stale": false
3639
}
3740
],
3841
"notifications": []
@@ -52,7 +55,8 @@ Test getting occurrences of a function arg annotated with a type:
5255
"end": {
5356
"line": 4,
5457
"col": 23
55-
}
58+
},
59+
"stale": false
5660
},
5761
{
5862
"start": {
@@ -62,7 +66,8 @@ Test getting occurrences of a function arg annotated with a type:
6266
"end": {
6367
"line": 5,
6468
"col": 6
65-
}
69+
},
70+
"stale": false
6671
},
6772
{
6873
"start": {
@@ -72,7 +77,8 @@ Test getting occurrences of a function arg annotated with a type:
7277
"end": {
7378
"line": 5,
7479
"col": 13
75-
}
80+
},
81+
"stale": false
7682
}
7783
],
7884
"notifications": []
@@ -92,7 +98,8 @@ Test getting occurrences of a record pattern in a function arg:
9298
"end": {
9399
"line": 9,
94100
"col": 28
95-
}
101+
},
102+
"stale": false
96103
},
97104
{
98105
"start": {
@@ -102,7 +109,8 @@ Test getting occurrences of a record pattern in a function arg:
102109
"end": {
103110
"line": 10,
104111
"col": 7
105-
}
112+
},
113+
"stale": false
106114
},
107115
{
108116
"start": {
@@ -112,7 +120,8 @@ Test getting occurrences of a record pattern in a function arg:
112120
"end": {
113121
"line": 10,
114122
"col": 15
115-
}
123+
},
124+
"stale": false
116125
}
117126
],
118127
"notifications": []
@@ -132,7 +141,8 @@ Test getting occurrences of a function arg then used in record literal:
132141
"end": {
133142
"line": 12,
134143
"col": 25
135-
}
144+
},
145+
"stale": false
136146
},
137147
{
138148
"start": {
@@ -142,7 +152,8 @@ Test getting occurrences of a function arg then used in record literal:
142152
"end": {
143153
"line": 13,
144154
"col": 14
145-
}
155+
},
156+
"stale": false
146157
}
147158
],
148159
"notifications": []
@@ -162,7 +173,8 @@ Test getting occurrences of a function arg then used in record literal punned:
162173
"end": {
163174
"line": 15,
164175
"col": 33
165-
}
176+
},
177+
"stale": false
166178
},
167179
{
168180
"start": {
@@ -172,7 +184,8 @@ Test getting occurrences of a function arg then used in record literal punned:
172184
"end": {
173185
"line": 16,
174186
"col": 8
175-
}
187+
},
188+
"stale": false
176189
}
177190
],
178191
"notifications": []
@@ -192,7 +205,8 @@ Test getting occurrences of a function arg alias then used in record literal:
192205
"end": {
193206
"line": 18,
194207
"col": 27
195-
}
208+
},
209+
"stale": false
196210
},
197211
{
198212
"start": {
@@ -202,7 +216,8 @@ Test getting occurrences of a function arg alias then used in record literal:
202216
"end": {
203217
"line": 19,
204218
"col": 5
205-
}
219+
},
220+
"stale": false
206221
},
207222
{
208223
"start": {
@@ -212,7 +227,8 @@ Test getting occurrences of a function arg alias then used in record literal:
212227
"end": {
213228
"line": 19,
214229
"col": 11
215-
}
230+
},
231+
"stale": false
216232
}
217233
],
218234
"notifications": []

tests/test-dirs/occurrences/ext-variant.t

+8-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ See issue #1185 on vscode-ocaml-platform
2020
"end": {
2121
"line": 2,
2222
"col": 11
23-
}
23+
},
24+
"stale": false
2425
},
2526
{
2627
"start": {
@@ -30,7 +31,8 @@ See issue #1185 on vscode-ocaml-platform
3031
"end": {
3132
"line": 5,
3233
"col": 3
33-
}
34+
},
35+
"stale": false
3436
}
3537
]
3638

@@ -56,7 +58,8 @@ FIXME: we can do better than that
5658
"end": {
5759
"line": 2,
5860
"col": 11
59-
}
61+
},
62+
"stale": false
6063
},
6164
{
6265
"start": {
@@ -66,7 +69,8 @@ FIXME: we can do better than that
6669
"end": {
6770
"line": 5,
6871
"col": 3
69-
}
72+
},
73+
"stale": false
7074
}
7175
]
7276

tests/test-dirs/occurrences/issue1398.t/run.t

+24-12
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ Test finding occurrences of let-based binding operator, from reified syntax:
1111
"end": {
1212
"line": 1,
1313
"col": 11
14-
}
14+
},
15+
"stale": false
1516
},
1617
{
1718
"start": {
@@ -21,7 +22,8 @@ Test finding occurrences of let-based binding operator, from reified syntax:
2122
"end": {
2223
"line": 3,
2324
"col": 17
24-
}
25+
},
26+
"stale": false
2527
},
2628
{
2729
"start": {
@@ -31,7 +33,8 @@ Test finding occurrences of let-based binding operator, from reified syntax:
3133
"end": {
3234
"line": 4,
3335
"col": 5
34-
}
36+
},
37+
"stale": false
3538
}
3639
],
3740
"notifications": []
@@ -51,7 +54,8 @@ Test finding occurrences of and-based binding operator, from reified syntax:
5154
"end": {
5255
"line": 2,
5356
"col": 11
54-
}
57+
},
58+
"stale": false
5559
},
5660
{
5761
"start": {
@@ -61,7 +65,8 @@ Test finding occurrences of and-based binding operator, from reified syntax:
6165
"end": {
6266
"line": 3,
6367
"col": 26
64-
}
68+
},
69+
"stale": false
6570
},
6671
{
6772
"start": {
@@ -71,7 +76,8 @@ Test finding occurrences of and-based binding operator, from reified syntax:
7176
"end": {
7277
"line": 4,
7378
"col": 17
74-
}
79+
},
80+
"stale": false
7581
}
7682
],
7783
"notifications": []
@@ -89,7 +95,8 @@ Test finding occurrences of and-based binding operator, from reified syntax:
8995
"end": {
9096
"line": 1,
9197
"col": 11
92-
}
98+
},
99+
"stale": false
93100
},
94101
{
95102
"start": {
@@ -99,7 +106,8 @@ Test finding occurrences of and-based binding operator, from reified syntax:
99106
"end": {
100107
"line": 3,
101108
"col": 17
102-
}
109+
},
110+
"stale": false
103111
},
104112
{
105113
"start": {
@@ -109,7 +117,8 @@ Test finding occurrences of and-based binding operator, from reified syntax:
109117
"end": {
110118
"line": 4,
111119
"col": 5
112-
}
120+
},
121+
"stale": false
113122
}
114123
],
115124
"notifications": []
@@ -127,7 +136,8 @@ Test finding occurrences of and-based binding operator, from reified syntax:
127136
"end": {
128137
"line": 2,
129138
"col": 11
130-
}
139+
},
140+
"stale": false
131141
},
132142
{
133143
"start": {
@@ -137,7 +147,8 @@ Test finding occurrences of and-based binding operator, from reified syntax:
137147
"end": {
138148
"line": 3,
139149
"col": 26
140-
}
150+
},
151+
"stale": false
141152
},
142153
{
143154
"start": {
@@ -147,7 +158,8 @@ Test finding occurrences of and-based binding operator, from reified syntax:
147158
"end": {
148159
"line": 4,
149160
"col": 17
150-
}
161+
},
162+
"stale": false
151163
}
152164
],
153165
"notifications": []

tests/test-dirs/occurrences/issue1404.t

+8-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ occurrences identifier-at 2:0 returns the occurrences of [x]
1616
"end": {
1717
"line": 1,
1818
"col": 5
19-
}
19+
},
20+
"stale": false
2021
},
2122
{
2223
"start": {
@@ -26,7 +27,8 @@ occurrences identifier-at 2:0 returns the occurrences of [x]
2627
"end": {
2728
"line": 2,
2829
"col": 1
29-
}
30+
},
31+
"stale": false
3032
}
3133
]
3234

@@ -45,7 +47,8 @@ occurrences identifier-at 2:1 returns the occurrences of [+]
4547
"end": {
4648
"line": 1,
4749
"col": 21
48-
}
50+
},
51+
"stale": false
4952
},
5053
{
5154
"start": {
@@ -55,7 +58,8 @@ occurrences identifier-at 2:1 returns the occurrences of [+]
5558
"end": {
5659
"line": 2,
5760
"col": 2
58-
}
61+
},
62+
"stale": false
5963
}
6064
]
6165

tests/test-dirs/occurrences/issue1410.t

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"end": {
1414
"line": 3,
1515
"col": 4
16-
}
16+
},
17+
"stale": false
1718
}
1819
]
1920

@@ -32,6 +33,7 @@
3233
"end": {
3334
"line": 3,
3435
"col": 4
35-
}
36+
},
37+
"stale": false
3638
}
3739
]

0 commit comments

Comments
 (0)