@@ -2,8 +2,39 @@ package lsp
22
33import "context"
44
5+ type Position struct {
6+ Line int `json:"line"`
7+ Character int `json:"character"`
8+ }
9+
10+ type RangeResult struct {
11+ Start Position `json:"start"`
12+ End Position `json:"end"`
13+ }
14+
15+ type LocationNode struct {
16+ Resource struct {
17+ Path string `json:"path"`
18+ Repository struct {
19+ Name string `json:"name"`
20+ } `json:"repository"`
21+ Commit struct {
22+ OID string `json:"oid"`
23+ } `json:"commit"`
24+ } `json:"resource"`
25+ Range RangeResult `json:"range"`
26+ }
27+
28+ // Hover
29+
530const hoverQuery = `
6- query Hover($repository: String!, $commit: String!, $path: String!, $line: Int!, $character: Int!) {
31+ query Hover(
32+ $repository: String!
33+ $commit: String!
34+ $path: String!
35+ $line: Int!
36+ $character: Int!
37+ ) {
738 repository(name: $repository) {
839 commit(rev: $commit) {
940 blob(path: $path) {
@@ -37,16 +68,6 @@ type HoverResult struct {
3768 Range * RangeResult `json:"range"`
3869}
3970
40- type RangeResult struct {
41- Start Position `json:"start"`
42- End Position `json:"end"`
43- }
44-
45- type Position struct {
46- Line int `json:"line"`
47- Character int `json:"character"`
48- }
49-
5071type hoverResponse struct {
5172 Repository * struct {
5273 Commit * struct {
@@ -59,7 +80,9 @@ type hoverResponse struct {
5980 } `json:"repository"`
6081}
6182
62- func (s * Server ) queryHover (ctx context.Context , path string , line , character int ) (* HoverResult , error ) {
83+ func (s * Server ) queryHover (
84+ ctx context.Context , path string , line , character int ,
85+ ) (* HoverResult , error ) {
6386 vars := map [string ]any {
6487 "repository" : s .repoName ,
6588 "commit" : s .commit ,
@@ -88,8 +111,16 @@ func (s *Server) queryHover(ctx context.Context, path string, line, character in
88111 return result .Repository .Commit .Blob .LSIF .Hover , nil
89112}
90113
114+ // Definitions
115+
91116const definitionsQuery = `
92- query Definitions($repository: String!, $commit: String!, $path: String!, $line: Int!, $character: Int!) {
117+ query Definitions(
118+ $repository: String!
119+ $commit: String!
120+ $path: String!
121+ $line: Int!
122+ $character: Int!
123+ ) {
93124 repository(name: $repository) {
94125 commit(rev: $commit) {
95126 blob(path: $path) {
@@ -124,19 +155,6 @@ query Definitions($repository: String!, $commit: String!, $path: String!, $line:
124155}
125156`
126157
127- type LocationNode struct {
128- Resource struct {
129- Path string `json:"path"`
130- Repository struct {
131- Name string `json:"name"`
132- } `json:"repository"`
133- Commit struct {
134- OID string `json:"oid"`
135- } `json:"commit"`
136- } `json:"resource"`
137- Range RangeResult `json:"range"`
138- }
139-
140158type definitionsResponse struct {
141159 Repository * struct {
142160 Commit * struct {
@@ -151,7 +169,9 @@ type definitionsResponse struct {
151169 } `json:"repository"`
152170}
153171
154- func (s * Server ) queryDefinitions (ctx context.Context , path string , line , character int ) ([]LocationNode , error ) {
172+ func (s * Server ) queryDefinitions (
173+ ctx context.Context , path string , line , character int ,
174+ ) ([]LocationNode , error ) {
155175 vars := map [string ]any {
156176 "repository" : s .repoName ,
157177 "commit" : s .commit ,
@@ -180,8 +200,16 @@ func (s *Server) queryDefinitions(ctx context.Context, path string, line, charac
180200 return result .Repository .Commit .Blob .LSIF .Definitions .Nodes , nil
181201}
182202
203+ // References
204+
183205const referencesQuery = `
184- query References($repository: String!, $commit: String!, $path: String!, $line: Int!, $character: Int!) {
206+ query References(
207+ $repository: String!
208+ $commit: String!
209+ $path: String!
210+ $line: Int!
211+ $character: Int!
212+ ) {
185213 repository(name: $repository) {
186214 commit(rev: $commit) {
187215 blob(path: $path) {
@@ -230,7 +258,9 @@ type referencesResponse struct {
230258 } `json:"repository"`
231259}
232260
233- func (s * Server ) queryReferences (ctx context.Context , path string , line , character int ) ([]LocationNode , error ) {
261+ func (s * Server ) queryReferences (
262+ ctx context.Context , path string , line , character int ,
263+ ) ([]LocationNode , error ) {
234264 vars := map [string ]any {
235265 "repository" : s .repoName ,
236266 "commit" : s .commit ,
0 commit comments