all repos

clerk @ 1b9e6e1f8922a34b89b80ea1c5b55997326c3aa5

missing tooling for ledger/hledger

clerk/internal/lsp/diagnostics_test.go (view raw)

Oleksandr Smirnov Oleksandr Smirnov
olexsmir@gmail.com
lsp: comply with lsp3.18 lifecycle, 29 days ago
1
package lsp
2
3
import (
4
	"testing"
5
6
	"olexsmir.xyz/clerk/internal/analyzer"
7
	"olexsmir.xyz/clerk/internal/linter"
8
	"olexsmir.xyz/clerk/journal"
9
)
10
11
func BenchmarkDiagnostics(b *testing.B) {
12
	content := openJournal(b, "../../journal/testdata/journals/actual-1ktxns-100accts.journal")
13
	srv := newServer(b)
14
15
	lint, err := linter.NewLinter(srv.server.settings.Linter)
16
	if err != nil {
17
		b.Fatal(err)
18
	}
19
20
	// Per-edit cost: a fresh loader skips the parse cache, so each iteration re-parses,
21
	// builds the per-file indices with the analysis, then lints and groups findings.
22
	b.ReportAllocs()
23
	b.ResetTimer()
24
	for b.Loop() {
25
		an := analyzer.Build(journal.NewLoader().ResolveBytes("/test.journal", []byte(content)))
26
		lines := buildFileIdx(an)
27
28
		finds := dedupFinds(lint.Run(an))
29
		srv.server.assignSeverities(finds)
30
		_ = srv.server.groupFindsByFile(finds, lines)
31
	}
32
}