Skip to content

Commit 6ebcb9e

Browse files
committed
use printer version returning a string so we can do the JSON escaping in the analysis bin
1 parent ac8cbb2 commit 6ebcb9e

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

analysis/src/Cli.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ let main () =
9090
| [_; "createInterface"; path; cmiFile] ->
9191
Printf.printf "\"%s\""
9292
(Json.escape (CreateInterface.command ~path ~cmiFile))
93-
| [_; "format"; path] -> Commands.format ~path
93+
| [_; "format"; path] ->
94+
Printf.printf "\"%s\"" (Json.escape (Commands.format ~path))
9495
| [_; "test"; path] -> Commands.test ~path
9596
| args when List.mem "-h" args || List.mem "--help" args -> prerr_endline help
9697
| _ ->

analysis/src/Commands.ml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,14 +256,13 @@ let format ~path =
256256
Res_driver.parsingEngine.parseImplementation ~forPrinter:true
257257
~filename:path
258258
in
259-
Res_driver.printEngine.printImplementation !Res_cli.ResClflags.width path
260-
comments structure
259+
Res_printer.printImplementation !Res_cli.ResClflags.width structure comments
261260
else if Filename.check_suffix path ".resi" then
262261
let {Res_driver.parsetree = signature; comments} =
263262
Res_driver.parsingEngine.parseInterface ~forPrinter:true ~filename:path
264263
in
265-
Res_driver.printEngine.printInterface !Res_cli.ResClflags.width path
266-
comments signature
264+
Res_printer.printInterface !Res_cli.ResClflags.width signature comments
265+
else ""
267266

268267
let test ~path =
269268
Uri2.stripPath := true;

server/src/utils.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ export let formatUsingValidBscNativePath = (
121121
let result = runAnalysisAfterSanityCheck(
122122
formatTempFileFullPath,
123123
["format", formatTempFileFullPath],
124-
false,
125124
false
126125
);
127126

@@ -144,8 +143,7 @@ export let formatUsingValidBscNativePath = (
144143
export let runAnalysisAfterSanityCheck = (
145144
filePath: p.DocumentUri,
146145
args: Array<any>,
147-
projectRequired = false,
148-
parseJson = true
146+
projectRequired = false
149147
) => {
150148
let binaryPath;
151149
if (fs.existsSync(c.analysisDevPath)) {
@@ -166,11 +164,7 @@ export let runAnalysisAfterSanityCheck = (
166164
};
167165
let stdout = childProcess.execFileSync(binaryPath, args, options);
168166

169-
if (parseJson) {
170-
return JSON.parse(stdout.toString());
171-
} else {
172-
return stdout.toString();
173-
}
167+
return JSON.parse(stdout.toString());
174168
};
175169

176170
export let runAnalysisCommand = (

0 commit comments

Comments
 (0)