@@ -47,6 +47,103 @@ extend type GitBlob {
47
47
Experimental: This API is likely to change in the future.
48
48
"""
49
49
symbolInfo (line : Int ! , character : Int ! ): SymbolInfo
50
+
51
+ """
52
+ If filter.provenance? is not provided, then the API will go through
53
+ each provenance one by one in the order Precise -> Syntactic -> SearchBased
54
+ and stop when some data is available.
55
+ """
56
+ codeGraphData (filter : CodeGraphDataFilter ): CodeGraphData
57
+ }
58
+
59
+ input CodeGraphDataFilter {
60
+ provenance : ProvenanceComparator
61
+ }
62
+
63
+ """
64
+ Invariants:
65
+ 1. forall sym in symbols.
66
+ (sym.provenance, sym.dataSource) == (scipDocument.provenance, scipDocument.dataSource)
67
+ """
68
+ # Implementation notes:
69
+ # 1. For precise code nav, we already have a code for inferring
70
+ # 'visible uploads' using the commit graph machinery -> infer best upload
71
+ # -> get document for that using the given path.
72
+ # 2. Syntactic will be similar to precise
73
+ # 3. Search-based -> return empty document/lists.
74
+ #
75
+ # Ref panel logic:
76
+ # 1. Request code graph data, specifying 'filter' if needed.
77
+ # Either the scipDocument or occurrences is fine.
78
+ # 2. When a hover is triggered, attempt to look up occurrence in document or list
79
+ # or some other lookup structure constructed from those.
80
+ # 3a. If one matching occurrence is found, use symbolName + range to call
81
+ # usagesForSymbol
82
+ # 3b. If zero matching occurrences are found, use only range to call usagesForSymbol.
83
+ # 3c. If more than one matching occurrence is found, use some more complex logic
84
+ # to offer a symbol picker.
85
+ # - Problem: For a symbol picker, ideally you'd use SymbolInformation.display_name,
86
+ # which is stored on SymbolInformation. However, display_name is not supported
87
+ # today by most SCIP indexers. And we don't have any API for getting the detailed
88
+ # SCIP SymbolInformation for a bunch of occurrences.
89
+ type CodeGraphData {
90
+ scipDocument : AssociatedSCIPDocument
91
+
92
+ """
93
+ List of symbols with definitions in this document.
94
+
95
+ Invariant:
96
+ forall sym in symbols.
97
+ exists occ in occurrences such that
98
+ sym.name == occ.symbolName && occ.roles.contains(Definition)
99
+ """
100
+ # TODO: Should this be paginated to gracefully handle large generated files?
101
+ symbols : [SymbolInformation ! ]
102
+
103
+ """
104
+ Occurrences are guaranteed to be sorted by range.
105
+ """
106
+ # TODO: Should this be paginated to gracefully handle large generated files?
107
+ occurrences (filter : OccurrencesFilter ): [Occurrence ! ]
108
+ }
109
+
110
+ type Occurrence {
111
+ symbolName : String
112
+ range : Range !
113
+ roles : [SymbolRole ! ]
114
+ # We can add diagnostics etc. here in the future if needed.
115
+ }
116
+
117
+ input OccurrencesFilter {
118
+ rangeFilter : RangeFilter
119
+ rolesFilter : RolesFilter
120
+ # We can add a DiagnosticsFilter etc. here in the future if needed.
121
+ }
122
+
123
+ input RangeFilter {
124
+ """
125
+ Zero-based line number, inclusive.
126
+ """
127
+ startLine : Int
128
+ """
129
+ Zero-based line number, inclusive.
130
+ """
131
+ endLine : Int
132
+ }
133
+
134
+ input RolesFilter {
135
+ or : [RolesFilter ! ]
136
+ equals : SymbolRole
137
+ }
138
+
139
+ enum SymbolRole {
140
+ Definition ,
141
+ Reference ,
142
+ """
143
+ Applicable for forward declarations in languages with header files (C, C++ etc.)
144
+ as well as standalone signatures in languages with separate interface files (OCaml etc.).
145
+ """
146
+ ForwardDefinition ,
50
147
}
51
148
52
149
"""
@@ -93,6 +190,8 @@ type GitBlobLSIFData implements TreeEntryLSIFData {
93
190
94
191
"""
95
192
A list of definitions of the symbol under the given document position.
193
+
194
+ DEPRECATED: Use usagesForSymbol with a Definition filter instead.
96
195
"""
97
196
definitions (
98
197
"""
@@ -105,21 +204,6 @@ type GitBlobLSIFData implements TreeEntryLSIFData {
105
204
"""
106
205
character : Int !
107
206
108
- """
109
- When specified, indicates that this request should be paginated and
110
- to fetch results starting at this cursor.
111
- A future request can be made for more results by passing in the
112
- 'LocationConnection.pageInfo.endCursor' that is returned.
113
- """
114
- after : String
115
-
116
- """
117
- When specified, indicates that this request should be paginated and
118
- the first N results (relative to the cursor) should be returned. i.e.
119
- how many results to return per page.
120
- """
121
- first : Int
122
-
123
207
"""
124
208
When specified, it filters references by filename.
125
209
"""
@@ -128,6 +212,8 @@ type GitBlobLSIFData implements TreeEntryLSIFData {
128
212
129
213
"""
130
214
A list of references of the symbol under the given document position.
215
+
216
+ DEPRECATED: Use usagesForSymbol with a Reference filter instead.
131
217
"""
132
218
references (
133
219
"""
@@ -163,6 +249,8 @@ type GitBlobLSIFData implements TreeEntryLSIFData {
163
249
164
250
"""
165
251
A list of implementations of the symbol under the given document position.
252
+
253
+ DEPRECATED: Use usagesForSymbol with Implementations filter instead.
166
254
"""
167
255
implementations (
168
256
"""
@@ -198,6 +286,8 @@ type GitBlobLSIFData implements TreeEntryLSIFData {
198
286
199
287
"""
200
288
A list of prototypes of the symbol under the given document position.
289
+
290
+ DEPRECATED: Use usagesForSymbol with a Supers filter instead.
201
291
"""
202
292
prototypes (
203
293
"""
@@ -263,44 +353,114 @@ type GitBlobLSIFData implements TreeEntryLSIFData {
263
353
}
264
354
265
355
extend type Query {
356
+ """
357
+ Identify usages for either a semantic symbol, or the symbol(s) implied
358
+ by a source range.
359
+
360
+ Ordering and uniqueness guarantees:
361
+ 1. The usages returned will already be de-duplicated.
362
+ 2. Results for a single file are contiguous.
363
+ 3. Results for a single repository are contiguous.
364
+
365
+ Related: See `codeGraphData` on GitBlob.
366
+ """
266
367
usagesForSymbol (
267
- symbol : LookupSCIPSymbol ,
268
368
"""
269
- Non-optional due to implementation limitations
369
+ Symbol to perform the lookup for.
370
+
371
+ If provided, then the start and end position in 'range' are optional.
372
+
373
+ If not provided, then the start and end position in 'range' must be set.
374
+ In that case, the results will be merged across all semantic symbols
375
+ in the source range specified by [start, end]
376
+ """
377
+ symbol : SymbolComparator ,
378
+ """
379
+ Information about an existing source range for a usage of the symbol.
380
+
381
+ TODO: Specify behavior for various cases of overlap between LookupRange
382
+ and actual occurrence range.
270
383
"""
271
384
range : LookupRange ! ,
385
+
272
386
filter : UsagesFilter ,
273
- first : Int ,
274
- after : String ,
387
+
388
+ """
389
+ When specified, indicates that this request should be paginated and
390
+ the first N results (relative to the cursor) should be returned. i.e.
391
+ how many results to return per page.
392
+ """
393
+ first : Int
394
+
395
+ """
396
+ When specified, indicates that this request should be paginated and
397
+ to fetch results starting at this cursor.
398
+ A future request can be made for more results by passing in the
399
+ 'UsageConnection.pageInfo.endCursor' that is returned.
400
+ """
401
+ after : String
275
402
): UsageConnection !
276
403
}
277
404
278
- input LookupSCIPSymbol {
405
+ input SymbolComparator {
279
406
name : SymbolNameComparator !
280
407
provenance : ProvenanceComparator !
281
408
}
282
409
283
- """
284
- In the future, we may want to extend this to allow passing in a suffix or a "symbol pattern".
285
- """
410
+ # Implementation note: In the future, we may want to extend this
411
+ # to allow passing in a suffix or a "symbol pattern".
412
+ # See https://github.com/sourcegraph/sourcegraph/issues/59957
286
413
input SymbolNameComparator {
287
- eq : String
414
+ equals : String
288
415
}
289
416
290
417
input ProvenanceComparator {
291
- eq : Provenance
418
+ equals : Provenance
292
419
}
293
420
294
- type SCIPSymbol {
421
+ type SymbolInformation implements WithProvenance {
422
+ """
423
+ Symbol name using syntax specified by the SCIP schema.
424
+ https://github.com/sourcegraph/scip/blob/main/scip.proto#L147-L188
425
+
426
+ This value will generally be used in conjunction with
427
+ the `usagesBySymbol` API.
428
+ """
295
429
name : String !
430
+ """
431
+ Hover documentation for the symbol, in Markdown format.
432
+
433
+ The caller must take care to escape any particular strings,
434
+ such as raw HTML, as necessary.
435
+
436
+ The value is null when the hover documentation is not found
437
+ by 'dataSource'.
438
+
439
+ The value is empty when `dataSource` is confident that there
440
+ is no appropriate hover documentation to display.
441
+ """
442
+ documentation : [String ! ]
443
+ """
444
+ Coarse-grained information about the data source.
445
+ """
296
446
provenance : Provenance !
447
+ """
448
+ Opaque fine-grained information describing the data source.
449
+
450
+ Provided only for debugging.
451
+
452
+ This field should be ignored when checking structural equality.
453
+ """
454
+ dataSource : String
297
455
}
298
456
299
457
input LookupRange {
300
458
"""
301
459
Defaults to instance-wide search if the repo is not specified.
302
460
303
- This field is non-optional due to implementation limitations.
461
+ This field is necessary if LookupSymbol is a repository-local or
462
+ file-local symbol. It is mandatory for cross-repo symbols
463
+ due to implementation limitations.
304
464
"""
305
465
repo : String !
306
466
"""
@@ -310,28 +470,40 @@ input LookupRange {
310
470
"""
311
471
Defaults to repo-wide search if the path is not specified.
312
472
313
- This field is non-optional due to implementation limitations.
473
+ This field is necessary if LookupSymbol is a file-local symbol.
474
+ It is mandatory for repository-local and cross-repo symbols
475
+ due to implementation limitations.
314
476
"""
315
477
path : String !
316
478
start : LookupPosition
317
479
end : LookupPosition
318
480
}
319
481
320
482
input LookupPosition {
483
+ """
484
+ Zero-based count of newline (\n or \r\n) characters before this position.
485
+ """
321
486
line : Int !
487
+ """
488
+ Zero-based UTF-16 code unit offset from preceding newline (\n or \r\n) character.
489
+ """
322
490
character : Int !
323
491
}
324
492
493
+ """
494
+ An empty filter allows all kinds of usages for all paths in all repositories.
495
+
496
+ However, if the symbol used for lookup is a file-local symbol or a
497
+ repository-local symbol, then usages will automatically be limited to the
498
+ same file or same repository respectively.
499
+ """
325
500
input UsagesFilter {
326
501
and : [UsagesFilter ! ]
327
502
or : [UsagesFilter ! ]
328
503
not : UsagesFilter
329
504
repository : RepositoryFilter
330
505
path : PathFilter
331
506
kind : SymbolUsageKind
332
- # TODO: Provide a way of controlling fallback behavior for indexes?
333
- # Not super sure how that would work, given that for different repositories,
334
- # the hashes will all be different?
335
507
}
336
508
337
509
input RepositoryFilter {
@@ -343,7 +515,7 @@ input PathFilter {
343
515
}
344
516
345
517
input StringComparator {
346
- eq : String
518
+ equals : String
347
519
}
348
520
349
521
enum SymbolUsageKind {
@@ -358,8 +530,17 @@ type UsageConnection {
358
530
pageInfo : PageInfo !
359
531
}
360
532
533
+ type UsageRange {
534
+ repo : String !
535
+ revision : String !
536
+ range : Range !
537
+ }
538
+
361
539
type Usage {
362
- symbol : SCIPSymbol !
540
+ symbol : SymbolInformation !
541
+
542
+ range : UsageRange
543
+
363
544
"""
364
545
NOTE: Do not pass
365
546
TODO: For this blob, it is generally more useful to get +N/-N lines
0 commit comments