@@ -7,33 +7,45 @@ import (
77 "iter"
88
99 "github.com/mendixlabs/mxcli/mdl/catalog"
10- "github.com/mendixlabs/mxcli/sdk/mpr"
10+ "github.com/mendixlabs/mxcli/mdl/types"
11+ "github.com/mendixlabs/mxcli/model"
12+ "github.com/mendixlabs/mxcli/sdk/microflows"
13+ "github.com/mendixlabs/mxcli/sdk/pages"
14+ "github.com/mendixlabs/mxcli/sdk/security"
1115)
1216
17+ // LintReader provides read access to MPR document data needed by lint rules.
18+ // Implemented by MprBackend (and any backend satisfying these signatures).
19+ type LintReader interface {
20+ GetMicroflow (id model.ID ) (* microflows.Microflow , error )
21+ GetProjectSecurity () (* security.ProjectSecurity , error )
22+ GetNavigation () (* types.NavigationDocument , error )
23+ ListPages () ([]* pages.Page , error )
24+ ListModules () ([]* model.Module , error )
25+ ListFolders () ([]* types.FolderInfo , error )
26+ GetRawUnit (id model.ID ) (map [string ]any , error )
27+ }
28+
1329// LintContext wraps a catalog and provides rule-friendly APIs.
1430type LintContext struct {
1531 catalog * catalog.Catalog
1632 db catalog.CatalogDB
1733 excluded map [string ]bool
18- reader * mpr.Reader
19- }
20-
21- // SetReader sets the MPR reader for rules that need to inspect full document data.
22- func (ctx * LintContext ) SetReader (reader * mpr.Reader ) {
23- ctx .reader = reader
34+ reader LintReader
2435}
2536
26- // Reader returns the MPR reader , or nil if not set.
27- func (ctx * LintContext ) Reader () * mpr. Reader {
37+ // Reader returns the LintReader , or nil if not set.
38+ func (ctx * LintContext ) Reader () LintReader {
2839 return ctx .reader
2940}
3041
31- // NewLintContext creates a new LintContext from a catalog.
32- func NewLintContext (cat * catalog.Catalog ) * LintContext {
42+ // NewLintContext creates a new LintContext from a catalog and an optional reader .
43+ func NewLintContext (cat * catalog.Catalog , reader LintReader ) * LintContext {
3344 return & LintContext {
3445 catalog : cat ,
3546 db : cat .CatalogDB (),
3647 excluded : make (map [string ]bool ),
48+ reader : reader ,
3749 }
3850}
3951
0 commit comments