|
|
|
@ -117,11 +117,9 @@ def findMessages (goal : MVarId) (doc : FileWorker.EditableDocument) (hLog : IO.
|
|
|
|
else return none
|
|
|
|
else return none
|
|
|
|
return messages
|
|
|
|
return messages
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
open RequestM in
|
|
|
|
/-- Get goals and messages at a given position -/
|
|
|
|
def getInteractiveGoals (p : Lsp.PlainGoalParams) : RequestM (RequestTask (Option Widget.InteractiveGoals)) := do
|
|
|
|
def getGoals (p : Lsp.PlainGoalParams) : RequestM (RequestTask (Option PlainGoal)) := do
|
|
|
|
|
|
|
|
let doc ← readDoc
|
|
|
|
let doc ← readDoc
|
|
|
|
let hLog := (← read).hLog
|
|
|
|
|
|
|
|
let text := doc.meta.text
|
|
|
|
let text := doc.meta.text
|
|
|
|
let hoverPos := text.lspPosToUtf8Pos p.position
|
|
|
|
let hoverPos := text.lspPosToUtf8Pos p.position
|
|
|
|
-- TODO: I couldn't find a good condition to find the correct snap. So we are looking
|
|
|
|
-- TODO: I couldn't find a good condition to find the correct snap. So we are looking
|
|
|
|
@ -129,24 +127,38 @@ def getGoals (p : Lsp.PlainGoalParams) : RequestM (RequestTask (Option PlainGoal
|
|
|
|
withWaitFindSnap doc (fun s => ¬ (s.infoTree.goalsAt? doc.meta.text hoverPos).isEmpty)
|
|
|
|
withWaitFindSnap doc (fun s => ¬ (s.infoTree.goalsAt? doc.meta.text hoverPos).isEmpty)
|
|
|
|
(notFoundX := return none) fun snap => do
|
|
|
|
(notFoundX := return none) fun snap => do
|
|
|
|
if let rs@(_ :: _) := snap.infoTree.goalsAt? doc.meta.text hoverPos then
|
|
|
|
if let rs@(_ :: _) := snap.infoTree.goalsAt? doc.meta.text hoverPos then
|
|
|
|
let goals ← rs.mapM fun { ctxInfo := ci, tacticInfo := ti, useAfter := useAfter, .. } => do
|
|
|
|
let goals : List Widget.InteractiveGoals ← rs.mapM fun { ctxInfo := ci, tacticInfo := ti, useAfter := useAfter, .. } => do
|
|
|
|
let ci := if useAfter then { ci with mctx := ti.mctxAfter } else { ci with mctx := ti.mctxBefore }
|
|
|
|
let ciAfter := { ci with mctx := ti.mctxAfter }
|
|
|
|
let goals := List.toArray <| if useAfter then ti.goalsAfter else ti.goalsBefore
|
|
|
|
let ci := if useAfter then ciAfter else { ci with mctx := ti.mctxBefore }
|
|
|
|
let goals ← ci.runMetaM {} $ goals.mapM fun goal => do
|
|
|
|
-- compute the interactive goals
|
|
|
|
let messages ← findMessages goal doc hLog
|
|
|
|
let goals ← ci.runMetaM {} (do
|
|
|
|
return ← goal.toGameGoal messages
|
|
|
|
let goals := List.toArray <| if useAfter then ti.goalsAfter else ti.goalsBefore
|
|
|
|
|
|
|
|
let goals ← goals.mapM Widget.goalToInteractive
|
|
|
|
|
|
|
|
return {goals}
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
-- compute the goal diff
|
|
|
|
|
|
|
|
let goals ← ciAfter.runMetaM {} (do
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
Widget.diffInteractiveGoals useAfter ti goals
|
|
|
|
|
|
|
|
catch _ =>
|
|
|
|
|
|
|
|
-- fail silently, since this is just a bonus feature
|
|
|
|
|
|
|
|
return goals
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
-- TODO: add hints
|
|
|
|
|
|
|
|
-- let goals ← ci.runMetaM {} $ goals.mapM fun goal => do
|
|
|
|
|
|
|
|
-- let messages ← findMessages goal doc hLog
|
|
|
|
|
|
|
|
-- return ← goal.toGameGoal messages
|
|
|
|
return goals
|
|
|
|
return goals
|
|
|
|
return some { goals := goals.foldl (· ++ ·) ∅ }
|
|
|
|
return some <| goals.foldl (· ++ ·) ∅
|
|
|
|
else
|
|
|
|
else
|
|
|
|
return none
|
|
|
|
return none
|
|
|
|
|
|
|
|
|
|
|
|
builtin_initialize
|
|
|
|
builtin_initialize
|
|
|
|
registerBuiltinRpcProcedure
|
|
|
|
registerBuiltinRpcProcedure
|
|
|
|
`Game.getGoals
|
|
|
|
`Game.getInteractiveGoals
|
|
|
|
Lsp.PlainGoalParams
|
|
|
|
Lsp.PlainGoalParams
|
|
|
|
(Option PlainGoal)
|
|
|
|
(Option InteractiveGoals)
|
|
|
|
getGoals
|
|
|
|
getInteractiveGoals
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
structure Diagnostic where
|
|
|
|
structure Diagnostic where
|
|
|
|
severity : Option Lean.Lsp.DiagnosticSeverity
|
|
|
|
severity : Option Lean.Lsp.DiagnosticSeverity
|
|
|
|
|