@@ -4,18 +4,20 @@ import * as fs from 'fs';
44import * as path from 'path' ;
55
66import * as cpp from 'child-process-promise' ;
7+ import * as compareVersions from 'compare-versions' ;
78
89import { ExtensionContext } from 'vscode' ;
910import * as vscode from 'vscode' ;
1011import { LanguageClient , LanguageClientOptions , RevealOutputChannelOn ,
1112 ServerOptions } from 'vscode-languageclient' ;
13+ import { enableOldServerWorkaround } from './compat'
1214
1315let extensionContext : ExtensionContext
1416let outputChannel : vscode . OutputChannel
1517
1618export function activate ( context : ExtensionContext ) {
1719 extensionContext = context
18- outputChannel = vscode . window . createOutputChannel ( ' Dotty Language Client' ) ;
20+ outputChannel = vscode . window . createOutputChannel ( " Dotty" ) ;
1921
2022 const sbtArtifact = "org.scala-sbt:sbt-launch:1.2.3"
2123 const buildSbtFile = `${ vscode . workspace . rootPath } /build.sbt`
@@ -36,7 +38,7 @@ export function activate(context: ExtensionContext) {
3638 run ( {
3739 module : context . asAbsolutePath ( 'out/src/passthrough-server.js' ) ,
3840 args : [ port . toString ( ) ]
39- } )
41+ } , false )
4042 } )
4143
4244 } else {
@@ -72,11 +74,13 @@ function runLanguageServer(coursierPath: string, languageServerArtifactFile: str
7274 if ( err ) throw err
7375 else {
7476 const languageServerArtifact = data . toString ( ) . trim ( )
77+ const languageServerVersion = languageServerArtifact . split ( ":" ) [ 2 ]
78+ const isOldServer = compareVersions ( languageServerVersion , "0.9.x" ) <= 0
7579 fetchWithCoursier ( coursierPath , languageServerArtifact ) . then ( ( languageServerClasspath ) => {
7680 run ( {
7781 command : "java" ,
7882 args : [ "-classpath" , languageServerClasspath , "dotty.tools.languageserver.Main" , "-stdio" ]
79- } )
83+ } , isOldServer )
8084 } )
8185 }
8286 } )
@@ -149,7 +153,7 @@ function configureIDE(sbtClasspath: string, languageServerScalaVersion: string,
149153 } )
150154}
151155
152- function run ( serverOptions : ServerOptions ) {
156+ function run ( serverOptions : ServerOptions , isOldServer : boolean ) {
153157 const clientOptions : LanguageClientOptions = {
154158 documentSelector : [
155159 { language : 'scala' , scheme : 'file' , pattern : '**/*.scala' } ,
@@ -158,12 +162,13 @@ function run(serverOptions: ServerOptions) {
158162 synchronize : {
159163 configurationSection : 'dotty'
160164 } ,
165+ outputChannel : outputChannel ,
161166 revealOutputChannelOn : RevealOutputChannelOn . Never
162167 }
163168
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 )
167172
168173 // Push the disposable to the context's subscriptions so that the
169174 // client can be deactivated on extension deactivation
0 commit comments