Skip to content

Commit 3ace135

Browse files
committed
Log completion analysis invocations
1 parent 7de9585 commit 3ace135

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

server/src/utils.ts

+22-8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ import { reportError } from "./errorReporter";
1616
import config from "./config";
1717
import { 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+
1926
let tempFilePrefix = "rescript_format_file_" + process.pid + "_";
2027
let tempFileId = 0;
2128

@@ -92,15 +99,19 @@ export let findBinary = (
9299

93100
type 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

105116
export 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

Comments
 (0)