@@ -63,6 +63,8 @@ function setupMethods (soljson) {
63
63
} ;
64
64
65
65
const createWrappedLspSend = function ( ) {
66
+ if ( ! ( '_solidity_lsp_send' in soljson ) )
67
+ return null ;
66
68
const wrappedLspSend = soljson . cwrap ( 'solidity_lsp_send' , 'number' , [ 'string' ] ) ;
67
69
return function ( input : String ) {
68
70
const args = [ ] ;
@@ -73,6 +75,8 @@ function setupMethods (soljson) {
73
75
74
76
// Creates a wrapper around `int solidity_lsp_start(callbacks: Callbacks)`.
75
77
const createWrappedLspStart = function ( ) {
78
+ if ( ! ( '_solidity_lsp_start' in soljson ) )
79
+ return null ;
76
80
const wrappedLspStart = soljson . cwrap ( 'solidity_lsp_start' , 'number' , [ ] ) ;
77
81
return function ( callbacks : Callbacks ) {
78
82
let readCallback = callbacks . import ;
@@ -146,17 +150,6 @@ function setupMethods (soljson) {
146
150
} ;
147
151
} ;
148
152
149
- // solc.lspStart(myCallbackHere);
150
- let lspStart = null ;
151
- if ( '_solidity_lsp_start' in soljson ) {
152
- lspStart = createWrappedLspStart ( ) ;
153
- }
154
-
155
- let lspSendReceive = null ;
156
- if ( '_solidity_lsp_send_receive' in soljson ) {
157
- lspSendReceive = createWrappedLspSend ( ) ;
158
- }
159
-
160
153
// This calls compile() with args || cb
161
154
const runWithCallbacks = function ( callbacks , compile , args ) {
162
155
if ( callbacks ) {
@@ -390,8 +383,8 @@ function setupMethods (soljson) {
390
383
nativeStandardJSON : compileStandard !== null
391
384
} ,
392
385
lsp : {
393
- start : lspStart ,
394
- sendReceive : lspSendReceive
386
+ start : createWrappedLspStart ( ) ,
387
+ sendReceive : createWrappedLspSend ( )
395
388
} ,
396
389
compile : compileStandardWrapper ,
397
390
// Loads the compiler of the given version from the github repository
0 commit comments