Skip to content
Snippets Groups Projects
Commit 8b3d513d authored by Loïc Correnson's avatar Loïc Correnson Committed by David Bühler
Browse files

[server] registering type markers

parent eb435af6
No related branches found
No related tags found
No related merge requests found
......@@ -83,7 +83,7 @@ interface MarkerProps {
function Marker(props: MarkerProps): JSX.Element {
const { marker, onMarker, children } = props;
const onClick = (): void => {if (onMarker) onMarker(marker);};
const onClick = (): void => { if (onMarker) onMarker(marker); };
return (
<span
className="kernel-text-marker"
......@@ -109,7 +109,11 @@ export function Text(props: TextProps): JSX.Element {
const array = marker ? text.slice(1) : text;
const contents = React.Children.toArray(array.map(makeContents));
if (marker) {
return <Marker marker={tag} onMarker={props.onMarker}>{contents}</Marker>;
return (
<Marker marker={tag} onMarker={props.onMarker}>
{contents}
</Marker>
);
}
return <>{contents}</>;
} if (typeof text === 'string') {
......
......@@ -336,6 +336,7 @@ struct
let jterm = jmarker "term"
let jglobal = jmarker "global"
let jproperty = jmarker "property"
let jtyp = jmarker "type"
let jtype = Data.declare ~package ~name:"marker"
~descr:(Md.plain "Localizable AST markers")
......@@ -427,6 +428,7 @@ end
module KfMarker = struct
type record
let record : record Record.signature = Record.signature ()
let fct = Record.field record ~name:"fct"
~descr:(Md.plain "Function") (module Kf)
let marker = Record.field record ~name:"marker"
......@@ -435,6 +437,7 @@ module KfMarker = struct
let data =
Record.publish ~package ~name:"location"
~descr:(Md.plain "Location: function and marker") record
module R : Record.S with type r = record = (val data)
type t = kernel_function * Printer_tag.localizable
let jtype = R.jtype
......@@ -647,7 +650,9 @@ struct
let update () = Request.emit signal
let register ~id ~label ~descr ?(title = descr) ?(enable = fun _ -> true) pretty =
let register ~id ~label ~descr
?(title = descr)
?(enable = fun _ -> true) pretty =
let rank = incr rankId ; !rankId in
let info = { id ; rank ; label ; descr; title ; enable ; pretty } in
if Hashtbl.mem registry id then
......
......@@ -46,6 +46,7 @@ sig
val jterm : jtype
val jglobal : jtype
val jproperty : jtype
val jtyp : jtype
val create : t -> string
(** Memoized unique identifier. *)
......
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