|
|
|
@ -114,24 +114,25 @@ def evalHintMessage : Expr → MetaM (Array Expr → MessageData) := fun _ => pu
|
|
|
|
open Meta in
|
|
|
|
open Meta in
|
|
|
|
/-- Find all hints whose trigger matches the current goal -/
|
|
|
|
/-- Find all hints whose trigger matches the current goal -/
|
|
|
|
def findHints (goal : MVarId) (doc : FileWorker.EditableDocument) (initParams : Lsp.InitializeParams) : MetaM (Array GameHint) := do
|
|
|
|
def findHints (goal : MVarId) (doc : FileWorker.EditableDocument) (initParams : Lsp.InitializeParams) : MetaM (Array GameHint) := do
|
|
|
|
let some level ← getLevelByFileName? initParams doc.meta.mkInputContext.fileName
|
|
|
|
goal.withContext do
|
|
|
|
| throwError "Level not found: {doc.meta.mkInputContext.fileName}"
|
|
|
|
let some level ← getLevelByFileName? initParams doc.meta.mkInputContext.fileName
|
|
|
|
let hints ← level.hints.filterMapM fun hint => do
|
|
|
|
| throwError "Level not found: {doc.meta.mkInputContext.fileName}"
|
|
|
|
openAbstractCtxResult hint.goal fun hintFVars hintGoal => goal.withContext do
|
|
|
|
let hints ← level.hints.filterMapM fun hint => do
|
|
|
|
if let some fvarBij := matchExpr (← instantiateMVars $ hintGoal) (← instantiateMVars $ ← inferType $ mkMVar goal)
|
|
|
|
openAbstractCtxResult hint.goal fun hintFVars hintGoal => do
|
|
|
|
then
|
|
|
|
if let some fvarBij := matchExpr (← instantiateMVars $ hintGoal) (← instantiateMVars $ ← inferType $ mkMVar goal)
|
|
|
|
let lctx := (← goal.getDecl).lctx
|
|
|
|
|
|
|
|
if let some bij ← matchDecls hintFVars lctx.getFVars (strict := hint.strict) (initBij := fvarBij)
|
|
|
|
|
|
|
|
then
|
|
|
|
then
|
|
|
|
let userFVars := hintFVars.map fun v => bij.forward.findD v.fvarId! v.fvarId!
|
|
|
|
let lctx := (← goal.getDecl).lctx
|
|
|
|
let text := (← evalHintMessage hint.text) (userFVars.map Expr.fvar)
|
|
|
|
if let some bij ← matchDecls hintFVars lctx.getFVars (strict := hint.strict) (initBij := fvarBij)
|
|
|
|
let ctx := {env := ← getEnv, mctx := ← getMCtx, lctx := ← getLCtx, opts := {}}
|
|
|
|
then
|
|
|
|
let text ← (MessageData.withContext ctx text).toString
|
|
|
|
let userFVars := hintFVars.map fun v => bij.forward.findD v.fvarId! v.fvarId!
|
|
|
|
return some { text := text, hidden := hint.hidden }
|
|
|
|
let text := (← evalHintMessage hint.text) (userFVars.map Expr.fvar)
|
|
|
|
else return none
|
|
|
|
let ctx := {env := ← getEnv, mctx := ← getMCtx, lctx := ← getLCtx, opts := {}}
|
|
|
|
else
|
|
|
|
let text ← (MessageData.withContext ctx text).toString
|
|
|
|
return none
|
|
|
|
return some { text := text, hidden := hint.hidden }
|
|
|
|
return hints
|
|
|
|
else return none
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
return none
|
|
|
|
|
|
|
|
return hints
|
|
|
|
|
|
|
|
|
|
|
|
open RequestM in
|
|
|
|
open RequestM in
|
|
|
|
def getInteractiveGoals (p : Lsp.PlainGoalParams) : RequestM (RequestTask (Option InteractiveGoals)) := do
|
|
|
|
def getInteractiveGoals (p : Lsp.PlainGoalParams) : RequestM (RequestTask (Option InteractiveGoals)) := do
|
|
|
|
|