@@ -4,18 +4,20 @@ import * as fs from 'fs';
4
4
import * as path from 'path' ;
5
5
6
6
import * as cpp from 'child-process-promise' ;
7
+ import * as compareVersions from 'compare-versions' ;
7
8
8
9
import { ExtensionContext } from 'vscode' ;
9
10
import * as vscode from 'vscode' ;
10
11
import { LanguageClient , LanguageClientOptions , RevealOutputChannelOn ,
11
12
ServerOptions } from 'vscode-languageclient' ;
13
+ import { enableOldServerWorkaround } from './compat'
12
14
13
15
let extensionContext : ExtensionContext
14
16
let outputChannel : vscode . OutputChannel
15
17
16
18
export function activate ( context : ExtensionContext ) {
17
19
extensionContext = context
18
- outputChannel = vscode . window . createOutputChannel ( ' Dotty Language Client' ) ;
20
+ outputChannel = vscode . window . createOutputChannel ( " Dotty" ) ;
19
21
20
22
const sbtArtifact = "org.scala-sbt:sbt-launch:1.2.3"
21
23
const buildSbtFile = `${ vscode . workspace . rootPath } /build.sbt`
@@ -36,7 +38,7 @@ export function activate(context: ExtensionContext) {
36
38
run ( {
37
39
module : context . asAbsolutePath ( 'out/src/passthrough-server.js' ) ,
38
40
args : [ port . toString ( ) ]
39
- } )
41
+ } , false )
40
42
} )
41
43
42
44
} else {
@@ -72,11 +74,13 @@ function runLanguageServer(coursierPath: string, languageServerArtifactFile: str
72
74
if ( err ) throw err
73
75
else {
74
76
const languageServerArtifact = data . toString ( ) . trim ( )
77
+ const languageServerVersion = languageServerArtifact . split ( ":" ) [ 2 ]
78
+ const isOldServer = compareVersions ( languageServerVersion , "0.9.x" ) <= 0
75
79
fetchWithCoursier ( coursierPath , languageServerArtifact ) . then ( ( languageServerClasspath ) => {
76
80
run ( {
77
81
command : "java" ,
78
82
args : [ "-classpath" , languageServerClasspath , "dotty.tools.languageserver.Main" , "-stdio" ]
79
- } )
83
+ } , isOldServer )
80
84
} )
81
85
}
82
86
} )
@@ -149,7 +153,7 @@ function configureIDE(sbtClasspath: string, languageServerScalaVersion: string,
149
153
} )
150
154
}
151
155
152
- function run ( serverOptions : ServerOptions ) {
156
+ function run ( serverOptions : ServerOptions , isOldServer : boolean ) {
153
157
const clientOptions : LanguageClientOptions = {
154
158
documentSelector : [
155
159
{ language : 'scala' , scheme : 'file' , pattern : '**/*.scala' } ,
@@ -158,12 +162,13 @@ function run(serverOptions: ServerOptions) {
158
162
synchronize : {
159
163
configurationSection : 'dotty'
160
164
} ,
165
+ outputChannel : outputChannel ,
161
166
revealOutputChannelOn : RevealOutputChannelOn . Never
162
167
}
163
168
164
- outputChannel . dispose ( )
165
-
166
- const client = new LanguageClient ( 'dotty' , 'Dotty Language Server' , serverOptions , clientOptions ) ;
169
+ const client = new LanguageClient ( "dotty" , "Dotty" , serverOptions , clientOptions )
170
+ if ( isOldServer )
171
+ enableOldServerWorkaround ( client )
167
172
168
173
// Push the disposable to the context's subscriptions so that the
169
174
// client can be deactivated on extension deactivation
0 commit comments