Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions Marksman/Doc.fs
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,30 @@ type Doc = {
| :? Doc as other -> (this :> IComparable<_>).CompareTo(other)
| _ -> failwith $"Comparison with non-Doc type: {obj}"

exception DocumentError of doc: RootedRelPath * cause: exn with
override this.Message =
$"Error while processing {RootedRelPath.filename this.doc}{Environment.NewLine}{this.cause.Message}"


module Doc =
open Marksman.Syms

let logger = LogProvider.getLoggerByName "Doc"

let mk parserSettings id version text =
let structure = Parser.parse parserSettings text
let index = Index.ofCst (Structure.concreteElements structure)

{
id = id
version = version
text = text
structure = structure
index = index
}
try
let structure = Parser.parse parserSettings text
let index = Index.ofCst (Structure.concreteElements structure)

{
id = id
version = version
text = text
structure = structure
index = index
}
with exn ->
raise (DocumentError(id.Path, exn))

let id { id = id } = id
let text doc = doc.text
Expand Down