@@ -26,11 +26,13 @@ import reporting._, reporting.diagnostic.{Message, MessageContainer, messages}
26
26
import typer .Typer
27
27
import util .{Set => _ , _ }
28
28
import interactive ._ , interactive .InteractiveDriver ._
29
+ import decompiler .IDEDecompilerDriver
29
30
import Interactive .Include
30
31
import config .Printers .interactiv
31
32
32
33
import languageserver .config .ProjectConfig
33
- import languageserver .worksheet .{Worksheet , WorksheetClient , WorksheetService }
34
+ import languageserver .worksheet .{Worksheet , WorksheetService }
35
+ import languageserver .decompiler .{TastyDecompilerService }
34
36
35
37
import lsp4j .services ._
36
38
@@ -43,7 +45,7 @@ import lsp4j.services._
43
45
* - This implementation is based on the LSP4J library: https://github.com/eclipse/lsp4j
44
46
*/
45
47
class DottyLanguageServer extends LanguageServer
46
- with TextDocumentService with WorkspaceService with WorksheetService { thisServer =>
48
+ with TextDocumentService with WorkspaceService with WorksheetService with TastyDecompilerService { thisServer =>
47
49
import ast .tpd ._
48
50
49
51
import DottyLanguageServer ._
@@ -128,6 +130,25 @@ class DottyLanguageServer extends LanguageServer
128
130
drivers(configFor(uri))
129
131
}
130
132
133
+ /** The driver instance responsible for decompiling `uri` in `classPath` */
134
+ def decompilerDriverFor (uri : URI , classPath : String ): IDEDecompilerDriver = thisServer.synchronized {
135
+ val config = configFor(uri)
136
+ val defaultFlags = List (" -color:never" )
137
+
138
+ implicit class updateDeco (ss : List [String ]) {
139
+ def update (pathKind : String , pathInfo : String ) = {
140
+ val idx = ss.indexOf(pathKind)
141
+ val ss1 = if (idx >= 0 ) ss.take(idx) ++ ss.drop(idx + 2 ) else ss
142
+ ss1 ++ List (pathKind, pathInfo)
143
+ }
144
+ }
145
+ val settings =
146
+ defaultFlags ++
147
+ config.compilerArguments.toList
148
+ .update(" -classpath" , (classPath +: config.dependencyClasspath).mkString(File .pathSeparator))
149
+ new IDEDecompilerDriver (settings)
150
+ }
151
+
131
152
/** A mapping from project `p` to the set of projects that transitively depend on `p`. */
132
153
def dependentProjects : Map [ProjectConfig , Set [ProjectConfig ]] = thisServer.synchronized {
133
154
if (myDependentProjects == null ) {
@@ -184,7 +205,8 @@ class DottyLanguageServer extends LanguageServer
184
205
rootUri = params.getRootUri
185
206
assert(rootUri != null )
186
207
187
- class DottyServerCapabilities (val worksheetRunProvider : Boolean = true ) extends lsp4j.ServerCapabilities
208
+ class DottyServerCapabilities (val worksheetRunProvider : Boolean = true ,
209
+ val tastyDecompiler : Boolean = true ) extends lsp4j.ServerCapabilities
188
210
189
211
val c = new DottyServerCapabilities
190
212
c.setTextDocumentSync(TextDocumentSyncKind .Full )
0 commit comments