Skip to content

Commit

Permalink
chore: use derive handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Vtec234 committed Dec 15, 2023
1 parent 6eb12ae commit 684b8e2
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions src/Lean/Widget/UserWidget.lean
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,6 @@ Authors: E.W.Ayers, Wojciech Nawrocki
import Lean.Elab.Eval
import Lean.Server.Rpc.RequestHandling

namespace Lean.Server
open Elab Command in
/-- Derive `Lean.Server.RpcEncodable` for a type.
TODO: remove after update-stage0 -/
elab "#mkrpcenc" n:ident : command => do
elabCommand <| ← `(
namespace $n
deriving instance Lean.Server.RpcEncodable for $n
end $n
)
end Lean.Server

namespace Lean.Widget
open Meta Elab

Expand Down Expand Up @@ -207,7 +194,7 @@ def savePanelWidgetInfo [Monad m] [MonadEnv m] [MonadError m] [MonadInfoTree m]

/-! ## Retrieving panel widget instances -/

#mkrpcenc WidgetInstance
deriving instance Server.RpcEncodable for WidgetInstance

/-- Retrieve all the `UserWidgetInfo`s that intersect a given line. -/
def widgetInfosAt? (text : FileMap) (t : InfoTree) (hoverLine : Nat) : List UserWidgetInfo :=
Expand All @@ -224,12 +211,12 @@ def widgetInfosAt? (text : FileMap) (t : InfoTree) (hoverLine : Nat) : List User
structure PanelWidgetInstance extends WidgetInstance where
/-- The syntactic span in the Lean file at which the panel widget is displayed. -/
range? : Option Lsp.Range
#mkrpcenc PanelWidgetInstance
deriving Server.RpcEncodable

/-- Output of `getWidgets` RPC.-/
structure GetWidgetsResponse where
widgets : Array PanelWidgetInstance
#mkrpcenc GetWidgetsResponse
deriving Server.RpcEncodable

open Lean Server RequestM in
/-- Get the panel widgets present around a particular position. -/
Expand Down

0 comments on commit 684b8e2

Please sign in to comment.