Diagnose returns syntax diagnostics for the given Doris statement. Surfaces genuine lex/parse errors from the omni parser, filtering out the "not yet supported" stub messages from statement-dispatch fallthroughs.
(_ context.Context, _ base.DiagnoseContext, statement string)
| 19 | // Surfaces genuine lex/parse errors from the omni parser, filtering out |
| 20 | // the "not yet supported" stub messages from statement-dispatch fallthroughs. |
| 21 | func Diagnose(_ context.Context, _ base.DiagnoseContext, statement string) ([]base.Diagnostic, error) { |
| 22 | diags := parser.Diagnose(statement) |
| 23 | out := make([]base.Diagnostic, 0, len(diags)) |
| 24 | for _, d := range diags { |
| 25 | if strings.HasSuffix(d.Msg, "statement parsing is not yet supported") { |
| 26 | continue |
| 27 | } |
| 28 | // Convert byte offset to line/col position. |
| 29 | line, col := byteOffsetToLineCol(statement, d.Loc.Start) |
| 30 | syntaxErr := &base.SyntaxError{ |
| 31 | Position: &storepb.Position{ |
| 32 | Line: int32(line), |
| 33 | Column: int32(col), |
| 34 | }, |
| 35 | Message: d.Msg, |
| 36 | } |
| 37 | out = append(out, base.ConvertSyntaxErrorToDiagnostic(syntaxErr, statement)) |
| 38 | } |
| 39 | return out, nil |
| 40 | } |
| 41 | |
| 42 | // byteOffsetToLineCol returns the 1-based line and 1-based column for a byte |
| 43 | // offset within the statement. Counts \n as line breaks. The 1-based column |
nothing calls this directly
no test coverage detected