diff --git a/errgoengine.go b/errgoengine.go index 4c645e8..80c5f6c 100644 --- a/errgoengine.go +++ b/errgoengine.go @@ -200,6 +200,11 @@ func ParseFiles(contextData *ContextData, defaultLanguage *Language, files fs.Re // check if document already exists existingDoc, docExists := contextData.Documents[path] + if docExists && existingDoc.BytesContentEquals(contents) { + // do not parse if content is the same + continue + } + // check matched languages selectedLanguage := defaultLanguage if docExists { diff --git a/source.go b/source.go index d7f0754..0569a3a 100644 --- a/source.go +++ b/source.go @@ -504,6 +504,14 @@ type Document struct { Tree *sitter.Tree } +func (doc *Document) StringContentEquals(str string) bool { + return doc.Contents == str +} + +func (doc *Document) BytesContentEquals(cnt []byte) bool { + return doc.Contents == string(cnt) +} + func (doc *Document) RootNode() SyntaxNode { return WrapNode(doc, doc.Tree.RootNode()) }