From da74258dd192fc03b4a43aca818ca815466312f8 Mon Sep 17 00:00:00 2001 From: Leni Aniva Date: Tue, 5 Dec 2023 20:20:08 -0800 Subject: [PATCH] feat!: Display public name only if name is private --- Pantograph.lean | 2 +- Pantograph/Protocol.lean | 3 ++- Test/Integration.lean | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Pantograph.lean b/Pantograph.lean index cc4096d..958e43c 100644 --- a/Pantograph.lean +++ b/Pantograph.lean @@ -85,7 +85,7 @@ def execute (command: Protocol.Command): MainM Lean.Json := do return .ok { type := ← serialize_expression state.options info.type, value? := ← value?.mapM (λ v => serialize_expression state.options v), - isPrivate := Lean.isPrivateName name, + publicName? := Lean.privateToUserName? name |>.map (·.toString), typeDependency? := if args.dependency?.getD false then .some <| info.type.getUsedConstants.map (λ n => name_to_ast n) else .none, valueDependency? := if args.dependency?.getD false then info.value?.map (·.getUsedConstants.map (λ n => name_to_ast n)) else .none, module? := module? diff --git a/Pantograph/Protocol.lean b/Pantograph/Protocol.lean index f99acb0..582ee1d 100644 --- a/Pantograph/Protocol.lean +++ b/Pantograph/Protocol.lean @@ -120,7 +120,8 @@ structure LibInspectResult where type: Expression value?: Option Expression := .none module?: Option String - isPrivate: Bool + -- If the name is private, displays the public facing name + publicName?: Option String := .none typeDependency?: Option (Array String) := .none valueDependency?: Option (Array String) := .none deriving Lean.ToJson diff --git a/Test/Integration.lean b/Test/Integration.lean index bfe1766..65c2da6 100644 --- a/Test/Integration.lean +++ b/Test/Integration.lean @@ -52,7 +52,7 @@ def test_option_modify : IO LSpec.TestSeq := subroutine_step "lib.inspect" [("name", .str "Nat.add_one")] (Lean.toJson ({ - type := { pp? }, module?, isPrivate := false }: + type := { pp? }, module? }: Protocol.LibInspectResult)), subroutine_step "options.set" [("printExprAST", .bool true)] @@ -61,7 +61,7 @@ def test_option_modify : IO LSpec.TestSeq := subroutine_step "lib.inspect" [("name", .str "Nat.add_one")] (Lean.toJson ({ - type := { pp?, sexp? }, module?, isPrivate := false }: + type := { pp?, sexp? }, module? }: Protocol.LibInspectResult)), subroutine_step "options.print" []