Skip to content
Snippets Groups Projects
Commit dbd6cf01 authored by David Bühler's avatar David Bühler
Browse files

[server] New GET request getMainFunction returning the current entry point.

In ivette, selects the entry point after opening new source files.
parent 70a4f653
No related branches found
No related tags found
No related merge requests found
......@@ -284,6 +284,15 @@ export const byLocation: Compare.Order<location> =
marker: byMarker,
});
const getMainFunction_internal: Server.GetRequest<null,Json.key<'#fct'>> = {
kind: Server.RqKind.GET,
name: 'kernel.ast.getMainFunction',
input: Json.jNull,
output: Json.jKey<'#fct'>('#fct'),
};
/** Get the current 'main' function. */
export const getMainFunction: Server.GetRequest<null,Json.key<'#fct'>>= getMainFunction_internal;
const getFunctions_internal: Server.GetRequest<null,Json.key<'#fct'>[]> = {
kind: Server.RqKind.GET,
name: 'kernel.ast.getFunctions',
......
......@@ -46,7 +46,8 @@ async function setFiles(): Promise<void> {
});
await Server.send(Ast.setFiles, files);
await Server.send(Ast.compute, { });
States.setSelection({fct: undefined});
const main = await Server.send(Ast.getMainFunction, { });
States.setSelection({ fct: main });
return;
}
......
......@@ -353,6 +353,12 @@ end
(* --- Functions --- *)
(* -------------------------------------------------------------------------- *)
let () = Request.register ~package
~kind:`GET ~name:"getMainFunction"
~descr:(Md.plain "Get the current 'main' function.")
~input:(module Junit) ~output:(module Kf)
(fun () -> fst (Globals.entry_point ()))
let () = Request.register ~package
~kind:`GET ~name:"getFunctions"
~descr:(Md.plain "Collect all functions in the AST")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment