reload resets the parser's state and then parses the entire project.
(ctx context.Context)
| 359 | |
| 360 | // reload resets the parser's state and then parses the entire project. |
| 361 | func (p *Parser) reload(ctx context.Context) error { |
| 362 | // Reset state |
| 363 | p.RillYAML = nil |
| 364 | p.DotEnv = make(map[string]map[string]string) |
| 365 | p.Resources = make(map[ResourceName]*Resource) |
| 366 | p.Errors = nil |
| 367 | p.resourceNamesForDataPaths = make(map[string][]ResourceName) |
| 368 | p.resourcesForPath = make(map[string][]*Resource) |
| 369 | p.resourcesForAmbiguousRef = make(map[ResourceName][]*Resource) |
| 370 | p.insertedResources = nil |
| 371 | p.updatedResources = nil |
| 372 | p.deletedResources = nil |
| 373 | |
| 374 | // Load entire repo |
| 375 | files, err := p.Repo.ListGlob(ctx, "**/*.{env,sql,yaml,yml}", true) |
| 376 | if err != nil { |
| 377 | return fmt.Errorf("could not list project files: %w", err) |
| 378 | } |
| 379 | |
| 380 | // Build paths slice |
| 381 | paths := make([]string, 0, len(files)) |
| 382 | for _, file := range files { |
| 383 | paths = append(paths, file.Path) |
| 384 | } |
| 385 | |
| 386 | // Parse all files |
| 387 | err = p.parsePaths(ctx, paths) |
| 388 | if err != nil { |
| 389 | return err |
| 390 | } |
| 391 | |
| 392 | // Infer ambiguous refs for all inserted resources |
| 393 | for _, r := range p.insertedResources { |
| 394 | p.inferAmbiguousRefs(r) |
| 395 | } |
| 396 | |
| 397 | return nil |
| 398 | } |
| 399 | |
| 400 | // reparseExceptRillYAML re-parses the indicated file paths, updating the Parser's state. |
| 401 | // It assumes that p.RillYAML is valid and does not need to be reloaded. |
no test coverage detected