@@ -16,6 +16,13 @@ import { reportError } from "./errorReporter";
1616import config from "./config" ;
1717import { filesDiagnostics , projectsFiles } from "./projectFiles" ;
1818
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+
1926let tempFilePrefix = "rescript_format_file_" + process . pid + "_" ;
2027let tempFileId = 0 ;
2128
@@ -92,15 +99,19 @@ export let findBinary = (
9299
93100type execResult =
94101 | {
95- kind : "success" ;
96- result : string ;
97- }
102+ kind : "success" ;
103+ result : string ;
104+ }
98105 | {
99- kind : "error" ;
100- error : string ;
101- } ;
106+ kind : "error" ;
107+ error : string ;
108+ } ;
102109
103- type formatCodeResult = execResult ;
110+ type formatCodeResult =
111+ | execResult
112+ | {
113+ kind : "blocked-using-built-in-formatter" ;
114+ } ;
104115
105116export let formatCode = (
106117 bscPath : p . DocumentUri | null ,
@@ -238,6 +249,9 @@ export let runAnalysisAfterSanityCheck = (
238249
239250 let stdout = "" ;
240251 try {
252+ if ( args . includes ( "completion" ) ) {
253+ sendLogNotification ( p . MessageType . Log , `Running completion: ${ binaryPath } ${ args . join ( " " ) } ` ) ;
254+ }
241255 stdout = childProcess . execFileSync ( binaryPath , args , options ) . toString ( ) ;
242256 return JSON . parse ( stdout ) ;
243257 } catch ( e ) {
@@ -666,7 +680,7 @@ export let parseCompilerLogOutput = (
666680 diagnostic,
667681 diagnosticMessage,
668682 file,
669- range,
683+ range
670684 } ) ;
671685
672686 result [ file ] . push ( diagnostic ) ;
0 commit comments