(ctx context.Context, name, dir string, sql config.SQL, combo config.CombinedSettings, parserOpts opts.Parser, stderr io.Writer)
| 294 | } |
| 295 | |
| 296 | func parse(ctx context.Context, name, dir string, sql config.SQL, combo config.CombinedSettings, parserOpts opts.Parser, stderr io.Writer) (*compiler.Result, bool) { |
| 297 | defer trace.StartRegion(ctx, "parse").End() |
| 298 | c, err := compiler.NewCompiler(sql, combo, parserOpts) |
| 299 | defer func() { |
| 300 | if c != nil { |
| 301 | c.Close(ctx) |
| 302 | } |
| 303 | }() |
| 304 | if err != nil { |
| 305 | fmt.Fprintf(stderr, "error creating compiler: %s\n", err) |
| 306 | return nil, true |
| 307 | } |
| 308 | if err := c.ParseCatalog(sql.Schema); err != nil { |
| 309 | fmt.Fprintf(stderr, "# package %s\n", name) |
| 310 | if parserErr, ok := err.(*multierr.Error); ok { |
| 311 | for _, fileErr := range parserErr.Errs() { |
| 312 | printFileErr(stderr, dir, fileErr) |
| 313 | } |
| 314 | } else { |
| 315 | fmt.Fprintf(stderr, "error parsing schema: %s\n", err) |
| 316 | } |
| 317 | return nil, true |
| 318 | } |
| 319 | if parserOpts.Debug.DumpCatalog { |
| 320 | debug.Dump(c.Catalog()) |
| 321 | } |
| 322 | if err := c.ParseQueries(sql.Queries, parserOpts); err != nil { |
| 323 | fmt.Fprintf(stderr, "# package %s\n", name) |
| 324 | if parserErr, ok := err.(*multierr.Error); ok { |
| 325 | for _, fileErr := range parserErr.Errs() { |
| 326 | printFileErr(stderr, dir, fileErr) |
| 327 | } |
| 328 | } else { |
| 329 | fmt.Fprintf(stderr, "error parsing queries: %s\n", err) |
| 330 | } |
| 331 | return nil, true |
| 332 | } |
| 333 | return c.Result(), false |
| 334 | } |
| 335 | |
| 336 | func codegen(ctx context.Context, combo config.CombinedSettings, sql OutputPair, result *compiler.Result) (string, *plugin.GenerateResponse, error) { |
| 337 | defer trace.StartRegion(ctx, "codegen").End() |
no test coverage detected