feat: rpc attribute

Functions can now be marked with the `@[rpc]` attribute, which
registers the function as an RpcProcedure that can be used to
communicate with the code editor and infoview.
This commit is contained in:
E.W.Ayers 2022-05-17 18:26:27 -04:00 committed by Sebastian Ullrich
parent d13fac6f45
commit 3bdb98e5ee

View file

@ -121,4 +121,15 @@ def registerRpcProcedure (method : Name) : CoreM Unit := do
}
setEnv <| userRpcProcedures.insert (← getEnv) method wrappedName
builtin_initialize registerBuiltinAttribute {
name := `rpc
descr := "Marks a function as a Lean server RPC method.
Shorthand for `registerRpcProcedure`.
The function must have type `α → RequestM (RequestTask β)` with
RpcEncodings for both α and β."
applicationTime := AttributeApplicationTime.afterCompilation
add := fun decl stx kind =>
registerRpcProcedure decl
}
end Lean.Server