1
- import { execSync , exec , spawnSync } from 'child_process' ;
1
+ import { execSync , spawnSync } from 'child_process' ;
2
2
import { ChildProcess , spawn } from 'mz/child_process' ;
3
3
import * as vscode from 'vscode' ;
4
4
import * as path from 'path' ;
@@ -8,17 +8,20 @@ import { LanguageClient, LanguageClientOptions, ServerOptions, StreamInfo } from
8
8
export function activate ( context : vscode . ExtensionContext ) {
9
9
var logChannel = vscode . window . createOutputChannel ( "Bal_LSP_and_Impl" ) ;
10
10
const main : string = 'com.lspandimpl.launcher.stdio.StdioLauncher' ;
11
- const tcpMain : string = 'TCPLauncher'
11
+ const tcpMain : string = 'com.lspandimpl.launcher.tcp. TCPLauncher'
12
12
logChannel . appendLine ( "Starting the Ballerina Language Server Extension!" ) ;
13
13
14
14
getJavaHome ( ) . then ( val => {
15
15
let javaHome = ( ( val + '' ) . split ( 'java.home =' ) [ 1 ] ) . trim ( ) ;
16
- logChannel . appendLine ( javaHome ) ;
17
- let excecutable : string = path . join ( javaHome , 'bin' , 'java' ) ;
16
+ logChannel . appendLine ( 'Java Home: [' + javaHome + ']' ) ;
18
17
18
+ let excecutable : string = path . join ( javaHome , 'bin' , 'java' ) ;
19
19
let classPath = path . join ( __dirname , '..' , '*' ) ;
20
20
const args : string [ ] = [ '-cp' , classPath ] ;
21
+
21
22
let ballerinaHome = getBallerinaHome ( ) ;
23
+ logChannel . appendLine ( 'Ballerina Home: [' + ballerinaHome + ']' ) ;
24
+
22
25
args . push ( '-Dballerina.home=' + ballerinaHome ) ;
23
26
if ( process . env . LSDEBUG === "true" ) {
24
27
logChannel . appendLine ( 'LSDEBUG is set to "true". Language Server is starting on debug mode' ) ;
@@ -67,7 +70,6 @@ export function activate(context: vscode.ExtensionContext) {
67
70
return childProcess
68
71
} ) ;
69
72
} ) ;
70
-
71
73
// ######## End of TCP Connection ########
72
74
73
75
let clientOptions : LanguageClientOptions = {
@@ -108,22 +110,12 @@ function getJavaHome() {
108
110
}
109
111
110
112
function getBallerinaHome ( ) {
111
- let cmd : string ;
112
-
113
- if ( process . platform == 'win32' ) {
114
- cmd = 'java -XshowSettings:properties -version 2>&1 | findstr "java.home"' ;
115
- } else {
116
- cmd = "bal home" ;
117
- }
118
-
119
113
try {
120
114
let response = spawnSync ( 'bal' , [ 'home' ] ) ;
121
115
if ( response . stdout . length > 0 ) {
122
116
return response . stdout . toString ( ) . trim ( ) ;
123
117
}
124
118
} catch ( er ) {
125
- if ( er instanceof Error ) {
126
- return "Failed"
127
- }
119
+ return "Failed to execute the command `bal home`" ;
128
120
}
129
121
}
0 commit comments