@@ -12,7 +12,6 @@ import cats.tagless.FunctorK
12
12
import cats .tagless .implicits .*
13
13
import cats .~>
14
14
import io .circe .Json
15
- import org .eclipse .lsp4j
16
15
import playground .CompilationError
17
16
import playground .CompilationFailed
18
17
import playground .FileCompiler
@@ -21,12 +20,14 @@ import playground.OperationCompiler
21
20
import playground .PreludeCompiler
22
21
import playground .ServiceIndex
23
22
import playground .language
23
+ import playground .language .CodeLens
24
24
import playground .language .CodeLensProvider
25
25
import playground .language .CommandProvider
26
26
import playground .language .CommandResultReporter
27
27
import playground .language .CompletionItem
28
28
import playground .language .CompletionProvider
29
29
import playground .language .DiagnosticProvider
30
+ import playground .language .DocumentSymbol
30
31
import playground .language .DocumentSymbolProvider
31
32
import playground .language .Feedback
32
33
import playground .language .FormattingProvider
@@ -39,9 +40,7 @@ import playground.smithyql.SourceRange
39
40
import playground .types .*
40
41
import smithy4s .dynamic .DynamicSchemaIndex
41
42
42
- import scala .jdk .CollectionConverters .*
43
-
44
- // todo: independentize this from lsp4j and move to kernel
43
+ // todo: move to kernel
45
44
trait LanguageServer [F [_]] {
46
45
47
46
def initialize [A ](workspaceFolders : List [Uri ]): F [InitializeResult ]
@@ -75,15 +74,15 @@ trait LanguageServer[F[_]] {
75
74
76
75
def diagnostic (
77
76
documentUri : Uri
78
- ): F [lsp4j. DocumentDiagnosticReport ]
77
+ ): F [List [ LSPDiagnostic ] ]
79
78
80
79
def codeLens (
81
80
documentUri : Uri
82
- ): F [List [lsp4j. CodeLens ]]
81
+ ): F [List [LSPCodeLens ]]
83
82
84
83
def documentSymbol (
85
84
documentUri : Uri
86
- ): F [List [lsp4j. DocumentSymbol ]]
85
+ ): F [List [LSPDocumentSymbol ]]
87
86
88
87
def didChangeWatchedFiles : F [Unit ]
89
88
@@ -228,7 +227,7 @@ object LanguageServer {
228
227
229
228
def diagnostic (
230
229
documentUri : Uri
231
- ): F [lsp4j. DocumentDiagnosticReport ] = TextDocumentManager [F ]
230
+ ): F [List [ LSPDiagnostic ] ] = TextDocumentManager [F ]
232
231
.get(documentUri)
233
232
.map { documentText =>
234
233
val diags = diagnosticProvider.getDiagnostics(
@@ -237,18 +236,13 @@ object LanguageServer {
237
236
238
237
val map = LocationMap (documentText)
239
238
240
- new lsp4j.DocumentDiagnosticReport (
241
- new lsp4j.RelatedFullDocumentDiagnosticReport (
242
- diags
243
- .map(converters.toLSP.diagnostic(map, _))
244
- .asJava
245
- )
246
- )
239
+ diags
240
+ .map(LSPDiagnostic (_, map))
247
241
}
248
242
249
243
def codeLens (
250
244
documentUri : Uri
251
- ): F [List [lsp4j. CodeLens ]] = TextDocumentManager [F ]
245
+ ): F [List [LSPCodeLens ]] = TextDocumentManager [F ]
252
246
.get(documentUri)
253
247
.map { documentText =>
254
248
val map = LocationMap (documentText)
@@ -258,17 +252,17 @@ object LanguageServer {
258
252
documentUri = documentUri,
259
253
documentText = documentText,
260
254
)
261
- .map(converters.toLSP.codeLens(map, _ ))
255
+ .map(LSPCodeLens (_, map ))
262
256
}
263
257
264
258
def documentSymbol (
265
259
documentUri : Uri
266
- ): F [List [lsp4j. DocumentSymbol ]] = TextDocumentManager [F ]
260
+ ): F [List [LSPDocumentSymbol ]] = TextDocumentManager [F ]
267
261
.get(documentUri)
268
262
.map { text =>
269
263
val map = LocationMap (text)
270
264
271
- DocumentSymbolProvider .make(text).map(converters.toLSP.documentSymbol(map, _ ))
265
+ DocumentSymbolProvider .make(text).map(LSPDocumentSymbol (_, map ))
272
266
}
273
267
274
268
def didChangeWatchedFiles : F [Unit ] = ServerLoader [F ]
@@ -357,6 +351,9 @@ case class InitializeResult(
357
351
serverInfo : ServerInfo ,
358
352
)
359
353
354
+ case class LSPDiagnostic (diagnostic : CompilationError , map : LocationMap )
355
+ case class LSPCodeLens (lens : CodeLens , map : LocationMap )
356
+ case class LSPDocumentSymbol (sym : DocumentSymbol , map : LocationMap )
360
357
case class LSPCompletionItem (item : CompletionItem , map : LocationMap )
361
358
case class LSPTextEdit (textEdit : TextEdit , map : LocationMap )
362
359
0 commit comments