@@ -16,6 +16,13 @@ import { reportError } from "./errorReporter";
16
16
import config from "./config" ;
17
17
import { filesDiagnostics , projectsFiles } from "./projectFiles" ;
18
18
19
+ // This is a bit dirty but avoids passing down this function each time.
20
+ export type SendLogNotification = ( level : p . MessageType , message : string ) => void
21
+ let sendLogNotification : SendLogNotification = ( ) => { } ;
22
+ export function setSendLogNotification ( send : SendLogNotification ) {
23
+ sendLogNotification = send ;
24
+ }
25
+
19
26
let tempFilePrefix = "rescript_format_file_" + process . pid + "_" ;
20
27
let tempFileId = 0 ;
21
28
@@ -92,15 +99,19 @@ export let findBinary = (
92
99
93
100
type execResult =
94
101
| {
95
- kind : "success" ;
96
- result : string ;
97
- }
102
+ kind : "success" ;
103
+ result : string ;
104
+ }
98
105
| {
99
- kind : "error" ;
100
- error : string ;
101
- } ;
106
+ kind : "error" ;
107
+ error : string ;
108
+ } ;
102
109
103
- type formatCodeResult = execResult ;
110
+ type formatCodeResult =
111
+ | execResult
112
+ | {
113
+ kind : "blocked-using-built-in-formatter" ;
114
+ } ;
104
115
105
116
export let formatCode = (
106
117
bscPath : p . DocumentUri | null ,
@@ -238,6 +249,9 @@ export let runAnalysisAfterSanityCheck = (
238
249
239
250
let stdout = "" ;
240
251
try {
252
+ if ( args . includes ( "completion" ) ) {
253
+ sendLogNotification ( p . MessageType . Log , `Running completion: ${ binaryPath } ${ args . join ( " " ) } ` ) ;
254
+ }
241
255
stdout = childProcess . execFileSync ( binaryPath , args , options ) . toString ( ) ;
242
256
return JSON . parse ( stdout ) ;
243
257
} catch ( e ) {
@@ -666,7 +680,7 @@ export let parseCompilerLogOutput = (
666
680
diagnostic,
667
681
diagnosticMessage,
668
682
file,
669
- range,
683
+ range
670
684
} ) ;
671
685
672
686
result [ file ] . push ( diagnostic ) ;
0 commit comments