@@ -19,7 +19,6 @@ defmodule NextLS do
19
19
alias GenLSP.Requests.TextDocumentDefinition
20
20
alias GenLSP.Requests.TextDocumentDocumentSymbol
21
21
alias GenLSP.Requests.TextDocumentFormatting
22
- alias GenLSP.Requests.TextDocumentReferences
23
22
alias GenLSP.Requests.WorkspaceSymbol
24
23
alias GenLSP.Structures.DidChangeWatchedFilesParams
25
24
alias GenLSP.Structures.DidChangeWorkspaceFoldersParams
@@ -109,7 +108,6 @@ defmodule NextLS do
109
108
document_formatting_provider: true ,
110
109
workspace_symbol_provider: true ,
111
110
document_symbol_provider: true ,
112
- references_provider: true ,
113
111
definition_provider: true ,
114
112
workspace: % {
115
113
workspace_folders: % GenLSP.Structures.WorkspaceFoldersServerCapabilities {
@@ -173,62 +171,6 @@ defmodule NextLS do
173
171
{ :reply , symbols , lsp }
174
172
end
175
173
176
- # TODO handle `context: %{includeDeclaration: true}` to include the current symbol definition among
177
- # the results.
178
- def handle_request ( % TextDocumentReferences { params: % { position: position , text_document: % { uri: uri } } } , lsp ) do
179
- file = URI . parse ( uri ) . path
180
- line = position . line + 1
181
- col = position . character + 1
182
-
183
- locations =
184
- dispatch ( lsp . assigns . registry , :databases , fn databases ->
185
- Enum . flat_map ( databases , fn { database , _ } ->
186
- references =
187
- case symbol_info ( file , line , col , database ) do
188
- { :function , module , function } ->
189
- DB . query (
190
- database ,
191
- ~Q"""
192
- SELECT file, start_line, end_line, start_column, end_column
193
- FROM "references" as refs
194
- WHERE refs.identifier = ?
195
- AND refs.type = ?
196
- AND refs.module = ?
197
- """ ,
198
- [ function , "function" , module ]
199
- )
200
-
201
- { :module , module } ->
202
- DB . query (
203
- database ,
204
- ~Q"""
205
- SELECT file, start_line, end_line, start_column, end_column
206
- FROM "references" as refs
207
- WHERE refs.module = ?
208
- and refs.type = ?
209
- """ ,
210
- [ module , "alias" ]
211
- )
212
-
213
- :unknown ->
214
- [ ]
215
- end
216
-
217
- for [ file , start_line , end_line , start_column , end_column ] <- references do
218
- % Location {
219
- uri: "file://#{ file } " ,
220
- range: % Range {
221
- start: % Position { line: start_line - 1 , character: start_column - 1 } ,
222
- end: % Position { line: end_line - 1 , character: end_column - 1 }
223
- }
224
- }
225
- end
226
- end )
227
- end )
228
-
229
- { :reply , locations , lsp }
230
- end
231
-
232
174
def handle_request ( % WorkspaceSymbol { params: % { query: query } } , lsp ) do
233
175
filter = fn sym ->
234
176
if query == "" do
@@ -661,55 +603,4 @@ defmodule NextLS do
661
603
{ ^ ref , result } -> result
662
604
end
663
605
end
664
-
665
- defp symbol_info ( file , line , col , database ) do
666
- definition_query =
667
- ~Q"""
668
- SELECT module, type, name
669
- FROM "symbols" sym
670
- WHERE sym.file = ?
671
- AND sym.line = ?
672
- ORDER BY sym.id ASC
673
- LIMIT 1
674
- """
675
-
676
- reference_query = ~Q"""
677
- SELECT identifier, type, module
678
- FROM "references" refs
679
- WHERE refs.file = ?
680
- AND refs.start_line <= ? AND refs.end_line >= ?
681
- AND refs.start_column <= ? AND refs.end_column >= ?
682
- ORDER BY refs.id ASC
683
- LIMIT 1
684
- """
685
-
686
- case DB . query ( database , definition_query , [ file , line ] ) do
687
- [ [ module , "defmodule" , _ ] ] ->
688
- { :module , module }
689
-
690
- [ [ module , "defstruct" , _ ] ] ->
691
- { :module , module }
692
-
693
- [ [ module , "def" , function ] ] ->
694
- { :function , module , function }
695
-
696
- [ [ module , "defp" , function ] ] ->
697
- { :function , module , function }
698
-
699
- [ [ module , "defmacro" , function ] ] ->
700
- { :function , module , function }
701
-
702
- _unknown_definition ->
703
- case DB . query ( database , reference_query , [ file , line , line , col , col ] ) do
704
- [ [ function , "function" , module ] ] ->
705
- { :function , module , function }
706
-
707
- [ [ _alias , "alias" , module ] ] ->
708
- { :module , module }
709
-
710
- _unknown_reference ->
711
- :unknown
712
- end
713
- end
714
- end
715
606
end
0 commit comments