@@ -56,7 +56,11 @@ def SorryData.toParsedSorry {Out} [ToString Out] (fileMap : FileMap) : SorryData
5656instance : ToString ParsedSorry where
5757 toString a := ToString.toString <| ToJson.toJson a
5858
59- #check Frontend.State
59+ def Lean.Message.printIfError (m : Message) : IO Unit := do
60+ if m.severity == .error then IO.eprintln <| ← m.toString
61+
62+ def Lean.MessageLog.printErrors (m : MessageLog) : IO Unit := do
63+ for message in m.reported ++ m.unreported do message.printIfError
6064
6165/-- `extractInfoTree myLeanFile` takes as input the path to a Lean file and outputs
6266the infotrees of the file, together with the `FileMap`. -/
@@ -65,15 +69,18 @@ def extractInfoTrees (fileName : System.FilePath) : IO (FileMap × List InfoTree
6569 let inputCtx := Parser.mkInputContext input fileName.toString
6670 let (header, parserState, messages) ← Parser.parseHeader inputCtx
6771 if Lean.MessageLog.hasErrors messages then
68- IO.println s! "Ran into errors while parsing the header of { fileName} "
72+ IO.eprintln s! "Ran into errors while parsing the header of { fileName} "
73+ MessageLog.printErrors messages
6974 -- TODO: do we need to specify the main module here?
7075 let (env, messages) ← processHeader header {} messages inputCtx
7176 if Lean.MessageLog.hasErrors messages then
72- IO.println s! "Ran into errors whist processing the header of { fileName} "
77+ IO.eprintln s! "Ran into errors whist processing the header of { fileName} "
78+ MessageLog.printErrors messages
7379 let commandState := Command.mkState env messages
7480 let frontendState ← IO.processCommands inputCtx parserState commandState
7581 if Lean.MessageLog.hasErrors frontendState.commandState.messages then
76- IO.println s! "Ran into errors whist processing the commands in { fileName} "
82+ IO.eprintln s! "Ran into errors whist processing the commands in { fileName} "
83+ MessageLog.printErrors messages
7784 let fileMap := FileMap.ofString input
7885 return (fileMap, frontendState.commandState.infoState.trees.toList)
7986
@@ -117,3 +124,6 @@ def getProjectSearchPath (path : System.FilePath) : IO (System.SearchPath) := do
117124 let paths ← getAllLakePaths rootDir
118125 let originalSearchPath ← getBuiltinSearchPath (← findSysroot)
119126 return originalSearchPath.append paths.toList
127+
128+ def System.FilePath.checkOLeans (path : System.FilePath) : IO Unit := do
129+ discard <| Lean.findOLean (← moduleNameOfFileName path none)
0 commit comments