Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit e50bb3b

Browse files
WIP: New SCIP-based GraphQL API draft
1 parent 3fe06f6 commit e50bb3b

File tree

2 files changed

+140
-3
lines changed

2 files changed

+140
-3
lines changed

cmd/frontend/graphqlbackend/codeintel.codenav.graphql

Lines changed: 101 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,21 @@ type GitBlobLSIFData implements TreeEntryLSIFData {
105105
"""
106106
character: Int!
107107

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+
108123
"""
109124
When specified, it filters references by filename.
110125
"""
@@ -118,12 +133,12 @@ type GitBlobLSIFData implements TreeEntryLSIFData {
118133
"""
119134
The line on which the symbol occurs (zero-based, inclusive).
120135
"""
121-
line: Int!
136+
line: Int
122137

123138
"""
124139
The character (not byte) of the start line on which the symbol occurs (zero-based, inclusive).
125140
"""
126-
character: Int!
141+
character: Int
127142

128143
"""
129144
When specified, indicates that this request should be paginated and
@@ -231,6 +246,19 @@ type GitBlobLSIFData implements TreeEntryLSIFData {
231246
character: Int!
232247
): Hover
233248

249+
"""
250+
Either one of 'symbol' or 'range' must be provided, but this isn't enforced at the GraphQL
251+
layer due to the lack of support for input unions.
252+
https://github.com/graphql/graphql-wg/blob/main/rfcs/InputUnion.md
253+
"""
254+
usages(
255+
symbol: LookupSCIPSymbol,
256+
range: LookupRange,
257+
filter: UsagesFilter,
258+
first: Int,
259+
after: String,
260+
): UsageConnection!
261+
234262
"""
235263
Code diagnostics provided through LSIF.
236264
"""
@@ -247,6 +275,77 @@ type GitBlobLSIFData implements TreeEntryLSIFData {
247275
snapshot(indexID: ID!): [SnapshotData!]
248276
}
249277

278+
"""
279+
In the future, we may want to extend this to allow passing in a suffix or a "symbol pattern".
280+
"""
281+
input LookupSCIPSymbol {
282+
name: String!
283+
provenance: Provenance!
284+
}
285+
286+
type SCIPSymbol {
287+
name: String!
288+
provenance: Provenance!
289+
}
290+
291+
input LookupRange {
292+
start: LookupPosition!
293+
end: LookupPosition!
294+
}
295+
296+
input LookupPosition {
297+
line: Int!
298+
character: Int!
299+
}
300+
301+
input UsagesFilter {
302+
and: [UsagesFilter!]
303+
or: [UsagesFilter!]
304+
not: UsagesFilter
305+
# TODO: Can we be flexible here and allow patterns while still maintaining fast queries.
306+
repository: String
307+
path: String
308+
kind: SymbolUsageKind
309+
# TODO: Provide a way of controlling fallback behavior for indexes?
310+
# Not super sure how that would work, given that for different repositories,
311+
# the hashes will all be different?
312+
}
313+
314+
enum SymbolUsageKind {
315+
Definition,
316+
Reference,
317+
Implementation,
318+
Super,
319+
}
320+
321+
type UsageConnection {
322+
nodes: [Usage!]!
323+
pageInfo: PageInfo!
324+
}
325+
326+
type Usage {
327+
symbol: SCIPSymbol!
328+
"""
329+
NOTE: Do not pass
330+
TODO: For this blob, it is generally more useful to get +N/-N lines
331+
rather than having to pass a range internally for the contents since
332+
the offsets from the start will not be known a-priori.
333+
"""
334+
blob: GitBlob!
335+
"""
336+
Instead of blob { content }, allows accessing a sub-span of the content
337+
using relative coordinates from the range of this usage. If linesBefore
338+
or linesAfter is negative or exceeds the number of available lines,
339+
the value is interpreted as until the start/end of the file.
340+
"""
341+
surroundingBlobContent(surroundingLines: SurroundingLines = {linesBefore: 0, linesAfter: 0}): String!
342+
}
343+
344+
input SurroundingLines {
345+
linesBefore: Int
346+
linesAfter: Int
347+
}
348+
250349
"""
251350
The SCIP snapshot decoration for a single SCIP Occurrence.
252351
"""

cmd/frontend/graphqlbackend/schema.graphql

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6172,17 +6172,55 @@ type HighlightedFile {
61726172
"""
61736173
html: String!
61746174
"""
6175-
Base64 encoded JSON payload of LSIF Typed with syntax highlighting data.
6175+
DEPRECATED: Base64 encoded JSON payload of SCIP with syntax highlighting data.
61766176
"""
61776177
lsif: String!
61786178
"""
6179+
"""
6180+
document: AssociatedSCIPDocument!
6181+
"""
61796182
A list of the desired line ranges. Each list is a list of lines, where each element is an HTML
61806183
table row '<tr>...</tr>' string. This is useful if you only need to display specific subsets of
61816184
the file.
61826185
"""
61836186
lineRanges(ranges: [HighlightLineRange!]!): [[String!]!]!
61846187
}
61856188

6189+
enum Provenance {
6190+
Precise,
6191+
Syntactic,
6192+
SearchBased,
6193+
}
6194+
6195+
interface WithProvenance {
6196+
"""
6197+
Coarse-grained information about the data source.
6198+
"""
6199+
provenance: Provenance!
6200+
"""
6201+
Opaque fine-grained information describing the data source.
6202+
6203+
Provided only for debugging.
6204+
6205+
This field should be ignored when checking structural equality.
6206+
"""
6207+
dataSource: String!
6208+
}
6209+
6210+
type AssociatedSCIPDocument implements WithProvenance {
6211+
"""
6212+
Base64 encoded SCIP payload.
6213+
6214+
After decoding, the resulting byte buffer can be parsed with
6215+
pre-generated bindings in the sourcegraph/scip repository or
6216+
manually generating bindings using
6217+
https://github.com/sourcegraph/scip/blob/main/scip.proto
6218+
"""
6219+
data: String!
6220+
provenance: Provenance!
6221+
dataSource: String!
6222+
}
6223+
61866224
"""
61876225
A file match.
61886226
"""

0 commit comments

Comments
 (0)