MCPcopy Index your code
hub / github.com/rilldata/rill / Reparse

Method Reparse

runtime/parser/parser.go:254–287  ·  view source on GitHub ↗

Reparse re-parses the indicated file paths, updating the Parser's state. If rill.yaml has previously errored, or if rill.yaml is included in paths, it will reload the entire project. If a previous call to Reparse has returned an error, the Parser may not be accessed or called again.

(ctx context.Context, paths []string)

Source from the content-addressed store, hash-verified

252// If rill.yaml has previously errored, or if rill.yaml is included in paths, it will reload the entire project.
253// If a previous call to Reparse has returned an error, the Parser may not be accessed or called again.
254func (p *Parser) Reparse(ctx context.Context, paths []string) (*Diff, error) {
255 var changedRillYAML bool
256 for _, path := range paths {
257 if !pathIsRillYAML(path) {
258 continue
259 }
260 oldRillYAML := p.RillYAML
261 err := p.parseRillYAML(ctx, path)
262 if err == nil {
263 // Watcher sends multiple events for a single edit. We want to only restart the controller when rill.yaml actually changes.
264 // So we check the new rill.yaml contents against the contents stored in parser state.
265 changedRillYAML = !reflect.DeepEqual(oldRillYAML, p.RillYAML)
266 } else {
267 // any error including parse error means rill.yaml changed
268 changedRillYAML = true
269 }
270 break
271 }
272
273 if changedRillYAML {
274 err := p.reload(ctx)
275 if err != nil {
276 return nil, err
277 }
278 return &Diff{Reloaded: true}, nil
279 }
280
281 // If rill.yaml previously errored, we're not going to reparse anything until it's changed, at which point we'll reload the entire project.
282 if p.RillYAML == nil {
283 return &Diff{Skipped: true}, nil
284 }
285
286 return p.reparseExceptRillYAML(ctx, paths)
287}
288
289// IsSkippable returns true if the path will be skipped by Reparse.
290// It's useful for callers to avoid triggering a reparse when they know the path is not relevant.

Callers 10

TestReparseFunction · 0.80
TestReparseNameCollisionFunction · 0.80
TestReparseRillYAMLFunction · 0.80
TestRefInferrenceFunction · 0.80
TestConnectorDeletionFunction · 0.80
BenchmarkReparseFunction · 0.80
TestEnvReparseFunction · 0.80
ReconcileMethod · 0.80

Calls 4

parseRillYAMLMethod · 0.95
reloadMethod · 0.95
reparseExceptRillYAMLMethod · 0.95
pathIsRillYAMLFunction · 0.85

Tested by 9

TestReparseFunction · 0.64
TestReparseNameCollisionFunction · 0.64
TestReparseRillYAMLFunction · 0.64
TestRefInferrenceFunction · 0.64
TestConnectorDeletionFunction · 0.64
BenchmarkReparseFunction · 0.64
TestEnvReparseFunction · 0.64