chore: Version 0.3 #136
|
@ -58,7 +58,7 @@ def inspect (args: Protocol.EnvInspect) (options: @&Protocol.Options): CoreM (Pr
|
||||||
| none => return .error $ Protocol.errorIndex s!"Symbol not found {args.name}"
|
| none => return .error $ Protocol.errorIndex s!"Symbol not found {args.name}"
|
||||||
| some info => pure info
|
| some info => pure info
|
||||||
let module? := env.getModuleIdxFor? name >>=
|
let module? := env.getModuleIdxFor? name >>=
|
||||||
(λ idx => env.allImportedModuleNames.get? idx.toNat) |>.map toString
|
(λ idx => env.allImportedModuleNames.get? idx.toNat)
|
||||||
let value? := match args.value?, info with
|
let value? := match args.value?, info with
|
||||||
| .some true, _ => info.value?
|
| .some true, _ => info.value?
|
||||||
| .some false, _ => .none
|
| .some false, _ => .none
|
||||||
|
@ -80,7 +80,7 @@ def inspect (args: Protocol.EnvInspect) (options: @&Protocol.Options): CoreM (Pr
|
||||||
then value?.map (λ e =>
|
then value?.map (λ e =>
|
||||||
e.getUsedConstants.filter (!isNameInternal ·) |>.map (λ n => serializeName n) )
|
e.getUsedConstants.filter (!isNameInternal ·) |>.map (λ n => serializeName n) )
|
||||||
else .none,
|
else .none,
|
||||||
module? := module?
|
module? := module?.map (·.toString)
|
||||||
}
|
}
|
||||||
let result ← match info with
|
let result ← match info with
|
||||||
| .inductInfo induct => pure { core with inductInfo? := .some {
|
| .inductInfo induct => pure { core with inductInfo? := .some {
|
||||||
|
@ -113,6 +113,20 @@ def inspect (args: Protocol.EnvInspect) (options: @&Protocol.Options): CoreM (Pr
|
||||||
k := r.k,
|
k := r.k,
|
||||||
} }
|
} }
|
||||||
| _ => pure core
|
| _ => pure core
|
||||||
|
let result ← if args.source?.getD false then
|
||||||
|
let searchPath ← searchPathRef.get
|
||||||
|
let sourceUri? ← module?.bindM (Server.documentUriFromModule searchPath ·)
|
||||||
|
let declRange? ← findDeclarationRanges? name
|
||||||
|
let sourceStart? := declRange?.map (·.range.pos)
|
||||||
|
let sourceEnd? := declRange?.map (·.range.endPos)
|
||||||
|
.pure {
|
||||||
|
result with
|
||||||
|
sourceUri?,
|
||||||
|
sourceStart?,
|
||||||
|
sourceEnd?,
|
||||||
|
}
|
||||||
|
else
|
||||||
|
.pure result
|
||||||
return .ok result
|
return .ok result
|
||||||
def addDecl (args: Protocol.EnvAdd): CoreM (Protocol.CR Protocol.EnvAddResult) := do
|
def addDecl (args: Protocol.EnvAdd): CoreM (Protocol.CR Protocol.EnvAddResult) := do
|
||||||
let env ← Lean.MonadEnv.getEnv
|
let env ← Lean.MonadEnv.getEnv
|
||||||
|
|
|
@ -5,6 +5,7 @@ Note that no command other than `InteractionError` may have `error` as one of
|
||||||
its field names to avoid confusion with error messages generated by the REPL.
|
its field names to avoid confusion with error messages generated by the REPL.
|
||||||
-/
|
-/
|
||||||
import Lean.Data.Json
|
import Lean.Data.Json
|
||||||
|
import Lean.Data.Position
|
||||||
|
|
||||||
namespace Pantograph.Protocol
|
namespace Pantograph.Protocol
|
||||||
|
|
||||||
|
@ -121,11 +122,13 @@ structure EnvCatalogResult where
|
||||||
-- Print the type of a symbol
|
-- Print the type of a symbol
|
||||||
structure EnvInspect where
|
structure EnvInspect where
|
||||||
name: String
|
name: String
|
||||||
-- If true/false, show/hide the value expressions; By default definitions
|
-- Show the value expressions; By default definitions values are shown and
|
||||||
-- values are shown and theorem values are hidden.
|
-- theorem values are hidden.
|
||||||
value?: Option Bool := .some false
|
value?: Option Bool := .some false
|
||||||
-- If true, show the type and value dependencies
|
-- Show the type and value dependencies
|
||||||
dependency?: Option Bool := .some false
|
dependency?: Option Bool := .some false
|
||||||
|
-- Show source location
|
||||||
|
source?: Option Bool := .some false
|
||||||
deriving Lean.FromJson
|
deriving Lean.FromJson
|
||||||
-- See `InductiveVal`
|
-- See `InductiveVal`
|
||||||
structure InductInfo where
|
structure InductInfo where
|
||||||
|
@ -172,6 +175,10 @@ structure EnvInspectResult where
|
||||||
inductInfo?: Option InductInfo := .none
|
inductInfo?: Option InductInfo := .none
|
||||||
constructorInfo?: Option ConstructorInfo := .none
|
constructorInfo?: Option ConstructorInfo := .none
|
||||||
recursorInfo?: Option RecursorInfo := .none
|
recursorInfo?: Option RecursorInfo := .none
|
||||||
|
|
||||||
|
sourceUri?: Option String := .none
|
||||||
|
sourceStart?: Option Lean.Position := .none
|
||||||
|
sourceEnd?: Option Lean.Position := .none
|
||||||
deriving Lean.ToJson
|
deriving Lean.ToJson
|
||||||
|
|
||||||
structure EnvAdd where
|
structure EnvAdd where
|
||||||
|
|
Loading…
Reference in New Issue