diff --git a/experimental/parser/diagnostics_internal.go b/experimental/parser/diagnostics_internal.go index 92e82ab3..04204f88 100644 --- a/experimental/parser/diagnostics_internal.go +++ b/experimental/parser/diagnostics_internal.go @@ -15,8 +15,16 @@ package parser import ( + "fmt" + "unicode" + "unicode/utf8" + "github.com/bufbuild/protocompile/experimental/internal/taxa" "github.com/bufbuild/protocompile/experimental/report" + "github.com/bufbuild/protocompile/experimental/token" + "github.com/bufbuild/protocompile/internal/ext/iterx" + "github.com/bufbuild/protocompile/internal/ext/slicesx" + "github.com/bufbuild/protocompile/internal/ext/stringsx" ) // errUnexpected is a low-level parser error for when we hit a token we don't @@ -36,6 +44,27 @@ type errUnexpected struct { // description. want taxa.Set got any + + // If nonempty, inserting this text will be suggested at the given offset. + insert string + insertAt int + insertJustify int + stream *token.Stream +} + +// errUnexpectedEOF is a helper for constructing EOF diagnostics that need to +// provide *no* suggestions. This is used in places where any suggestion we +// could provide would be nonsensical. +func errUnexpectedEOF(c *token.Cursor, where taxa.Place) errUnexpected { + tok, span := c.Clone().SeekToEnd() + if tok.IsZero() { + return errUnexpected{ + what: span, + where: where, + got: taxa.EOF, + } + } + return errUnexpected{what: tok, where: where} } func (e errUnexpected) Diagnose(d *report.Diagnostic) { @@ -54,9 +83,10 @@ func (e errUnexpected) Diagnose(d *report.Diagnostic) { message = report.Message("unexpected %v %v", got, e.where) } - snippet := report.Snippet(e.what) + what := e.what.Span() + snippet := report.Snippet(what) if e.want.Len() > 0 { - snippet = report.Snippetf(e.what, "expected %v", e.want.Join("or")) + snippet = report.Snippetf(what, "expected %v", e.want.Join("or")) } d.Apply( @@ -64,6 +94,19 @@ func (e errUnexpected) Diagnose(d *report.Diagnostic) { snippet, report.Snippetf(e.prev, "previous %v is here", e.where.Subject()), ) + + if e.insert != "" { + want, _ := iterx.First(e.want.All()) + d.Apply(justify( + e.stream, + what, + fmt.Sprintf("consider inserting a %v", want), + justified{ + report.Edit{Replace: e.insert}, + e.insertJustify, + }, + )) + } } // errMoreThanOne is used to diagnose the occurrence of some construct more @@ -85,3 +128,111 @@ func (e errMoreThanOne) Diagnose(d *report.Diagnostic) { report.Snippetf(e.first, "first one is here"), ) } + +const ( + justifyNone int = iota + justifyBetween + justifyRight + justifyLeft +) + +type justified struct { + report.Edit + justify int +} + +func justify(stream *token.Stream, span report.Span, message string, edits ...justified) report.DiagnosticOption { + text := span.File.Text() + for i := range edits { + e := &edits[i] + // Convert the edits to absolute offsets. + e.Start += span.Start + e.End += span.Start + empty := e.Start == e.End + + spaceAfter := func(text string, idx int) int { + r, ok := stringsx.Rune(text, idx) + if !ok || !unicode.IsSpace(r) { + return 0 + } + return utf8.RuneLen(r) + } + spaceBefore := func(text string, idx int) int { + r, ok := stringsx.PrevRune(text, idx) + if !ok || !unicode.IsSpace(r) { + return 0 + } + return utf8.RuneLen(r) + } + + switch edits[i].justify { + case justifyBetween: + // If possible, shift the offset such that it is surrounded by + // whitespace. However, this is not always possible, in which case we + // must add whitespace to text. + prev := spaceBefore(text, e.Start) + next := spaceAfter(text, e.End) + switch { + case prev > 0 && next > 0: + // Nothing to do here. + + case empty && prev > 0 && spaceBefore(text, e.Start-prev) > 0: + e.Start -= prev + e.End -= prev + case prev > 0: + e.Replace += " " + + case empty && next > 0 && spaceAfter(text, e.End+next) > 0: + e.Start += next + e.End += next + case next > 0: + e.Replace = " " + e.Replace + + default: + // We're crammed between non-whitespace. + e.Replace = " " + e.Replace + " " + } + + case justifyLeft: + // Get the token at the start of the span. + start, end := stream.Around(e.Start) + if end.IsZero() { + break + } + + c := token.NewCursorAt(start) + // Seek to the previous unskippable token, and use its end as + // the start of the justification. + e.Start = c.Prev().Span().End + if empty { + e.End = e.Start + } + + case justifyRight: + // Identical to the above, but reversed. + start, end := stream.Around(e.Start) + if start.IsZero() { + break + } + + c := token.NewCursorAt(end) + e.End = c.Next().Span().Start + if empty { + e.Start = e.End + } + } + } + + span = report.JoinSeq(iterx.Map(slicesx.Values(edits), func(j justified) report.Span { + return span.File.Span(j.Start, j.End) + })) + return report.SuggestEdits( + span, message, + slicesx.Collect(iterx.Map(slicesx.Values(edits), + func(j justified) report.Edit { + j.Start -= span.Start + j.End -= span.Start + return j.Edit + }))..., + ) +} diff --git a/experimental/parser/lex_string.go b/experimental/parser/lex_string.go index 7305878d..caceeff6 100644 --- a/experimental/parser/lex_string.go +++ b/experimental/parser/lex_string.go @@ -42,7 +42,7 @@ func lexString(l *lexer) token.Token { } cursor := l.cursor - sc := lexStringContent(l) + sc := lexStringContent(quote, l) if sc.isEscape && !haveEsc { // If we saw our first escape, spill the string into the buffer // up to just before the escape. @@ -79,14 +79,20 @@ type stringContent struct { // lexStringContent lexes a single logical rune's worth of content for a quoted // string. -func lexStringContent(l *lexer) (sc stringContent) { +func lexStringContent(_ rune, l *lexer) (sc stringContent) { start := l.cursor r := l.Pop() switch { case r == 0: + esc := l.SpanFrom(l.cursor - utf8.RuneLen(r)) l.Errorf("unescaped NUL bytes are not permitted in string literals").Apply( - report.Snippetf(l.SpanFrom(l.cursor-utf8.RuneLen(r)), "replace this with `\\0` or `\\x00`"), + report.Snippet(esc), + report.SuggestEdits(esc, "replace it with `\\0` or `\\x00`", report.Edit{ + Start: 0, + End: 1, + Replace: "\\0", + }), ) case r == '\n': // TODO: This diagnostic is simply user-hostile. We should remove it. @@ -98,10 +104,10 @@ func lexStringContent(l *lexer) (sc stringContent) { // Many programming languages have since thoughtlessly copied this // choice, including Protobuf, whose lexical morphology is almost // exactly C's). + nl := l.SpanFrom(l.cursor - utf8.RuneLen(r)) l.Errorf("unescaped newlines are not permitted in string literals").Apply( - // Not to mention, this diagnostic is not ideal: we should probably - // tell users to split the string into multiple quoted fragments. - report.Snippetf(l.SpanFrom(l.cursor-utf8.RuneLen(r)), "replace this with `\\n`"), + report.Snippet(nl), + report.Helpf("consider splitting this into two adjacent string literals"), ) case report.NonPrint(r): // Warn if the user has a non-printable character in their string that isn't @@ -116,8 +122,14 @@ func lexStringContent(l *lexer) (sc stringContent) { escape = fmt.Sprintf(`\U%08x`, r) } + esc := l.SpanFrom(l.cursor - utf8.RuneLen(r)) l.Warnf("non-printable character in string literal").Apply( - report.Snippetf(l.SpanFrom(l.cursor-utf8.RuneLen(r)), "help: consider escaping this with e.g. `%s` instead", escape), + report.Snippet(esc), + report.SuggestEdits(esc, "consider escaping it", report.Edit{ + Start: 0, + End: len(esc.Text()), + Replace: escape, + }), ) } diff --git a/experimental/parser/parse_decl.go b/experimental/parser/parse_decl.go index ad7507b0..fb2574bc 100644 --- a/experimental/parser/parse_decl.go +++ b/experimental/parser/parse_decl.go @@ -121,32 +121,48 @@ func parseDecl(p *parser, c *token.Cursor, in taxa.Noun) ast.DeclAny { in = taxa.Edition } - eq, err := p.Punct(c, "=", in.In()) - args.Equals = eq - if err != nil { - p.Error(err) - } - - // Regardless of if we see an = sign, try to parse an expression if we - // can. - if !args.Equals.IsZero() || canStartExpr(c.Peek()) { - args.Value = parseExpr(p, c, in.In()) - } + if c.Done() { + // If we see an EOF at this point, suggestions from the next + // few stanzas will be garbage. + p.Error(errUnexpectedEOF(c, in.In())) + } else { + eq, err := punctParser{ + parser: p, c: c, + want: "=", + where: in.In(), + insert: justifyBetween, + }.parse() + args.Equals = eq + if err != nil { + p.Error(err) + } - args.Options = tryParseOptions(p, c, in) + // Regardless of if we see an = sign, try to parse an expression if we + // can. + if !args.Equals.IsZero() || canStartExpr(c.Peek()) { + args.Value = parseExpr(p, c, in.In()) + } - args.Semicolon, err = p.Punct(c, ";", in.After()) - // Only diagnose a missing semicolon if we successfully parsed some - // kind of partially-valid expression. Otherwise, we might diagnose - // the same extraneous/missing ; twice. - // - // For example, consider `syntax = ;`. WHen we enter parseExpr, it - // will complain about the unexpected ;. - // - // TODO: Add something like ExprError and check if args.Value - // contains one. - if err != nil && !args.Value.IsZero() { - p.Error(err) + args.Options = tryParseOptions(p, c, in) + + args.Semicolon, err = punctParser{ + parser: p, c: c, + want: ";", + where: in.After(), + insert: justifyLeft, + }.parse() + // Only diagnose a missing semicolon if we successfully parsed some + // kind of partially-valid expression. Otherwise, we might diagnose + // the same extraneous/missing ; twice. + // + // For example, consider `syntax = ;`. WHen we enter parseExpr, it + // will complain about the unexpected ;. + // + // TODO: Add something like ExprError and check if args.Value + // contains one. + if err != nil && !args.Value.IsZero() { + p.Error(err) + } } return p.NewDeclSyntax(args).AsAny() @@ -168,12 +184,23 @@ func parseDecl(p *parser, c *token.Cursor, in taxa.Noun) ast.DeclAny { Path: path, } - args.Options = tryParseOptions(p, c, in) - - semi, err := p.Punct(c, ";", taxa.Package.After()) - args.Semicolon = semi - if err != nil { - p.Error(err) + if c.Done() && path.IsZero() { + // If we see an EOF at this point, suggestions from the next + // few stanzas will be garbage. + p.Error(errUnexpectedEOF(c, taxa.Package.In())) + } else { + args.Options = tryParseOptions(p, c, in) + + semi, err := punctParser{ + parser: p, c: c, + want: ";", + where: taxa.Package.After(), + insert: justifyLeft, + }.parse() + args.Semicolon = semi + if err != nil { + p.Error(err) + } } return p.NewDeclPackage(args).AsAny() @@ -218,10 +245,21 @@ func parseDecl(p *parser, c *token.Cursor, in taxa.Noun) ast.DeclAny { args.Options = tryParseOptions(p, c, in) - semi, err := p.Punct(c, ";", in.After()) - args.Semicolon = semi - if err != nil && args.ImportPath.IsZero() { - p.Error(err) + if args.ImportPath.IsZero() && c.Done() { + // If we see an EOF at this point, suggestions from the next + // few stanzas will be garbage. + p.Error(errUnexpectedEOF(c, in.In())) + } else { + semi, err := punctParser{ + parser: p, c: c, + want: ";", + where: in.After(), + insert: justifyLeft, + }.parse() + args.Semicolon = semi + if err != nil && args.ImportPath.IsZero() { + p.Error(err) + } } return p.NewDeclImport(args).AsAny() @@ -352,7 +390,12 @@ func parseRange(p *parser, c *token.Cursor) ast.DeclRange { options := tryParseOptions(p, c, in) // Parse a semicolon, if possible. - semi, err := p.Punct(c, ";", in.After()) + semi, err := punctParser{ + parser: p, c: c, + want: ";", + where: in.After(), + insert: justifyLeft, + }.parse() if err != nil && (!options.IsZero() || !badExpr) { p.Error(err) } @@ -417,7 +460,11 @@ func parseOptions(p *parser, brackets token.Token, _ taxa.Noun) ast.CompactOptio switch eq.Text() { case ":": // Allow colons, which is usually a mistake. p.Errorf("unexpected `:` in compact option").Apply( - report.Snippetf(eq, "help: replace this with `=`"), + report.Snippet(eq), + justify(p.Stream(), eq.Span(), "replace this with an `=`", justified{ + report.Edit{Start: 0, End: 1, Replace: "="}, + justifyBetween, + }), report.Notef("top-level `option` assignment uses `=`, not `:`"), ) fallthrough diff --git a/experimental/parser/parse_def.go b/experimental/parser/parse_def.go index 55322724..c965c1c8 100644 --- a/experimental/parser/parse_def.go +++ b/experimental/parser/parse_def.go @@ -116,7 +116,12 @@ func (p *defParser) parse() ast.DeclDef { // If we didn't see any braces, this def needs to be ended by a semicolon. if !skipSemi { - semi, err := p.Punct(p.c, ";", taxa.Def.After()) + semi, err := punctParser{ + parser: p.parser, c: p.c, + want: ";", + where: taxa.Def.After(), + insert: justifyLeft, + }.parse() p.args.Semicolon = semi if err != nil { p.Error(err) @@ -145,8 +150,15 @@ func (p *defParser) parse() ast.DeclDef { if !p.outputs.IsZero() { parseTypeList(p.parser, p.outputs, def.WithSignature().Outputs(), taxa.MethodOuts) } else if !p.outputTy.IsZero() { + span := p.outputTy.Span() p.Errorf("missing `(...)` around method return type").Apply( - report.Snippetf(p.outputTy, "help: replace this with `(%s)`", p.outputTy.Span().Text()), + report.Snippet(span), + report.SuggestEdits( + span, + "insert (...) around the return type", + report.Edit{Start: 0, End: 0, Replace: "("}, + report.Edit{Start: span.Len(), End: span.Len(), Replace: ")"}, + ), ) seq.Append(def.WithSignature().Outputs(), p.outputTy) } @@ -208,7 +220,11 @@ func (defOutputs) parse(p *defParser) report.Span { returns := p.c.Next() var ty ast.TypeAny - list, err := p.Punct(p.c, "(", taxa.KeywordReturns.After()) + list, err := punctParser{ + parser: p.parser, c: p.c, + want: "(", + where: taxa.KeywordReturns.After(), + }.parse() if list.IsZero() && canStartPath(p.c.Peek()) { // Suppose the user writes `returns my.Response`. This is // invalid but reasonable so we want to diagnose it. To do this, @@ -284,7 +300,12 @@ func (defValue) canStart(p *defParser) bool { } func (defValue) parse(p *defParser) report.Span { - eq, err := p.Punct(p.c, "=", taxa.Def.In()) + eq, err := punctParser{ + parser: p.parser, c: p.c, + want: "=", + where: taxa.Def.In(), + insert: justifyBetween, + }.parse() if err != nil { p.Error(err) } diff --git a/experimental/parser/parse_delimited.go b/experimental/parser/parse_delimited.go index f29d8540..e816dc3f 100644 --- a/experimental/parser/parse_delimited.go +++ b/experimental/parser/parse_delimited.go @@ -82,7 +82,11 @@ func (d delimited[T]) iter(yield func(value T, delim token.Token) bool) { where: d.in.In(), want: d.what.AsSet(), got: fmt.Sprintf("leading `%s`", next.Text()), - }) + }).Apply(report.SuggestEdits( + next.Span(), + fmt.Sprintf("delete this `%s`", next.Text()), + report.Edit{Start: 0, End: len(next.Text())}, + )) } var needDelim bool @@ -136,8 +140,16 @@ func (d delimited[T]) iter(yield func(value T, delim token.Token) bool) { where: d.in.In(), want: d.delimNouns(), }).Apply( - // TODO: this should be a suggestion. report.Snippetf(v.Span().Rune(0), "note: assuming a missing `%s` here", d.delims[latest]), + justify( + d.p.Stream(), + v.Span(), + fmt.Sprintf("add a `%s` here", d.delims[latest]), + justified{ + report.Edit{Replace: d.delims[latest]}, + justifyLeft, + }, + ), ) } needDelim = d.required @@ -163,7 +175,14 @@ func (d delimited[T]) iter(yield func(value T, delim token.Token) bool) { where: d.in.In(), want: d.what.AsSet(), got: fmt.Sprintf("extra `%s`", next.Text()), - }).Apply(report.Snippetf(delim, "first delimiter is here")) + }).Apply( + report.Snippetf(delim, "first delimiter is here"), + report.SuggestEdits( + next.Span(), + fmt.Sprintf("delete this `%s`", next.Text()), + report.Edit{Start: 0, End: len(next.Text())}, + ), + ) } if !yield(v, delim) { @@ -193,7 +212,11 @@ func (d delimited[T]) iter(yield func(value T, delim token.Token) bool) { what: delim, where: d.in.In(), got: fmt.Sprintf("trailing `%s`", delim.Text()), - }) + }).Apply(report.SuggestEdits( + delim.Span(), + fmt.Sprintf("delete this `%s`", delim.Text()), + report.Edit{Start: 0, End: len(delim.Text())}, + )) } } diff --git a/experimental/parser/parse_expr.go b/experimental/parser/parse_expr.go index 86e7f2e2..86e2c6a7 100644 --- a/experimental/parser/parse_expr.go +++ b/experimental/parser/parse_expr.go @@ -47,8 +47,12 @@ func parseExprInfix(p *parser, c *token.Cursor, where taxa.Place, lhs ast.ExprAn if where.Subject() == taxa.Array || where.Subject() == taxa.Dict { switch next.Text() { case "=": // Allow equals signs, which are usually a mistake. - p.Errorf("unexpected `=` where expression").Apply( - report.Snippetf(next, "help: replace this with `:`"), + p.Errorf("unexpected `=` in expression").Apply( + report.Snippet(next), + justify(p.Stream(), next.Span(), "replace this with an `:`", justified{ + report.Edit{Start: 0, End: 1, Replace: ":"}, + justifyLeft, + }), report.Notef("a %s use `=`, not `:`, for setting fields", taxa.Dict), ) fallthrough diff --git a/experimental/parser/parse_path.go b/experimental/parser/parse_path.go index 327a7171..60f7c4ea 100644 --- a/experimental/parser/parse_path.go +++ b/experimental/parser/parse_path.go @@ -15,10 +15,14 @@ package parser import ( + "fmt" + "github.com/bufbuild/protocompile/experimental/ast" "github.com/bufbuild/protocompile/experimental/internal/astx" "github.com/bufbuild/protocompile/experimental/internal/taxa" + "github.com/bufbuild/protocompile/experimental/report" "github.com/bufbuild/protocompile/experimental/token" + "github.com/bufbuild/protocompile/internal/ext/slicesx" ) // parsePath parses the longest path at cursor. Returns a nil path if @@ -54,13 +58,27 @@ func parsePath(p *parser, c *token.Cursor) ast.Path { // This is a double dot, so something like foo..bar, ..foo, or // foo.. We diagnose it and move on -- Path.Components is robust // against double dots. + + // We consume additional separators here so that we can diagnose + // them all in one shot. + for { + prevSeparator = c.Next() + next := c.Peek() + if !slicesx.Among(next.Text(), ".", "/") { + break + } + } + + tokens := report.Join(next, prevSeparator) p.Error(errUnexpected{ - what: next, + what: tokens, where: taxa.Classify(next).After(), want: taxa.NewSet(taxa.Ident, taxa.Parens), + got: "tokens", }) + } else { + prevSeparator = c.Next() } - prevSeparator = c.Next() case next.Kind() == token.Ident: if !first && prevSeparator.IsZero() { @@ -113,9 +131,13 @@ func parsePath(p *parser, c *token.Cursor) ast.Path { // consume this token. p.Error(errUnexpected{ what: next, - where: taxa.QualifiedName.In(), + where: taxa.QualifiedName.After(), want: taxa.NewSet(taxa.Ident, taxa.Parens), - }) + }).Apply(report.SuggestEdits( + prevSeparator, + fmt.Sprintf("delete the extra `%s`", prevSeparator.Text()), + report.Edit{Start: 0, End: 1}, + )) end = prevSeparator // Include the trailing separator. done = true diff --git a/experimental/parser/parse_state.go b/experimental/parser/parse_state.go index bd3b5953..0cb31396 100644 --- a/experimental/parser/parse_state.go +++ b/experimental/parser/parse_state.go @@ -28,35 +28,48 @@ type parser struct { *report.Report } -// parsePunct attempts to unconditionally parse some punctuation. +type punctParser struct { + *parser + c *token.Cursor + want string + where taxa.Place + insert int // One of the justify* values. +} + +// parse attempts to unconditionally parse some punctuation. // // If the wrong token is encountered, it DOES NOT consume the token, returning a nil // token instead. Returns a diagnostic on failure. -func (p *parser) Punct(c *token.Cursor, want string, where taxa.Place) (token.Token, report.Diagnose) { - next := c.Peek() - if next.Text() == want { - return c.Next(), nil +func (p punctParser) parse() (token.Token, report.Diagnose) { + start := p.c.PeekSkippable().Span() + start = start.File.Span(start.Start, start.Start) + + next := p.c.Peek() + if next.Text() == p.want { + return p.c.Next(), nil } - wanted := taxa.NewSet(taxa.Punct(want, false)) + err := errUnexpected{ + where: p.where, + want: taxa.NewSet(taxa.Punct(p.want, false)), + } if next.IsZero() { - tok, span := c.SeekToEnd() - err := errUnexpected{ - what: span, - where: where, - want: wanted, - got: taxa.EOF, - } + tok, span := p.c.SeekToEnd() + err.what = span + err.got = taxa.EOF if !tok.IsZero() { err.got = taxa.Classify(tok) } - - return token.Zero, err + } else { + err.what = next } - return token.Zero, errUnexpected{ - what: next, - where: where, - want: wanted, + if p.insert != 0 { + err.stream = p.Stream() + err.insert = p.want + err.insertAt = err.what.Span().Start + err.insertJustify = p.insert } + + return token.Zero, err } diff --git a/experimental/parser/testdata/lexer/strings/bad-contents.proto b/experimental/parser/testdata/lexer/strings/bad-contents.proto index 882fb7cc..8823c5ff 100644 --- a/experimental/parser/testdata/lexer/strings/bad-contents.proto +++ b/experimental/parser/testdata/lexer/strings/bad-contents.proto @@ -3,6 +3,9 @@ contains a newline" " " + "this is an indented string + that contains a newline" + "this string contains a nul: $x{00}" "this string contains a nul $x{00} in the middle" "$x{00}" diff --git a/experimental/parser/testdata/lexer/strings/bad-contents.proto.stderr.txt b/experimental/parser/testdata/lexer/strings/bad-contents.proto.stderr.txt index 7ff7563f..9346bc8e 100644 --- a/experimental/parser/testdata/lexer/strings/bad-contents.proto.stderr.txt +++ b/experimental/parser/testdata/lexer/strings/bad-contents.proto.stderr.txt @@ -2,42 +2,76 @@ error: unescaped newlines are not permitted in string literals --> testdata/lexer/strings/bad-contents.proto:1:13 | 1 | "this string - | ^ replace this with `\n` + | ^ + = help: consider splitting this into two adjacent string literals error: unescaped newlines are not permitted in string literals --> testdata/lexer/strings/bad-contents.proto:3:2 | 3 | " - | ^ replace this with `\n` + | ^ + = help: consider splitting this into two adjacent string literals + +error: unescaped newlines are not permitted in string literals + --> testdata/lexer/strings/bad-contents.proto:6:32 + | + 6 | "this is an indented string + | ^ + = help: consider splitting this into two adjacent string literals error: unescaped NUL bytes are not permitted in string literals - --> testdata/lexer/strings/bad-contents.proto:6:30 + --> testdata/lexer/strings/bad-contents.proto:9:30 + | + 9 | "this string contains a nul: " + | ^^^^^^^^ + help: replace it with `\0` or `\x00` + | + 9 | - "this string contains a nul: " + 9 | + "this string contains a nul: \0" | - 6 | "this string contains a nul: " - | ^^^^^^^^ replace this with `\0` or `\x00` error: unescaped NUL bytes are not permitted in string literals - --> testdata/lexer/strings/bad-contents.proto:7:29 + --> testdata/lexer/strings/bad-contents.proto:10:29 + | +10 | "this string contains a nul in the middle" + | ^^^^^^^^ + help: replace it with `\0` or `\x00` + | +10 | - "this string contains a nul in the middle" +10 | + "this string contains a nul \0 in the middle" | - 7 | "this string contains a nul in the middle" - | ^^^^^^^^ replace this with `\0` or `\x00` error: unescaped NUL bytes are not permitted in string literals - --> testdata/lexer/strings/bad-contents.proto:8:2 + --> testdata/lexer/strings/bad-contents.proto:11:2 + | +11 | "" + | ^^^^^^^^ + help: replace it with `\0` or `\x00` + | +11 | - "" +11 | + "\0" | - 8 | "" - | ^^^^^^^^ replace this with `\0` or `\x00` warning: non-printable character in string literal - --> testdata/lexer/strings/bad-contents.proto:10:57 + --> testdata/lexer/strings/bad-contents.proto:13:57 + | +13 | "this string contains some other non-graphic character: " + | ^^^^^^^^ + help: consider escaping it + | +13 | - "this string contains some other non-graphic character: " +13 | + "this string contains some other non-graphic character: \x01" | -10 | "this string contains some other non-graphic character: " - | ^^^^^^^^ help: consider escaping this with e.g. `\x01` instead warning: non-printable character in string literal - --> testdata/lexer/strings/bad-contents.proto:11:39 + --> testdata/lexer/strings/bad-contents.proto:14:39 + | +14 | "this is graphic but non-ASCII space: " + | ^^^^^^^^ + help: consider escaping it + | +14 | - "this is graphic but non-ASCII space: " +14 | + "this is graphic but non-ASCII space: \u00a0" | -11 | "this is graphic but non-ASCII space: " - | ^^^^^^^^ help: consider escaping this with e.g. `\u00a0` instead -encountered 5 errors and 2 warnings +encountered 6 errors and 2 warnings diff --git a/experimental/parser/testdata/lexer/strings/bad-contents.proto.tokens.tsv b/experimental/parser/testdata/lexer/strings/bad-contents.proto.tokens.tsv index 3656262b..e1737a60 100644 --- a/experimental/parser/testdata/lexer/strings/bad-contents.proto.tokens.tsv +++ b/experimental/parser/testdata/lexer/strings/bad-contents.proto.tokens.tsv @@ -1,14 +1,16 @@ # kind offsets linecol text -0 String 000:220 001:001 "\"this string\ncontains a newline\"" string:"this string\ncontains a newline\nthis string contains a nul: \x00this string contains a nul \x00 in the middle\x00this string contains some other non-graphic character: \x01this is graphic but non-ASCII space: \u00a0" close:Token(12) +0 String 000:282 001:001 "\"this string\ncontains a newline\"" string:"this string\ncontains a newline\nthis is an indented string\n that contains a newlinethis string contains a nul: \x00this string contains a nul \x00 in the middle\x00this string contains some other non-graphic character: \x01this is graphic but non-ASCII space: \u00a0" close:Token(14) 1 Space 032:033 002:020 "\n" 2 String 033:036 003:001 "\"\n\"" string:"\n" -3 Space 036:038 004:002 "\n\n" -4 String 038:069 006:001 "\"this string contains a nul: \x00\"" string:"this string contains a nul: \x00" -5 Space 069:070 006:031 "\n" -6 String 070:114 007:001 "\"this string contains a nul \x00 in the middle\"" string:"this string contains a nul \x00 in the middle" -7 Space 114:115 007:044 "\n" -8 String 115:118 008:001 "\"\x00\"" string:"\x00" -9 Space 118:120 008:003 "\n\n" -10 String 120:178 010:001 "\"this string contains some other non-graphic character: \x01\"" string:"this string contains some other non-graphic character: \x01" -11 Space 178:179 010:058 "\n" -12 String 000:220 001:001 "\"this is graphic but non-ASCII space: \u00a0\"" string:"this is graphic but non-ASCII space: \u00a0" open:Token(0) +3 Space 036:042 004:002 "\n\n " +4 String 042:098 006:005 "\"this is an indented string\n that contains a newline\"" string:"this is an indented string\n that contains a newline" +5 Space 098:100 007:029 "\n\n" +6 String 100:131 009:001 "\"this string contains a nul: \x00\"" string:"this string contains a nul: \x00" +7 Space 131:132 009:031 "\n" +8 String 132:176 010:001 "\"this string contains a nul \x00 in the middle\"" string:"this string contains a nul \x00 in the middle" +9 Space 176:177 010:044 "\n" +10 String 177:180 011:001 "\"\x00\"" string:"\x00" +11 Space 180:182 011:003 "\n\n" +12 String 182:240 013:001 "\"this string contains some other non-graphic character: \x01\"" string:"this string contains some other non-graphic character: \x01" +13 Space 240:241 013:058 "\n" +14 String 000:282 001:001 "\"this is graphic but non-ASCII space: \u00a0\"" string:"this is graphic but non-ASCII space: \u00a0" open:Token(0) diff --git a/experimental/parser/testdata/parser/def/ordering.proto.stderr.txt b/experimental/parser/testdata/parser/def/ordering.proto.stderr.txt index c1ccc797..aeb7656d 100644 --- a/experimental/parser/testdata/parser/def/ordering.proto.stderr.txt +++ b/experimental/parser/testdata/parser/def/ordering.proto.stderr.txt @@ -18,7 +18,11 @@ error: missing `(...)` around method return type --> testdata/parser/def/ordering.proto:22:17 | 22 | M x returns T (T); - | ^ help: replace this with `(T)` + | ^ + help: insert (...) around the return type + | +22 | M x returns (T) (T); + | + + error: unexpected method parameter list after method return type --> testdata/parser/def/ordering.proto:22:19 @@ -56,7 +60,11 @@ error: missing `(...)` around method return type --> testdata/parser/def/ordering.proto:30:17 | 30 | M x returns T returns T; - | ^ help: replace this with `(T)` + | ^ + help: insert (...) around the return type + | +30 | M x returns (T) returns T; + | + + error: encountered more than one method return type --> testdata/parser/def/ordering.proto:30:19 @@ -70,7 +78,11 @@ error: missing `(...)` around method return type --> testdata/parser/def/ordering.proto:31:17 | 31 | M x returns T [] returns T; - | ^ help: replace this with `(T)` + | ^ + help: insert (...) around the return type + | +31 | M x returns (T) [] returns T; + | + + error: unexpected method return type after compact options --> testdata/parser/def/ordering.proto:31:22 @@ -92,7 +104,11 @@ error: missing `(...)` around method return type --> testdata/parser/def/ordering.proto:32:29 | 32 | M x [foo = bar] returns T; - | ^ help: replace this with `(T)` + | ^ + help: insert (...) around the return type + | +32 | M x [foo = bar] returns (T); + | + + error: encountered more than one message field tag --> testdata/parser/def/ordering.proto:35:13 diff --git a/experimental/parser/testdata/parser/enum/incomplete.proto.stderr.txt b/experimental/parser/testdata/parser/enum/incomplete.proto.stderr.txt index 65a25684..5dd6da04 100644 --- a/experimental/parser/testdata/parser/enum/incomplete.proto.stderr.txt +++ b/experimental/parser/testdata/parser/enum/incomplete.proto.stderr.txt @@ -3,5 +3,9 @@ error: unexpected `}` after definition | 22 | } | ^ expected `;` + help: consider inserting a `;` + | +21 | NO_TAG2; + | + encountered 1 error diff --git a/experimental/parser/testdata/parser/field/incomplete.proto b/experimental/parser/testdata/parser/field/incomplete.proto index 7640e728..82cf21c6 100644 --- a/experimental/parser/testdata/parser/field/incomplete.proto +++ b/experimental/parser/testdata/parser/field/incomplete.proto @@ -23,5 +23,9 @@ message M { foo.bar name = 1 foo.Bar name; foo.Bar name 1; - foo.bar name = 1 + foo.bar name = 1 // Comment + + foo..bar name = 1; + foo...bar name = 1; + foo.bar name. = 1; } \ No newline at end of file diff --git a/experimental/parser/testdata/parser/field/incomplete.proto.stderr.txt b/experimental/parser/testdata/parser/field/incomplete.proto.stderr.txt index a2e66554..d6e37ece 100644 --- a/experimental/parser/testdata/parser/field/incomplete.proto.stderr.txt +++ b/experimental/parser/testdata/parser/field/incomplete.proto.stderr.txt @@ -3,17 +3,52 @@ error: unexpected identifier after definition | 24 | foo.Bar name; | ^^^ expected `;` + help: consider inserting a `;` + | +23 | foo.bar name = 1; + | + error: unexpected integer literal in definition --> testdata/parser/field/incomplete.proto:25:18 | 25 | foo.Bar name 1; | ^ expected `=` + help: consider inserting a `=` + | +25 | foo.Bar name = 1; + | ++ + +error: unexpected identifier after definition + --> testdata/parser/field/incomplete.proto:28:5 + | +28 | foo..bar name = 1; + | ^^^ expected `;` + help: consider inserting a `;` + | +26 | foo.bar name = 1; // Comment + | + -error: unexpected `}` after definition - --> testdata/parser/field/incomplete.proto:27:1 +error: unexpected tokens after `.` + --> testdata/parser/field/incomplete.proto:28:9 + | +28 | foo..bar name = 1; + | ^ expected identifier or `(...)` + +error: unexpected tokens after `.` + --> testdata/parser/field/incomplete.proto:29:9 + | +29 | foo...bar name = 1; + | ^^ expected identifier or `(...)` + +error: unexpected `=` after qualified name + --> testdata/parser/field/incomplete.proto:30:19 + | +30 | foo.bar name. = 1; + | ^ expected identifier or `(...)` + help: delete the extra `.` + | +30 | - foo.bar name. = 1; +30 | + foo.bar name = 1; | -27 | } - | ^ expected `;` -encountered 3 errors +encountered 6 errors diff --git a/experimental/parser/testdata/parser/field/incomplete.proto.yaml b/experimental/parser/testdata/parser/field/incomplete.proto.yaml index 8b9aa4b6..9927aba9 100644 --- a/experimental/parser/testdata/parser/field/incomplete.proto.yaml +++ b/experimental/parser/testdata/parser/field/incomplete.proto.yaml @@ -32,3 +32,25 @@ decls: name.components: [{ ident: "name" }] type.path.components: [{ ident: "foo" }, { ident: "bar", separator: SEPARATOR_DOT }] value.literal.int_value: 1 + - def: + kind: KIND_FIELD + name.components: [{ ident: "name" }] + type.path.components: + - ident: "foo" + - separator: SEPARATOR_DOT + - { ident: "bar", separator: SEPARATOR_DOT } + value.literal.int_value: 1 + - def: + kind: KIND_FIELD + name.components: [{ ident: "name" }] + type.path.components: + - ident: "foo" + - separator: SEPARATOR_DOT + - separator: SEPARATOR_DOT + - { ident: "bar", separator: SEPARATOR_DOT } + value.literal.int_value: 1 + - def: + kind: KIND_FIELD + name.components: [{ ident: "name" }, { separator: SEPARATOR_DOT }] + type.path.components: [{ ident: "foo" }, { ident: "bar", separator: SEPARATOR_DOT }] + value.literal.int_value: 1 diff --git a/experimental/parser/testdata/parser/field/options.proto b/experimental/parser/testdata/parser/field/options.proto index f31158dc..6a152362 100644 --- a/experimental/parser/testdata/parser/field/options.proto +++ b/experimental/parser/testdata/parser/field/options.proto @@ -25,4 +25,5 @@ message M { ]; M bad = 4 [foo: {bar: baz}]; + M bad2 = 5 [foo = {bar = baz}]; } \ No newline at end of file diff --git a/experimental/parser/testdata/parser/field/options.proto.stderr.txt b/experimental/parser/testdata/parser/field/options.proto.stderr.txt index dd855fdd..cfe64ae8 100644 --- a/experimental/parser/testdata/parser/field/options.proto.stderr.txt +++ b/experimental/parser/testdata/parser/field/options.proto.stderr.txt @@ -2,7 +2,24 @@ error: unexpected `:` in compact option --> testdata/parser/field/options.proto:27:19 | 27 | M bad = 4 [foo: {bar: baz}]; - | ^ help: replace this with `=` + | ^ + help: replace this with an `=` + | +27 | - M bad = 4 [foo: {bar: baz}]; +27 | + M bad = 4 [foo = {bar: baz}]; + | = note: top-level `option` assignment uses `=`, not `:` -encountered 1 error +error: unexpected `=` in expression + --> testdata/parser/field/options.proto:28:28 + | +28 | M bad2 = 5 [foo = {bar = baz}]; + | ^ + help: replace this with an `:` + | +28 | - M bad2 = 5 [foo = {bar = baz}]; +28 | + M bad2 = 5 [foo = {bar: baz}]; + | + = note: a message expression use `=`, not `:`, for setting fields + +encountered 2 errors diff --git a/experimental/parser/testdata/parser/field/options.proto.yaml b/experimental/parser/testdata/parser/field/options.proto.yaml index 03a4845d..ddd4b1b5 100644 --- a/experimental/parser/testdata/parser/field/options.proto.yaml +++ b/experimental/parser/testdata/parser/field/options.proto.yaml @@ -39,3 +39,13 @@ decls: value.dict.entries: - key.path.components: [{ ident: "bar" }] value.path.components: [{ ident: "baz" }] + - def: + kind: KIND_FIELD + name.components: [{ ident: "bad2" }] + type.path.components: [{ ident: "M" }] + value.literal.int_value: 5 + options.entries: + - path.components: [{ ident: "foo" }] + value.dict.entries: + - key.path.components: [{ ident: "bar" }] + value.path.components: [{ ident: "baz" }] diff --git a/experimental/parser/testdata/parser/import/eof_after_kw.proto.stderr.txt b/experimental/parser/testdata/parser/import/eof_after_kw.proto.stderr.txt index 22329c3f..58fecf7e 100644 --- a/experimental/parser/testdata/parser/import/eof_after_kw.proto.stderr.txt +++ b/experimental/parser/testdata/parser/import/eof_after_kw.proto.stderr.txt @@ -1,7 +1,7 @@ -error: unexpected end-of-file after import +error: unexpected end-of-file in import --> testdata/parser/import/eof_after_kw.proto:20:7 | 20 | import - | ^ expected `;` + | ^ encountered 1 error diff --git a/experimental/parser/testdata/parser/lists.proto.stderr.txt b/experimental/parser/testdata/parser/lists.proto.stderr.txt index 7cdfb903..03753da4 100644 --- a/experimental/parser/testdata/parser/lists.proto.stderr.txt +++ b/experimental/parser/testdata/parser/lists.proto.stderr.txt @@ -5,6 +5,10 @@ error: unexpected integer literal in array expression | ^ expected `,` | | | note: assuming a missing `,` here + help: add a `,` here + | +20 | option foo = [1, 2, 3]; + | + error: unexpected extra `,` in array expression --> testdata/parser/lists.proto:21:20 @@ -13,6 +17,11 @@ error: unexpected extra `,` in array expression | -^ expected expression | | | first delimiter is here + help: delete this `,` + | +21 | - option foo = [1, 2,, 3]; +21 | + option foo = [1, 2, 3]; + | error: unexpected extra `,` in array expression --> testdata/parser/lists.proto:22:20 @@ -21,18 +30,33 @@ error: unexpected extra `,` in array expression | -^ expected expression | | | first delimiter is here + help: delete this `,` + | +22 | - option foo = [1, 2,, 3,]; +22 | + option foo = [1, 2, 3,]; + | error: unexpected trailing `,` in array expression --> testdata/parser/lists.proto:22:23 | 22 | option foo = [1, 2,, 3,]; | ^ + help: delete this `,` + | +22 | - option foo = [1, 2,, 3,]; +22 | + option foo = [1, 2,, 3]; + | error: unexpected leading `,` in array expression --> testdata/parser/lists.proto:23:15 | 23 | option foo = [,1 2,, 3,]; | ^ expected expression + help: delete this `,` + | +23 | - option foo = [,1 2,, 3,]; +23 | + option foo = [1 2,, 3,]; + | error: unexpected integer literal in array expression --> testdata/parser/lists.proto:23:18 @@ -41,6 +65,10 @@ error: unexpected integer literal in array expression | ^ expected `,` | | | note: assuming a missing `,` here + help: add a `,` here + | +23 | option foo = [,1, 2,, 3,]; + | + error: unexpected extra `,` in array expression --> testdata/parser/lists.proto:23:20 @@ -49,12 +77,22 @@ error: unexpected extra `,` in array expression | -^ expected expression | | | first delimiter is here + help: delete this `,` + | +23 | - option foo = [,1 2,, 3,]; +23 | + option foo = [,1 2, 3,]; + | error: unexpected trailing `,` in array expression --> testdata/parser/lists.proto:23:23 | 23 | option foo = [,1 2,, 3,]; | ^ + help: delete this `,` + | +23 | - option foo = [,1 2,, 3,]; +23 | + option foo = [,1 2,, 3]; + | error: unexpected `;` in array expression --> testdata/parser/lists.proto:24:16 @@ -75,12 +113,21 @@ error: unexpected message expression in array expression | ^^ expected `,` | | | note: assuming a missing `,` here + help: add a `,` here + | +25 | option foo = [a, {}]; + | + error: unexpected leading `,` in array expression --> testdata/parser/lists.proto:26:15 | 26 | option foo = [,]; | ^ expected expression + help: delete this `,` + | +26 | - option foo = [,]; +26 | + option foo = []; + | error: unexpected extra `;` in message expression --> testdata/parser/lists.proto:31:16 @@ -89,12 +136,22 @@ error: unexpected extra `;` in message expression | -^ expected message field value | | | first delimiter is here + help: delete this `;` + | +31 | - bar: 2;; +31 | + bar: 2; + | error: unexpected leading `;` in message expression --> testdata/parser/lists.proto:34:15 | 34 | option foo = {;bar: 1}; | ^ expected message field value + help: delete this `;` + | +34 | - option foo = {;bar: 1}; +34 | + option foo = {bar: 1}; + | error: unexpected extra `;` in message expression --> testdata/parser/lists.proto:35:22 @@ -103,6 +160,11 @@ error: unexpected extra `;` in message expression | -^ expected message field value | | | first delimiter is here + help: delete this `;` + | +35 | - option foo = {baz: 1;; baz: 1}; +35 | + option foo = {baz: 1; baz: 1}; + | error: unexpected extra `;` in message expression --> testdata/parser/lists.proto:36:22 @@ -111,18 +173,33 @@ error: unexpected extra `;` in message expression | -^ expected message field value | | | first delimiter is here + help: delete this `;` + | +36 | - option foo = {baz: 1,; baz: 1;}; +36 | + option foo = {baz: 1, baz: 1;}; + | error: unexpected leading `;` in message expression --> testdata/parser/lists.proto:38:10 | 38 | bar {;} | ^ expected message field value + help: delete this `;` + | +38 | - bar {;} +38 | + bar {} + | error: unexpected leading `,` in message expression --> testdata/parser/lists.proto:39:10 | 39 | bar {,} | ^ expected message field value + help: delete this `,` + | +39 | - bar {,} +39 | + bar {} + | error: unexpected type name in method parameter list --> testdata/parser/lists.proto:45:17 @@ -131,6 +208,10 @@ error: unexpected type name in method parameter list | ^^^ expected `,` | | | note: assuming a missing `,` here + help: add a `,` here + | +45 | rpc Foo(int, int) returns (int int); + | + error: unexpected type name in method return type --> testdata/parser/lists.proto:45:35 @@ -139,6 +220,10 @@ error: unexpected type name in method return type | ^^^ expected `,` | | | note: assuming a missing `,` here + help: add a `,` here + | +45 | rpc Foo(int int) returns (int, int); + | + error: unexpected `;` in method parameter list --> testdata/parser/lists.proto:46:16 @@ -151,12 +236,22 @@ error: unexpected trailing `,` in method return type | 46 | rpc Foo(int; int) returns (int, int,); | ^ + help: delete this `,` + | +46 | - rpc Foo(int; int) returns (int, int,); +46 | + rpc Foo(int; int) returns (int, int); + | error: unexpected leading `,` in method parameter list --> testdata/parser/lists.proto:47:13 | 47 | rpc Foo(, int, int) returns (int,, int,); | ^ expected type + help: delete this `,` + | +47 | - rpc Foo(, int, int) returns (int,, int,); +47 | + rpc Foo( int, int) returns (int,, int,); + | error: unexpected extra `,` in method return type --> testdata/parser/lists.proto:47:38 @@ -165,12 +260,22 @@ error: unexpected extra `,` in method return type | -^ expected type | | | first delimiter is here + help: delete this `,` + | +47 | - rpc Foo(, int, int) returns (int,, int,); +47 | + rpc Foo(, int, int) returns (int, int,); + | error: unexpected trailing `,` in method return type --> testdata/parser/lists.proto:47:43 | 47 | rpc Foo(, int, int) returns (int,, int,); | ^ + help: delete this `,` + | +47 | - rpc Foo(, int, int) returns (int,, int,); +47 | + rpc Foo(, int, int) returns (int,, int); + | error: unexpected `;` in method parameter list --> testdata/parser/lists.proto:48:13 @@ -183,6 +288,11 @@ error: unexpected leading `,` in method return type | 48 | rpc Foo(;) returns (,); | ^ expected type + help: delete this `,` + | +48 | - rpc Foo(;) returns (,); +48 | + rpc Foo(;) returns (); + | error: unexpected type name in type parameters --> testdata/parser/lists.proto:55:13 @@ -191,6 +301,10 @@ error: unexpected type name in type parameters | ^^^ expected `,` | | | note: assuming a missing `,` here + help: add a `,` here + | +55 | map x; + | + error: unexpected extra `,` in type parameters --> testdata/parser/lists.proto:56:13 @@ -199,18 +313,33 @@ error: unexpected extra `,` in type parameters | -^ expected type | | | first delimiter is here + help: delete this `,` + | +56 | - map x; +56 | + map x; + | error: unexpected leading `,` in type parameters --> testdata/parser/lists.proto:57:9 | 57 | map<,> x; | ^ expected type + help: delete this `,` + | +57 | - map<,> x; +57 | + map<> x; + | error: unexpected leading `,` in type parameters --> testdata/parser/lists.proto:59:9 | 59 | map<,int, int> x; | ^ expected type + help: delete this `,` + | +59 | - map<,int, int> x; +59 | + map x; + | error: unexpected `;` in type parameters --> testdata/parser/lists.proto:60:12 @@ -223,6 +352,11 @@ error: unexpected trailing `,` in type parameters | 63 | int, | ^ + help: delete this `,` + | +63 | - int, +63 | + int + | error: unexpected integer literal in reserved range --> testdata/parser/lists.proto:68:19 @@ -231,6 +365,10 @@ error: unexpected integer literal in reserved range | ^ expected `,` | | | note: assuming a missing `,` here + help: add a `,` here + | +68 | reserved 1, 2, 3; + | + error: unexpected extra `,` in reserved range --> testdata/parser/lists.proto:69:19 @@ -239,6 +377,11 @@ error: unexpected extra `,` in reserved range | -^ expected expression | | | first delimiter is here + help: delete this `,` + | +69 | - reserved 1, 2,, 3; +69 | + reserved 1, 2, 3; + | error: unexpected extra `,` in reserved range --> testdata/parser/lists.proto:70:19 @@ -247,18 +390,33 @@ error: unexpected extra `,` in reserved range | -^ expected expression | | | first delimiter is here + help: delete this `,` + | +70 | - reserved 1, 2,, 3,; +70 | + reserved 1, 2, 3,; + | error: unexpected trailing `,` in reserved range --> testdata/parser/lists.proto:70:22 | 70 | reserved 1, 2,, 3,; | ^ + help: delete this `,` + | +70 | - reserved 1, 2,, 3,; +70 | + reserved 1, 2,, 3; + | error: unexpected leading `,` in reserved range --> testdata/parser/lists.proto:71:14 | 71 | reserved ,1 2,, 3,; | ^ expected expression + help: delete this `,` + | +71 | - reserved ,1 2,, 3,; +71 | + reserved 1 2,, 3,; + | error: unexpected integer literal in reserved range --> testdata/parser/lists.proto:71:17 @@ -267,6 +425,10 @@ error: unexpected integer literal in reserved range | ^ expected `,` | | | note: assuming a missing `,` here + help: add a `,` here + | +71 | reserved ,1, 2,, 3,; + | + error: unexpected extra `,` in reserved range --> testdata/parser/lists.proto:71:19 @@ -275,12 +437,22 @@ error: unexpected extra `,` in reserved range | -^ expected expression | | | first delimiter is here + help: delete this `,` + | +71 | - reserved ,1 2,, 3,; +71 | + reserved ,1 2, 3,; + | error: unexpected trailing `,` in reserved range --> testdata/parser/lists.proto:71:22 | 71 | reserved ,1 2,, 3,; | ^ + help: delete this `,` + | +71 | - reserved ,1 2,, 3,; +71 | + reserved ,1 2,, 3; + | error: unexpected message expression in reserved range --> testdata/parser/lists.proto:72:16 @@ -289,12 +461,21 @@ error: unexpected message expression in reserved range | ^^ expected `,` | | | note: assuming a missing `,` here + help: add a `,` here + | +72 | reserved a, {}; + | + error: unexpected leading `,` in reserved range --> testdata/parser/lists.proto:73:14 | 73 | reserved ,; | ^ expected expression + help: delete this `,` + | +73 | - reserved ,; +73 | + reserved ; + | error: unexpected identifier in reserved range --> testdata/parser/lists.proto:75:19 @@ -303,6 +484,10 @@ error: unexpected identifier in reserved range | ^ expected `,` | | | note: assuming a missing `,` here + help: add a `,` here + | +75 | reserved a, b, c; + | + error: unexpected identifier in reserved range --> testdata/parser/lists.proto:76:19 @@ -311,11 +496,19 @@ error: unexpected identifier in reserved range | ^ expected `,` | | | note: assuming a missing `,` here + help: add a `,` here + | +76 | reserved a, b, c + | + error: unexpected `message` after reserved range --> testdata/parser/lists.proto:77:5 | 77 | message Foo {} | ^^^^^^^ expected `;` + help: consider inserting a `;` + | +76 | reserved a, b c; + | + encountered 46 errors diff --git a/experimental/parser/testdata/parser/package/42.proto.stderr.txt b/experimental/parser/testdata/parser/package/42.proto.stderr.txt index 068c4268..fde36db6 100644 --- a/experimental/parser/testdata/parser/package/42.proto.stderr.txt +++ b/experimental/parser/testdata/parser/package/42.proto.stderr.txt @@ -3,6 +3,10 @@ error: unexpected integer literal after `package` declaration | 17 | package 42; | ^^ expected `;` + help: consider inserting a `;` + | +17 | package; 42; + | + error: unexpected integer literal in file scope --> testdata/parser/package/42.proto:17:9 diff --git a/experimental/parser/testdata/parser/package/eof_after_kw.proto.stderr.txt b/experimental/parser/testdata/parser/package/eof_after_kw.proto.stderr.txt index ef9ef905..7be83f57 100644 --- a/experimental/parser/testdata/parser/package/eof_after_kw.proto.stderr.txt +++ b/experimental/parser/testdata/parser/package/eof_after_kw.proto.stderr.txt @@ -1,7 +1,7 @@ -error: unexpected end-of-file after `package` declaration +error: unexpected end-of-file in `package` declaration --> testdata/parser/package/eof_after_kw.proto:17:8 | 17 | package - | ^ expected `;` + | ^ encountered 1 error diff --git a/experimental/parser/testdata/parser/syntax/eof_after_kw.proto.stderr.txt b/experimental/parser/testdata/parser/syntax/eof_after_kw.proto.stderr.txt index df781754..e4ac916b 100644 --- a/experimental/parser/testdata/parser/syntax/eof_after_kw.proto.stderr.txt +++ b/experimental/parser/testdata/parser/syntax/eof_after_kw.proto.stderr.txt @@ -2,6 +2,6 @@ error: unexpected end-of-file in `syntax` declaration --> testdata/parser/syntax/eof_after_kw.proto:15:7 | 15 | syntax - | ^ expected `=` + | ^ encountered 1 error diff --git a/experimental/parser/testdata/parser/syntax/lonely.proto.stderr.txt b/experimental/parser/testdata/parser/syntax/lonely.proto.stderr.txt index 03b49403..49bdf7cb 100644 --- a/experimental/parser/testdata/parser/syntax/lonely.proto.stderr.txt +++ b/experimental/parser/testdata/parser/syntax/lonely.proto.stderr.txt @@ -3,6 +3,10 @@ error: unexpected `;` in `edition` declaration | 15 | edition; | ^ expected `=` + help: consider inserting a `=` + | +15 | edition = ; + | +++ error: unexpected `;` in `syntax` declaration --> testdata/parser/syntax/lonely.proto:17:10 diff --git a/experimental/parser/testdata/parser/type/generic.proto.stderr.txt b/experimental/parser/testdata/parser/type/generic.proto.stderr.txt index a8b5c7b4..4a21d4c2 100644 --- a/experimental/parser/testdata/parser/type/generic.proto.stderr.txt +++ b/experimental/parser/testdata/parser/type/generic.proto.stderr.txt @@ -5,5 +5,9 @@ error: unexpected type name in type parameters | ^^^ expected `,` | | | note: assuming a missing `,` here + help: add a `,` here + | +37 | set x13 = 13; + | + encountered 1 error diff --git a/experimental/parser/testdata/parser/type/repeated.proto.stderr.txt b/experimental/parser/testdata/parser/type/repeated.proto.stderr.txt index b096bd89..0f52e952 100644 --- a/experimental/parser/testdata/parser/type/repeated.proto.stderr.txt +++ b/experimental/parser/testdata/parser/type/repeated.proto.stderr.txt @@ -2,18 +2,30 @@ error: missing `(...)` around method return type --> testdata/parser/type/repeated.proto:33:41 | 33 | rpc X4(required optional M) returns stream optional M {} - | ^^^^^^^^^^^^^^^^^ help: replace this with `(stream optional M)` + | ^^^^^^^^^^^^^^^^^ + help: insert (...) around the return type + | +33 | rpc X4(required optional M) returns (stream optional M) {} + | + + error: missing `(...)` around method return type --> testdata/parser/type/repeated.proto:34:46 | 34 | rpc X5(repeated repeated test.M) returns repeated stream .test.M {} - | ^^^^^^^^^^^^^^^^^^^^^^^ help: replace this with `(repeated stream .test.M)` + | ^^^^^^^^^^^^^^^^^^^^^^^ + help: insert (...) around the return type + | +34 | rpc X5(repeated repeated test.M) returns (repeated stream .test.M) {} + | + + error: missing `(...)` around method return type --> testdata/parser/type/repeated.proto:35:43 | 35 | rpc X6(stream stream .test.M) returns stream repeated M {} - | ^^^^^^^^^^^^^^^^^ help: replace this with `(stream repeated M)` + | ^^^^^^^^^^^^^^^^^ + help: insert (...) around the return type + | +35 | rpc X6(stream stream .test.M) returns (stream repeated M) {} + | + + encountered 3 errors diff --git a/experimental/report/renderer.go b/experimental/report/renderer.go index 7b90da22..0e927658 100644 --- a/experimental/report/renderer.go +++ b/experimental/report/renderer.go @@ -927,15 +927,11 @@ func (r *renderer) suggestion(snip snippet) { if multiline { span, hunks := unifiedDiff(snip.Span, snip.edits) - aLine := span.StartLoc().Line - bLine := aLine - for i, hunk := range hunks { - // Trim a single newline before and after hunk. This helps deal with - // cases where a newline gets duplicated across hunks of different - // type. - hunk.content, _ = strings.CutPrefix(hunk.content, "\n") - hunk.content, _ = strings.CutSuffix(hunk.content, "\n") + startLine := span.StartLoc().Line + aLine := startLine + bLine := startLine + for i, hunk := range hunks { if hunk.content == "" { continue } @@ -957,11 +953,11 @@ func (r *renderer) suggestion(snip snippet) { // Draw the line as we would for an ordinary window, but prefix // each line with a the hunk's kind and color. - fmt.Fprintf(r, "\n%s%*d | %s%c%s %s", + fmt.Fprintf(r, "\n%s%*d | %s%c%s ", r.ss.nAccent, r.margin, lineno, hunk.bold(&r.ss), hunk.kind, hunk.color(&r.ss), - line, ) + stringWidth(0, line, false, &r.writer) switch hunk.kind { case hunkUnchanged: diff --git a/experimental/report/span.go b/experimental/report/span.go index 2def474e..f93cbaed 100644 --- a/experimental/report/span.go +++ b/experimental/report/span.go @@ -73,6 +73,11 @@ func (s Span) EndLoc() Location { return s.Location(s.End) } +// Len returns the length of this span in bytes. +func (s Span) Len() int { + return s.End - s.Start +} + // Span implements [Spanner]. func (s Span) Span() Span { return s diff --git a/experimental/report/testdata/suggestions.yaml b/experimental/report/testdata/suggestions.yaml index 210b947a..fb982fb5 100644 --- a/experimental/report/testdata/suggestions.yaml +++ b/experimental/report/testdata/suggestions.yaml @@ -22,7 +22,7 @@ files: package abc.xyz; service Foo { - rpc Get(GetRequest) returns GetResponse; + rpc Get(GetRequest) returns GetResponse rpc Put(PutRequest) returns (PutResponse) [foo = bar]; } @@ -92,12 +92,12 @@ diagnostics: annotations: - message: compact options not allowed here file: 0 - start: 139 - end: 150 + start: 138 + end: 149 - message: use `option` settings inside of the method body file: 0 - start: 139 - end: 151 + start: 138 + end: 150 edits: - start: 0 end: 1 diff --git a/experimental/report/testdata/suggestions.yaml.color.txt b/experimental/report/testdata/suggestions.yaml.color.txt index 79d478f3..1152f651 100644 --- a/experimental/report/testdata/suggestions.yaml.color.txt +++ b/experimental/report/testdata/suggestions.yaml.color.txt @@ -26,12 +26,12 @@ ⟨b.red⟩error: missing (...) around return type ⟨blu⟩ --> foo.proto:6:31 | -⟨blu⟩ 6 | ⟨reset⟩ rpc Get(GetRequest) returns GetResponse; +⟨blu⟩ 6 | ⟨reset⟩ rpc Get(GetRequest) returns GetResponse ⟨blu⟩ | ⟨reset⟩ ⟨b.red⟩^^^^^^^^^^^⟨reset⟩ ⟨b.red⟩ ⟨blu⟩ help: add `(...)` around the type | -⟨blu⟩ 6 | ⟨reset⟩ rpc Get(GetRequest) returns ⟨grn⟩(⟨reset⟩GetResponse⟨grn⟩)⟨reset⟩; -⟨blu⟩ | ⟨reset⟩ ⟨b.grn⟩+⟨reset⟩ ⟨b.grn⟩+⟨reset⟩ ⟨reset⟩ +⟨blu⟩ 6 | ⟨reset⟩ rpc Get(GetRequest) returns ⟨grn⟩(⟨reset⟩GetResponse⟨grn⟩) +⟨blu⟩ | ⟨reset⟩ ⟨b.grn⟩+⟨reset⟩ ⟨b.grn⟩+⟨reset⟩ ⟨b.red⟩error: method options must go in a block ⟨blu⟩ --> foo.proto:7:45 @@ -51,9 +51,13 @@ ⟨blu⟩ help: | ⟨blu⟩ 5 | ⟨b.red⟩-⟨red⟩ service Foo { -⟨blu⟩ 6 | ⟨reset⟩ ⟨reset⟩ rpc Get(GetRequest) returns GetResponse; -⟨blu⟩ 7 | ⟨reset⟩ ⟨reset⟩ rpc Put(PutRequest) returns (PutResponse) [foo = bar]; -⟨blu⟩ 8 | ⟨b.red⟩-⟨red⟩ } +⟨blu⟩ 6 | ⟨reset⟩ ⟨reset⟩ +⟨blu⟩ 7 | ⟨reset⟩ ⟨reset⟩ rpc Get(GetRequest) returns GetResponse +⟨blu⟩ 8 | ⟨reset⟩ ⟨reset⟩ rpc Put(PutRequest) returns (PutResponse) [foo = bar]; +⟨blu⟩ 9 | ⟨reset⟩ ⟨reset⟩ +⟨blu⟩10 | ⟨b.red⟩-⟨red⟩ } +⟨blu⟩11 | ⟨b.red⟩-⟨red⟩ +⟨blu⟩ 9 | ⟨b.grn⟩+⟨grn⟩ } ⟨blu⟩ | ⟨reset⟩ ⟨b.red⟩error: delete this method @@ -61,6 +65,8 @@ ⟨blu⟩ help: | ⟨blu⟩ 7 | ⟨b.red⟩-⟨red⟩ rpc Put(PutRequest) returns (PutResponse) [foo = bar]; +⟨blu⟩ 8 | ⟨b.red⟩-⟨red⟩ } +⟨blu⟩ 7 | ⟨b.grn⟩+⟨grn⟩ r} ⟨blu⟩ | ⟨reset⟩ ⟨b.red⟩encountered 4 errors and 1 warning diff --git a/experimental/report/testdata/suggestions.yaml.fancy.txt b/experimental/report/testdata/suggestions.yaml.fancy.txt index 79cbc379..87159097 100644 --- a/experimental/report/testdata/suggestions.yaml.fancy.txt +++ b/experimental/report/testdata/suggestions.yaml.fancy.txt @@ -26,11 +26,11 @@ warning: services should have a `Service` suffix error: missing (...) around return type --> foo.proto:6:31 | - 6 | rpc Get(GetRequest) returns GetResponse; + 6 | rpc Get(GetRequest) returns GetResponse | ^^^^^^^^^^^ help: add `(...)` around the type | - 6 | rpc Get(GetRequest) returns (GetResponse); + 6 | rpc Get(GetRequest) returns (GetResponse) | + + error: method options must go in a block @@ -51,9 +51,13 @@ error: delete some stuff help: | 5 | - service Foo { - 6 | rpc Get(GetRequest) returns GetResponse; - 7 | rpc Put(PutRequest) returns (PutResponse) [foo = bar]; - 8 | - } + 6 | + 7 | rpc Get(GetRequest) returns GetResponse + 8 | rpc Put(PutRequest) returns (PutResponse) [foo = bar]; + 9 | +10 | - } +11 | - + 9 | + } | error: delete this method @@ -61,6 +65,8 @@ error: delete this method help: | 7 | - rpc Put(PutRequest) returns (PutResponse) [foo = bar]; + 8 | - } + 7 | + r} | encountered 4 errors and 1 warning diff --git a/experimental/token/cursor.go b/experimental/token/cursor.go index 836ca589..336a2875 100644 --- a/experimental/token/cursor.go +++ b/experimental/token/cursor.go @@ -74,6 +74,13 @@ func (c *Cursor) IsSynthetic() bool { return c.stream != nil } +// Clone returns a copy of this cursor, which allows performing operations on +// it without mutating the original cursor. +func (c *Cursor) Clone() *Cursor { + c2 := *c + return &c2 +} + // Mark makes a mark on this cursor to indicate a place that can be rewound // to. func (c *Cursor) Mark() CursorMark { diff --git a/experimental/token/stream.go b/experimental/token/stream.go index 679e0509..b62188b3 100644 --- a/experimental/token/stream.go +++ b/experimental/token/stream.go @@ -15,8 +15,10 @@ package token import ( + "cmp" "fmt" "math" + "slices" "github.com/bufbuild/protocompile/experimental/internal" "github.com/bufbuild/protocompile/experimental/report" @@ -82,6 +84,36 @@ func (s *Stream) All() iter.Seq[Token] { } } +// Around returns the tokens around the given offset. It has the following +// potential return values: +// +// 1. offset == 0, returns [Zero], first token. +// 2. offset == len(File.Text()), returns last token, [Zero]. +// 3. offset is the end of a token. Returns the tokens ending and starting +// at offset, respectively. +// 4. offset is inside of a token tok. Returns tok, tok. +func (s *Stream) Around(offset int) (Token, Token) { + if offset == 0 { + return Zero, ID(1).In(s.Context) + } + if offset == len(s.File.Text()) { + return ID(len(s.nats)).In(s.Context), Zero + } + + idx, exact := slices.BinarySearchFunc(s.nats, offset, func(n nat, offset int) int { + return cmp.Compare(int(n.end), offset) + }) + + if exact { + // We landed between two tokens. idx+1 is the ID of the token that ends + // at offset. + return ID(idx + 1).In(s.Context), ID(idx + 2).In(s.Context) + } + + // We landed in the middle of a token, specifically idx+1. + return ID(idx + 1).In(s.Context), ID(idx + 1).In(s.Context) +} + // Cursor returns a cursor over the natural token stream. func (s *Stream) Cursor() *Cursor { return &Cursor{ diff --git a/internal/ext/slicesx/slicesx.go b/internal/ext/slicesx/slicesx.go index f8d11066..64398f62 100644 --- a/internal/ext/slicesx/slicesx.go +++ b/internal/ext/slicesx/slicesx.go @@ -28,10 +28,7 @@ type SliceIndex = unsafex.Int // // If the bounds check fails, returns the zero value and false. func Get[S ~[]E, E any, I SliceIndex](s S, idx I) (element E, ok bool) { - if idx < 0 { - return element, false - } - if uint64(idx) >= uint64(len(s)) { + if !BoundsCheck(idx, len(s)) { return element, false } @@ -43,10 +40,7 @@ func Get[S ~[]E, E any, I SliceIndex](s S, idx I) (element E, ok bool) { // GetPointer is like [Get], but it returns a pointer to the selected element // instead, returning nil on out-of-bounds indices. func GetPointer[S ~[]E, E any, I SliceIndex](s S, idx I) *E { - if idx < 0 { - return nil - } - if uint64(idx) >= uint64(len(s)) { + if !BoundsCheck(idx, len(s)) { return nil } @@ -67,6 +61,20 @@ func LastPointer[S ~[]E, E any](s S) *E { return GetPointer(s, len(s)-1) } +// BoundsCheck performs a generic bounds check as efficiently as possible. +// +// This function assumes that len is the length of a slice, i.e, it is +// non-negative. +// +//nolint:revive,predeclared // len is the right variable name ugh. +func BoundsCheck[I SliceIndex](idx I, len int) bool { + // An unsigned comparison is sufficient. If idx is non-negative, it checks + // that it is less than len. If idx is negative, converting it to uint64 + // will produce a value greater than math.Int64Max, which is greater than + // the positive value we get from casting len. + return uint64(idx) < uint64(len) +} + // Among is like [slices.Contains], but the haystack is passed variadically. // // This makes the common case of using Contains as a variadic (x == y || ...) diff --git a/internal/ext/stringsx/stringsx.go b/internal/ext/stringsx/stringsx.go index 83164903..3066ecd8 100644 --- a/internal/ext/stringsx/stringsx.go +++ b/internal/ext/stringsx/stringsx.go @@ -17,12 +17,37 @@ package stringsx import ( "strings" + "unicode/utf8" "github.com/bufbuild/protocompile/internal/ext/iterx" + "github.com/bufbuild/protocompile/internal/ext/slicesx" "github.com/bufbuild/protocompile/internal/ext/unsafex" "github.com/bufbuild/protocompile/internal/iter" ) +// Rune returns the rune at the given index. +// +// Returns 0, false if out of bounds. Returns U+FFFD, false if rune decoding fails. +func Rune[I slicesx.SliceIndex](s string, idx I) (rune, bool) { + if !slicesx.BoundsCheck(idx, len(s)) { + return 0, false + } + r, _ := utf8.DecodeRuneInString(s[idx:]) + return r, r != utf8.RuneError +} + +// Rune returns the previous rune at the given index. +// +// Returns 0, false if out of bounds. Returns U+FFFD, false if rune decoding fails. +func PrevRune[I slicesx.SliceIndex](s string, idx I) (rune, bool) { + if !slicesx.BoundsCheck(idx-1, len(s)) { + return 0, false + } + + r, _ := utf8.DecodeLastRuneInString(s[:idx]) + return r, r != utf8.RuneError +} + // EveryFunc verifies that all runes in the string satisfy the given predicate. func EveryFunc(s string, p func(rune) bool) bool { return iterx.All(Runes(s), p) diff --git a/internal/gen/buf/compiler/v1alpha1/ast.pb.go b/internal/gen/buf/compiler/v1alpha1/ast.pb.go index d4e38b48..c070875c 100644 --- a/internal/gen/buf/compiler/v1alpha1/ast.pb.go +++ b/internal/gen/buf/compiler/v1alpha1/ast.pb.go @@ -14,7 +14,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.2 +// protoc-gen-go v1.36.4 // protoc (unknown) // source: buf/compiler/v1alpha1/ast.proto @@ -25,6 +25,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -406,14 +407,13 @@ func (Type_Prefixed_Prefix) EnumDescriptor() ([]byte, []int) { // A parsed AST file. This is the root file for the whole Protocompile AST. type File struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The original filesystem file this file was parsed from. File *Report_File `protobuf:"bytes,1,opt,name=file,proto3" json:"file,omitempty"` // Declarations in this file. - Decls []*Decl `protobuf:"bytes,2,rep,name=decls,proto3" json:"decls,omitempty"` + Decls []*Decl `protobuf:"bytes,2,rep,name=decls,proto3" json:"decls,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *File) Reset() { @@ -465,12 +465,11 @@ func (x *File) GetDecls() []*Decl { // This only contains byte offsets for the span; all other information // (such as the line number) should be re-computed as needed. type Span struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Start uint32 `protobuf:"varint,1,opt,name=start,proto3" json:"start,omitempty"` + End uint32 `protobuf:"varint,2,opt,name=end,proto3" json:"end,omitempty"` unknownFields protoimpl.UnknownFields - - Start uint32 `protobuf:"varint,1,opt,name=start,proto3" json:"start,omitempty"` - End uint32 `protobuf:"varint,2,opt,name=end,proto3" json:"end,omitempty"` + sizeCache protoimpl.SizeCache } func (x *Span) Reset() { @@ -526,13 +525,12 @@ func (x *Span) GetEnd() uint32 { // this message do not correspond to valid Protobuf syntax, but they are // accepted by the parser. type Path struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Components []*Path_Component `protobuf:"bytes,1,rep,name=components,proto3" json:"components,omitempty"` + state protoimpl.MessageState `protogen:"open.v1"` + Components []*Path_Component `protobuf:"bytes,1,rep,name=components,proto3" json:"components,omitempty"` // The span for the whole path. - Span *Span `protobuf:"bytes,10,opt,name=span,proto3" json:"span,omitempty"` + Span *Span `protobuf:"bytes,10,opt,name=span,proto3" json:"span,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Path) Reset() { @@ -581,11 +579,8 @@ func (x *Path) GetSpan() *Span { // A declaration in a Protobuf file. type Decl struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Types that are assignable to Decl: + state protoimpl.MessageState `protogen:"open.v1"` + // Types that are valid to be assigned to Decl: // // *Decl_Empty_ // *Decl_Syntax_ @@ -594,7 +589,9 @@ type Decl struct { // *Decl_Def // *Decl_Body_ // *Decl_Range_ - Decl isDecl_Decl `protobuf_oneof:"decl"` + Decl isDecl_Decl `protobuf_oneof:"decl"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Decl) Reset() { @@ -627,58 +624,72 @@ func (*Decl) Descriptor() ([]byte, []int) { return file_buf_compiler_v1alpha1_ast_proto_rawDescGZIP(), []int{3} } -func (m *Decl) GetDecl() isDecl_Decl { - if m != nil { - return m.Decl +func (x *Decl) GetDecl() isDecl_Decl { + if x != nil { + return x.Decl } return nil } func (x *Decl) GetEmpty() *Decl_Empty { - if x, ok := x.GetDecl().(*Decl_Empty_); ok { - return x.Empty + if x != nil { + if x, ok := x.Decl.(*Decl_Empty_); ok { + return x.Empty + } } return nil } func (x *Decl) GetSyntax() *Decl_Syntax { - if x, ok := x.GetDecl().(*Decl_Syntax_); ok { - return x.Syntax + if x != nil { + if x, ok := x.Decl.(*Decl_Syntax_); ok { + return x.Syntax + } } return nil } func (x *Decl) GetImport() *Decl_Import { - if x, ok := x.GetDecl().(*Decl_Import_); ok { - return x.Import + if x != nil { + if x, ok := x.Decl.(*Decl_Import_); ok { + return x.Import + } } return nil } func (x *Decl) GetPackage() *Decl_Package { - if x, ok := x.GetDecl().(*Decl_Package_); ok { - return x.Package + if x != nil { + if x, ok := x.Decl.(*Decl_Package_); ok { + return x.Package + } } return nil } func (x *Decl) GetDef() *Def { - if x, ok := x.GetDecl().(*Decl_Def); ok { - return x.Def + if x != nil { + if x, ok := x.Decl.(*Decl_Def); ok { + return x.Def + } } return nil } func (x *Decl) GetBody() *Decl_Body { - if x, ok := x.GetDecl().(*Decl_Body_); ok { - return x.Body + if x != nil { + if x, ok := x.Decl.(*Decl_Body_); ok { + return x.Body + } } return nil } func (x *Decl) GetRange() *Decl_Range { - if x, ok := x.GetDecl().(*Decl_Range_); ok { - return x.Range + if x != nil { + if x, ok := x.Decl.(*Decl_Range_); ok { + return x.Range + } } return nil } @@ -734,10 +745,7 @@ func (*Decl_Range_) isDecl_Decl() {} // // This allows the parser to accept and represent many invalid but plausible productions. type Def struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // Definitions without a clear kind may be marked as `KIND_UNSPECIFIED`. Kind Def_Kind `protobuf:"varint,1,opt,name=kind,proto3,enum=buf.compiler.v1alpha1.Def_Kind" json:"kind,omitempty"` Name *Path `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` @@ -757,6 +765,8 @@ type Def struct { KeywordSpan *Span `protobuf:"bytes,11,opt,name=keyword_span,json=keywordSpan,proto3" json:"keyword_span,omitempty"` EqualsSpan *Span `protobuf:"bytes,12,opt,name=equals_span,json=equalsSpan,proto3" json:"equals_span,omitempty"` SemicolonSpan *Span `protobuf:"bytes,13,opt,name=semicolon_span,json=semicolonSpan,proto3" json:"semicolon_span,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Def) Reset() { @@ -868,12 +878,11 @@ func (x *Def) GetSemicolonSpan() *Span { // Compact options after a declaration, in `[...]`. type Options struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Entries []*Options_Entry `protobuf:"bytes,1,rep,name=entries,proto3" json:"entries,omitempty"` + Span *Span `protobuf:"bytes,10,opt,name=span,proto3" json:"span,omitempty"` unknownFields protoimpl.UnknownFields - - Entries []*Options_Entry `protobuf:"bytes,1,rep,name=entries,proto3" json:"entries,omitempty"` - Span *Span `protobuf:"bytes,10,opt,name=span,proto3" json:"span,omitempty"` + sizeCache protoimpl.SizeCache } func (x *Options) Reset() { @@ -922,11 +931,8 @@ func (x *Options) GetSpan() *Span { // An expression, such as the value of an option or the tag of a field. type Expr struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Types that are assignable to Expr: + state protoimpl.MessageState `protogen:"open.v1"` + // Types that are valid to be assigned to Expr: // // *Expr_Literal_ // *Expr_Path @@ -935,7 +941,9 @@ type Expr struct { // *Expr_Array_ // *Expr_Dict_ // *Expr_Field_ - Expr isExpr_Expr `protobuf_oneof:"expr"` + Expr isExpr_Expr `protobuf_oneof:"expr"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Expr) Reset() { @@ -968,58 +976,72 @@ func (*Expr) Descriptor() ([]byte, []int) { return file_buf_compiler_v1alpha1_ast_proto_rawDescGZIP(), []int{6} } -func (m *Expr) GetExpr() isExpr_Expr { - if m != nil { - return m.Expr +func (x *Expr) GetExpr() isExpr_Expr { + if x != nil { + return x.Expr } return nil } func (x *Expr) GetLiteral() *Expr_Literal { - if x, ok := x.GetExpr().(*Expr_Literal_); ok { - return x.Literal + if x != nil { + if x, ok := x.Expr.(*Expr_Literal_); ok { + return x.Literal + } } return nil } func (x *Expr) GetPath() *Path { - if x, ok := x.GetExpr().(*Expr_Path); ok { - return x.Path + if x != nil { + if x, ok := x.Expr.(*Expr_Path); ok { + return x.Path + } } return nil } func (x *Expr) GetPrefixed() *Expr_Prefixed { - if x, ok := x.GetExpr().(*Expr_Prefixed_); ok { - return x.Prefixed + if x != nil { + if x, ok := x.Expr.(*Expr_Prefixed_); ok { + return x.Prefixed + } } return nil } func (x *Expr) GetRange() *Expr_Range { - if x, ok := x.GetExpr().(*Expr_Range_); ok { - return x.Range + if x != nil { + if x, ok := x.Expr.(*Expr_Range_); ok { + return x.Range + } } return nil } func (x *Expr) GetArray() *Expr_Array { - if x, ok := x.GetExpr().(*Expr_Array_); ok { - return x.Array + if x != nil { + if x, ok := x.Expr.(*Expr_Array_); ok { + return x.Array + } } return nil } func (x *Expr) GetDict() *Expr_Dict { - if x, ok := x.GetExpr().(*Expr_Dict_); ok { - return x.Dict + if x != nil { + if x, ok := x.Expr.(*Expr_Dict_); ok { + return x.Dict + } } return nil } func (x *Expr) GetField() *Expr_Field { - if x, ok := x.GetExpr().(*Expr_Field_); ok { - return x.Field + if x != nil { + if x, ok := x.Expr.(*Expr_Field_); ok { + return x.Field + } } return nil } @@ -1075,16 +1097,15 @@ func (*Expr_Field_) isExpr_Expr() {} // This AST includes many types not present in ordinary Protobuf, such as representations // for `repeated repeated int32` and `Arbitrary`, among others. type Type struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Types that are assignable to Type: + state protoimpl.MessageState `protogen:"open.v1"` + // Types that are valid to be assigned to Type: // // *Type_Path // *Type_Prefixed_ // *Type_Generic_ - Type isType_Type `protobuf_oneof:"type"` + Type isType_Type `protobuf_oneof:"type"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Type) Reset() { @@ -1117,30 +1138,36 @@ func (*Type) Descriptor() ([]byte, []int) { return file_buf_compiler_v1alpha1_ast_proto_rawDescGZIP(), []int{7} } -func (m *Type) GetType() isType_Type { - if m != nil { - return m.Type +func (x *Type) GetType() isType_Type { + if x != nil { + return x.Type } return nil } func (x *Type) GetPath() *Path { - if x, ok := x.GetType().(*Type_Path); ok { - return x.Path + if x != nil { + if x, ok := x.Type.(*Type_Path); ok { + return x.Path + } } return nil } func (x *Type) GetPrefixed() *Type_Prefixed { - if x, ok := x.GetType().(*Type_Prefixed_); ok { - return x.Prefixed + if x != nil { + if x, ok := x.Type.(*Type_Prefixed_); ok { + return x.Prefixed + } } return nil } func (x *Type) GetGeneric() *Type_Generic { - if x, ok := x.GetType().(*Type_Generic_); ok { - return x.Generic + if x != nil { + if x, ok := x.Type.(*Type_Generic_); ok { + return x.Generic + } } return nil } @@ -1169,13 +1196,10 @@ func (*Type_Generic_) isType_Type() {} // A path component. type Path_Component struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // May be missing altogether, for invalid paths like `foo..bar`. // - // Types that are assignable to Component: + // Types that are valid to be assigned to Component: // // *Path_Component_Ident // *Path_Component_Extension @@ -1188,6 +1212,8 @@ type Path_Component struct { ComponentSpan *Span `protobuf:"bytes,10,opt,name=component_span,json=componentSpan,proto3" json:"component_span,omitempty"` // The span of this component's leading dot, if any. SeparatorSpan *Span `protobuf:"bytes,11,opt,name=separator_span,json=separatorSpan,proto3" json:"separator_span,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Path_Component) Reset() { @@ -1220,23 +1246,27 @@ func (*Path_Component) Descriptor() ([]byte, []int) { return file_buf_compiler_v1alpha1_ast_proto_rawDescGZIP(), []int{2, 0} } -func (m *Path_Component) GetComponent() isPath_Component_Component { - if m != nil { - return m.Component +func (x *Path_Component) GetComponent() isPath_Component_Component { + if x != nil { + return x.Component } return nil } func (x *Path_Component) GetIdent() string { - if x, ok := x.GetComponent().(*Path_Component_Ident); ok { - return x.Ident + if x != nil { + if x, ok := x.Component.(*Path_Component_Ident); ok { + return x.Ident + } } return "" } func (x *Path_Component) GetExtension() *Path { - if x, ok := x.GetComponent().(*Path_Component_Extension); ok { - return x.Extension + if x != nil { + if x, ok := x.Component.(*Path_Component_Extension); ok { + return x.Extension + } } return nil } @@ -1282,11 +1312,10 @@ func (*Path_Component_Extension) isPath_Component_Component() {} // An empty declaration. type Decl_Empty struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Span *Span `protobuf:"bytes,10,opt,name=span,proto3" json:"span,omitempty"` unknownFields protoimpl.UnknownFields - - Span *Span `protobuf:"bytes,10,opt,name=span,proto3" json:"span,omitempty"` + sizeCache protoimpl.SizeCache } func (x *Decl_Empty) Reset() { @@ -1328,17 +1357,16 @@ func (x *Decl_Empty) GetSpan() *Span { // A language pragma, such as a syntax or edition declaration. type Decl_Syntax struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Kind Decl_Syntax_Kind `protobuf:"varint,1,opt,name=kind,proto3,enum=buf.compiler.v1alpha1.Decl_Syntax_Kind" json:"kind,omitempty"` + Value *Expr `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` + Options *Options `protobuf:"bytes,3,opt,name=options,proto3" json:"options,omitempty"` + Span *Span `protobuf:"bytes,10,opt,name=span,proto3" json:"span,omitempty"` + KeywordSpan *Span `protobuf:"bytes,11,opt,name=keyword_span,json=keywordSpan,proto3" json:"keyword_span,omitempty"` + EqualsSpan *Span `protobuf:"bytes,12,opt,name=equals_span,json=equalsSpan,proto3" json:"equals_span,omitempty"` + SemicolonSpan *Span `protobuf:"bytes,13,opt,name=semicolon_span,json=semicolonSpan,proto3" json:"semicolon_span,omitempty"` unknownFields protoimpl.UnknownFields - - Kind Decl_Syntax_Kind `protobuf:"varint,1,opt,name=kind,proto3,enum=buf.compiler.v1alpha1.Decl_Syntax_Kind" json:"kind,omitempty"` - Value *Expr `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` - Options *Options `protobuf:"bytes,3,opt,name=options,proto3" json:"options,omitempty"` - Span *Span `protobuf:"bytes,10,opt,name=span,proto3" json:"span,omitempty"` - KeywordSpan *Span `protobuf:"bytes,11,opt,name=keyword_span,json=keywordSpan,proto3" json:"keyword_span,omitempty"` - EqualsSpan *Span `protobuf:"bytes,12,opt,name=equals_span,json=equalsSpan,proto3" json:"equals_span,omitempty"` - SemicolonSpan *Span `protobuf:"bytes,13,opt,name=semicolon_span,json=semicolonSpan,proto3" json:"semicolon_span,omitempty"` + sizeCache protoimpl.SizeCache } func (x *Decl_Syntax) Reset() { @@ -1422,15 +1450,14 @@ func (x *Decl_Syntax) GetSemicolonSpan() *Span { // A package declaration. type Decl_Package struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Path *Path `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` + Options *Options `protobuf:"bytes,2,opt,name=options,proto3" json:"options,omitempty"` + Span *Span `protobuf:"bytes,10,opt,name=span,proto3" json:"span,omitempty"` + KeywordSpan *Span `protobuf:"bytes,11,opt,name=keyword_span,json=keywordSpan,proto3" json:"keyword_span,omitempty"` + SemicolonSpan *Span `protobuf:"bytes,12,opt,name=semicolon_span,json=semicolonSpan,proto3" json:"semicolon_span,omitempty"` unknownFields protoimpl.UnknownFields - - Path *Path `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` - Options *Options `protobuf:"bytes,2,opt,name=options,proto3" json:"options,omitempty"` - Span *Span `protobuf:"bytes,10,opt,name=span,proto3" json:"span,omitempty"` - KeywordSpan *Span `protobuf:"bytes,11,opt,name=keyword_span,json=keywordSpan,proto3" json:"keyword_span,omitempty"` - SemicolonSpan *Span `protobuf:"bytes,12,opt,name=semicolon_span,json=semicolonSpan,proto3" json:"semicolon_span,omitempty"` + sizeCache protoimpl.SizeCache } func (x *Decl_Package) Reset() { @@ -1500,18 +1527,17 @@ func (x *Decl_Package) GetSemicolonSpan() *Span { // An import declaration. type Decl_Import struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Modifier Decl_Import_Modifier `protobuf:"varint,1,opt,name=modifier,proto3,enum=buf.compiler.v1alpha1.Decl_Import_Modifier" json:"modifier,omitempty"` - ImportPath *Expr `protobuf:"bytes,2,opt,name=import_path,json=importPath,proto3" json:"import_path,omitempty"` - Options *Options `protobuf:"bytes,3,opt,name=options,proto3" json:"options,omitempty"` - Span *Span `protobuf:"bytes,10,opt,name=span,proto3" json:"span,omitempty"` - KeywordSpan *Span `protobuf:"bytes,11,opt,name=keyword_span,json=keywordSpan,proto3" json:"keyword_span,omitempty"` - ModifierSpan *Span `protobuf:"bytes,12,opt,name=modifier_span,json=modifierSpan,proto3" json:"modifier_span,omitempty"` - ImportPathSpan *Span `protobuf:"bytes,13,opt,name=import_path_span,json=importPathSpan,proto3" json:"import_path_span,omitempty"` - SemicolonSpan *Span `protobuf:"bytes,14,opt,name=semicolon_span,json=semicolonSpan,proto3" json:"semicolon_span,omitempty"` + state protoimpl.MessageState `protogen:"open.v1"` + Modifier Decl_Import_Modifier `protobuf:"varint,1,opt,name=modifier,proto3,enum=buf.compiler.v1alpha1.Decl_Import_Modifier" json:"modifier,omitempty"` + ImportPath *Expr `protobuf:"bytes,2,opt,name=import_path,json=importPath,proto3" json:"import_path,omitempty"` + Options *Options `protobuf:"bytes,3,opt,name=options,proto3" json:"options,omitempty"` + Span *Span `protobuf:"bytes,10,opt,name=span,proto3" json:"span,omitempty"` + KeywordSpan *Span `protobuf:"bytes,11,opt,name=keyword_span,json=keywordSpan,proto3" json:"keyword_span,omitempty"` + ModifierSpan *Span `protobuf:"bytes,12,opt,name=modifier_span,json=modifierSpan,proto3" json:"modifier_span,omitempty"` + ImportPathSpan *Span `protobuf:"bytes,13,opt,name=import_path_span,json=importPathSpan,proto3" json:"import_path_span,omitempty"` + SemicolonSpan *Span `protobuf:"bytes,14,opt,name=semicolon_span,json=semicolonSpan,proto3" json:"semicolon_span,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Decl_Import) Reset() { @@ -1603,12 +1629,11 @@ func (x *Decl_Import) GetSemicolonSpan() *Span { // The body of a message, enum, or similar declaration, which // itself contains declarations. type Decl_Body struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Decls []*Decl `protobuf:"bytes,1,rep,name=decls,proto3" json:"decls,omitempty"` + Span *Span `protobuf:"bytes,10,opt,name=span,proto3" json:"span,omitempty"` unknownFields protoimpl.UnknownFields - - Decls []*Decl `protobuf:"bytes,1,rep,name=decls,proto3" json:"decls,omitempty"` - Span *Span `protobuf:"bytes,10,opt,name=span,proto3" json:"span,omitempty"` + sizeCache protoimpl.SizeCache } func (x *Decl_Body) Reset() { @@ -1658,16 +1683,15 @@ func (x *Decl_Body) GetSpan() *Span { // An extensions or reserved range within a message. Both productions are // extremely similar, so they share an AST node. type Decl_Range struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Kind Decl_Range_Kind `protobuf:"varint,1,opt,name=kind,proto3,enum=buf.compiler.v1alpha1.Decl_Range_Kind" json:"kind,omitempty"` + Ranges []*Expr `protobuf:"bytes,2,rep,name=ranges,proto3" json:"ranges,omitempty"` + Options *Options `protobuf:"bytes,3,opt,name=options,proto3" json:"options,omitempty"` + Span *Span `protobuf:"bytes,10,opt,name=span,proto3" json:"span,omitempty"` + KeywordSpan *Span `protobuf:"bytes,11,opt,name=keyword_span,json=keywordSpan,proto3" json:"keyword_span,omitempty"` + SemicolonSpan *Span `protobuf:"bytes,12,opt,name=semicolon_span,json=semicolonSpan,proto3" json:"semicolon_span,omitempty"` unknownFields protoimpl.UnknownFields - - Kind Decl_Range_Kind `protobuf:"varint,1,opt,name=kind,proto3,enum=buf.compiler.v1alpha1.Decl_Range_Kind" json:"kind,omitempty"` - Ranges []*Expr `protobuf:"bytes,2,rep,name=ranges,proto3" json:"ranges,omitempty"` - Options *Options `protobuf:"bytes,3,opt,name=options,proto3" json:"options,omitempty"` - Span *Span `protobuf:"bytes,10,opt,name=span,proto3" json:"span,omitempty"` - KeywordSpan *Span `protobuf:"bytes,11,opt,name=keyword_span,json=keywordSpan,proto3" json:"keyword_span,omitempty"` - SemicolonSpan *Span `protobuf:"bytes,12,opt,name=semicolon_span,json=semicolonSpan,proto3" json:"semicolon_span,omitempty"` + sizeCache protoimpl.SizeCache } func (x *Decl_Range) Reset() { @@ -1744,16 +1768,15 @@ func (x *Decl_Range) GetSemicolonSpan() *Span { // A method signature. This appears on `KIND_METHOD`, for example. type Def_Signature struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Inputs []*Type `protobuf:"bytes,1,rep,name=inputs,proto3" json:"inputs,omitempty"` + Outputs []*Type `protobuf:"bytes,2,rep,name=outputs,proto3" json:"outputs,omitempty"` + Span *Span `protobuf:"bytes,10,opt,name=span,proto3" json:"span,omitempty"` + InputSpan *Span `protobuf:"bytes,11,opt,name=input_span,json=inputSpan,proto3" json:"input_span,omitempty"` + ReturnsSpan *Span `protobuf:"bytes,12,opt,name=returns_span,json=returnsSpan,proto3" json:"returns_span,omitempty"` + OutputSpan *Span `protobuf:"bytes,13,opt,name=output_span,json=outputSpan,proto3" json:"output_span,omitempty"` unknownFields protoimpl.UnknownFields - - Inputs []*Type `protobuf:"bytes,1,rep,name=inputs,proto3" json:"inputs,omitempty"` - Outputs []*Type `protobuf:"bytes,2,rep,name=outputs,proto3" json:"outputs,omitempty"` - Span *Span `protobuf:"bytes,10,opt,name=span,proto3" json:"span,omitempty"` - InputSpan *Span `protobuf:"bytes,11,opt,name=input_span,json=inputSpan,proto3" json:"input_span,omitempty"` - ReturnsSpan *Span `protobuf:"bytes,12,opt,name=returns_span,json=returnsSpan,proto3" json:"returns_span,omitempty"` - OutputSpan *Span `protobuf:"bytes,13,opt,name=output_span,json=outputSpan,proto3" json:"output_span,omitempty"` + sizeCache protoimpl.SizeCache } func (x *Def_Signature) Reset() { @@ -1829,13 +1852,12 @@ func (x *Def_Signature) GetOutputSpan() *Span { } type Options_Entry struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Path *Path `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` + Value *Expr `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` + EqualsSpan *Span `protobuf:"bytes,10,opt,name=equals_span,json=equalsSpan,proto3" json:"equals_span,omitempty"` unknownFields protoimpl.UnknownFields - - Path *Path `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` - Value *Expr `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` - EqualsSpan *Span `protobuf:"bytes,10,opt,name=equals_span,json=equalsSpan,proto3" json:"equals_span,omitempty"` + sizeCache protoimpl.SizeCache } func (x *Options_Entry) Reset() { @@ -1891,20 +1913,19 @@ func (x *Options_Entry) GetEqualsSpan() *Span { // A literal value: a number or a string. type Expr_Literal struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // None of these may be set, in the case of an integer with an invalid or // out-of-range format. // - // Types that are assignable to Value: + // Types that are valid to be assigned to Value: // // *Expr_Literal_IntValue // *Expr_Literal_FloatValue // *Expr_Literal_StringValue - Value isExpr_Literal_Value `protobuf_oneof:"value"` - Span *Span `protobuf:"bytes,10,opt,name=span,proto3" json:"span,omitempty"` + Value isExpr_Literal_Value `protobuf_oneof:"value"` + Span *Span `protobuf:"bytes,10,opt,name=span,proto3" json:"span,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Expr_Literal) Reset() { @@ -1937,30 +1958,36 @@ func (*Expr_Literal) Descriptor() ([]byte, []int) { return file_buf_compiler_v1alpha1_ast_proto_rawDescGZIP(), []int{6, 0} } -func (m *Expr_Literal) GetValue() isExpr_Literal_Value { - if m != nil { - return m.Value +func (x *Expr_Literal) GetValue() isExpr_Literal_Value { + if x != nil { + return x.Value } return nil } func (x *Expr_Literal) GetIntValue() uint64 { - if x, ok := x.GetValue().(*Expr_Literal_IntValue); ok { - return x.IntValue + if x != nil { + if x, ok := x.Value.(*Expr_Literal_IntValue); ok { + return x.IntValue + } } return 0 } func (x *Expr_Literal) GetFloatValue() float64 { - if x, ok := x.GetValue().(*Expr_Literal_FloatValue); ok { - return x.FloatValue + if x != nil { + if x, ok := x.Value.(*Expr_Literal_FloatValue); ok { + return x.FloatValue + } } return 0 } func (x *Expr_Literal) GetStringValue() string { - if x, ok := x.GetValue().(*Expr_Literal_StringValue); ok { - return x.StringValue + if x != nil { + if x, ok := x.Value.(*Expr_Literal_StringValue); ok { + return x.StringValue + } } return "" } @@ -1996,14 +2023,13 @@ func (*Expr_Literal_StringValue) isExpr_Literal_Value() {} // An expression with some kind of prefix, such as a minus sign. type Expr_Prefixed struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Prefix Expr_Prefixed_Prefix `protobuf:"varint,1,opt,name=prefix,proto3,enum=buf.compiler.v1alpha1.Expr_Prefixed_Prefix" json:"prefix,omitempty"` + Expr *Expr `protobuf:"bytes,2,opt,name=expr,proto3" json:"expr,omitempty"` + Span *Span `protobuf:"bytes,10,opt,name=span,proto3" json:"span,omitempty"` + PrefixSpan *Span `protobuf:"bytes,11,opt,name=prefix_span,json=prefixSpan,proto3" json:"prefix_span,omitempty"` unknownFields protoimpl.UnknownFields - - Prefix Expr_Prefixed_Prefix `protobuf:"varint,1,opt,name=prefix,proto3,enum=buf.compiler.v1alpha1.Expr_Prefixed_Prefix" json:"prefix,omitempty"` - Expr *Expr `protobuf:"bytes,2,opt,name=expr,proto3" json:"expr,omitempty"` - Span *Span `protobuf:"bytes,10,opt,name=span,proto3" json:"span,omitempty"` - PrefixSpan *Span `protobuf:"bytes,11,opt,name=prefix_span,json=prefixSpan,proto3" json:"prefix_span,omitempty"` + sizeCache protoimpl.SizeCache } func (x *Expr_Prefixed) Reset() { @@ -2069,14 +2095,13 @@ func (x *Expr_Prefixed) GetPrefixSpan() *Span { // // Ranges are inclusive. type Expr_Range struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Start *Expr `protobuf:"bytes,1,opt,name=start,proto3" json:"start,omitempty"` + End *Expr `protobuf:"bytes,2,opt,name=end,proto3" json:"end,omitempty"` + Span *Span `protobuf:"bytes,10,opt,name=span,proto3" json:"span,omitempty"` + ToSpan *Span `protobuf:"bytes,11,opt,name=to_span,json=toSpan,proto3" json:"to_span,omitempty"` unknownFields protoimpl.UnknownFields - - Start *Expr `protobuf:"bytes,1,opt,name=start,proto3" json:"start,omitempty"` - End *Expr `protobuf:"bytes,2,opt,name=end,proto3" json:"end,omitempty"` - Span *Span `protobuf:"bytes,10,opt,name=span,proto3" json:"span,omitempty"` - ToSpan *Span `protobuf:"bytes,11,opt,name=to_span,json=toSpan,proto3" json:"to_span,omitempty"` + sizeCache protoimpl.SizeCache } func (x *Expr_Range) Reset() { @@ -2139,15 +2164,14 @@ func (x *Expr_Range) GetToSpan() *Span { // An array literal, a sequence of expressions bound by square brackets. type Expr_Array struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Elements []*Expr `protobuf:"bytes,1,rep,name=elements,proto3" json:"elements,omitempty"` + Span *Span `protobuf:"bytes,10,opt,name=span,proto3" json:"span,omitempty"` + OpenSpan *Span `protobuf:"bytes,11,opt,name=open_span,json=openSpan,proto3" json:"open_span,omitempty"` + CloseSpan *Span `protobuf:"bytes,12,opt,name=close_span,json=closeSpan,proto3" json:"close_span,omitempty"` + CommaSpans []*Span `protobuf:"bytes,13,rep,name=comma_spans,json=commaSpans,proto3" json:"comma_spans,omitempty"` unknownFields protoimpl.UnknownFields - - Elements []*Expr `protobuf:"bytes,1,rep,name=elements,proto3" json:"elements,omitempty"` - Span *Span `protobuf:"bytes,10,opt,name=span,proto3" json:"span,omitempty"` - OpenSpan *Span `protobuf:"bytes,11,opt,name=open_span,json=openSpan,proto3" json:"open_span,omitempty"` - CloseSpan *Span `protobuf:"bytes,12,opt,name=close_span,json=closeSpan,proto3" json:"close_span,omitempty"` - CommaSpans []*Span `protobuf:"bytes,13,rep,name=comma_spans,json=commaSpans,proto3" json:"comma_spans,omitempty"` + sizeCache protoimpl.SizeCache } func (x *Expr_Array) Reset() { @@ -2217,15 +2241,14 @@ func (x *Expr_Array) GetCommaSpans() []*Span { // A dictionary literal, a sequence of key-value pairs bound by curly braces. type Expr_Dict struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Entries []*Expr_Field `protobuf:"bytes,1,rep,name=entries,proto3" json:"entries,omitempty"` + Span *Span `protobuf:"bytes,10,opt,name=span,proto3" json:"span,omitempty"` + OpenSpan *Span `protobuf:"bytes,11,opt,name=open_span,json=openSpan,proto3" json:"open_span,omitempty"` + CloseSpan *Span `protobuf:"bytes,12,opt,name=close_span,json=closeSpan,proto3" json:"close_span,omitempty"` + CommaSpans []*Span `protobuf:"bytes,13,rep,name=comma_spans,json=commaSpans,proto3" json:"comma_spans,omitempty"` unknownFields protoimpl.UnknownFields - - Entries []*Expr_Field `protobuf:"bytes,1,rep,name=entries,proto3" json:"entries,omitempty"` - Span *Span `protobuf:"bytes,10,opt,name=span,proto3" json:"span,omitempty"` - OpenSpan *Span `protobuf:"bytes,11,opt,name=open_span,json=openSpan,proto3" json:"open_span,omitempty"` - CloseSpan *Span `protobuf:"bytes,12,opt,name=close_span,json=closeSpan,proto3" json:"close_span,omitempty"` - CommaSpans []*Span `protobuf:"bytes,13,rep,name=comma_spans,json=commaSpans,proto3" json:"comma_spans,omitempty"` + sizeCache protoimpl.SizeCache } func (x *Expr_Dict) Reset() { @@ -2296,14 +2319,13 @@ func (x *Expr_Dict) GetCommaSpans() []*Span { // A key-value pair expression, which usually will appear inside of an // `Expr.Dict`. type Expr_Field struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Key *Expr `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Value *Expr `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` + Span *Span `protobuf:"bytes,10,opt,name=span,proto3" json:"span,omitempty"` + ColonSpan *Span `protobuf:"bytes,11,opt,name=colon_span,json=colonSpan,proto3" json:"colon_span,omitempty"` unknownFields protoimpl.UnknownFields - - Key *Expr `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - Value *Expr `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` - Span *Span `protobuf:"bytes,10,opt,name=span,proto3" json:"span,omitempty"` - ColonSpan *Span `protobuf:"bytes,11,opt,name=colon_span,json=colonSpan,proto3" json:"colon_span,omitempty"` + sizeCache protoimpl.SizeCache } func (x *Expr_Field) Reset() { @@ -2366,14 +2388,13 @@ func (x *Expr_Field) GetColonSpan() *Span { // A type with a modifier prefix in front of it, such as `repeated` or `stream`. type Type_Prefixed struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Prefix Type_Prefixed_Prefix `protobuf:"varint,1,opt,name=prefix,proto3,enum=buf.compiler.v1alpha1.Type_Prefixed_Prefix" json:"prefix,omitempty"` + Type *Type `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` + Span *Span `protobuf:"bytes,10,opt,name=span,proto3" json:"span,omitempty"` + PrefixSpan *Span `protobuf:"bytes,11,opt,name=prefix_span,json=prefixSpan,proto3" json:"prefix_span,omitempty"` unknownFields protoimpl.UnknownFields - - Prefix Type_Prefixed_Prefix `protobuf:"varint,1,opt,name=prefix,proto3,enum=buf.compiler.v1alpha1.Type_Prefixed_Prefix" json:"prefix,omitempty"` - Type *Type `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` - Span *Span `protobuf:"bytes,10,opt,name=span,proto3" json:"span,omitempty"` - PrefixSpan *Span `protobuf:"bytes,11,opt,name=prefix_span,json=prefixSpan,proto3" json:"prefix_span,omitempty"` + sizeCache protoimpl.SizeCache } func (x *Type_Prefixed) Reset() { @@ -2439,16 +2460,15 @@ func (x *Type_Prefixed) GetPrefixSpan() *Span { // Note that no other generic types are part of Protobuf, but we support arbitrary generic // types since it is a more natural way to define the AST. type Type_Generic struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Path *Path `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` + Args []*Type `protobuf:"bytes,2,rep,name=args,proto3" json:"args,omitempty"` + Span *Span `protobuf:"bytes,10,opt,name=span,proto3" json:"span,omitempty"` + OpenSpan *Span `protobuf:"bytes,11,opt,name=open_span,json=openSpan,proto3" json:"open_span,omitempty"` + CloseSpan *Span `protobuf:"bytes,12,opt,name=close_span,json=closeSpan,proto3" json:"close_span,omitempty"` + CommaSpans []*Span `protobuf:"bytes,13,rep,name=comma_spans,json=commaSpans,proto3" json:"comma_spans,omitempty"` unknownFields protoimpl.UnknownFields - - Path *Path `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` - Args []*Type `protobuf:"bytes,2,rep,name=args,proto3" json:"args,omitempty"` - Span *Span `protobuf:"bytes,10,opt,name=span,proto3" json:"span,omitempty"` - OpenSpan *Span `protobuf:"bytes,11,opt,name=open_span,json=openSpan,proto3" json:"open_span,omitempty"` - CloseSpan *Span `protobuf:"bytes,12,opt,name=close_span,json=closeSpan,proto3" json:"close_span,omitempty"` - CommaSpans []*Span `protobuf:"bytes,13,rep,name=comma_spans,json=commaSpans,proto3" json:"comma_spans,omitempty"` + sizeCache protoimpl.SizeCache } func (x *Type_Generic) Reset() { @@ -2525,7 +2545,7 @@ func (x *Type_Generic) GetCommaSpans() []*Span { var File_buf_compiler_v1alpha1_ast_proto protoreflect.FileDescriptor -var file_buf_compiler_v1alpha1_ast_proto_rawDesc = []byte{ +var file_buf_compiler_v1alpha1_ast_proto_rawDesc = string([]byte{ 0x0a, 0x1f, 0x62, 0x75, 0x66, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x61, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x15, 0x62, 0x75, 0x66, 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x2e, @@ -3012,16 +3032,16 @@ var file_buf_compiler_v1alpha1_ast_proto_rawDesc = []byte{ 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x17, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +}) var ( file_buf_compiler_v1alpha1_ast_proto_rawDescOnce sync.Once - file_buf_compiler_v1alpha1_ast_proto_rawDescData = file_buf_compiler_v1alpha1_ast_proto_rawDesc + file_buf_compiler_v1alpha1_ast_proto_rawDescData []byte ) func file_buf_compiler_v1alpha1_ast_proto_rawDescGZIP() []byte { file_buf_compiler_v1alpha1_ast_proto_rawDescOnce.Do(func() { - file_buf_compiler_v1alpha1_ast_proto_rawDescData = protoimpl.X.CompressGZIP(file_buf_compiler_v1alpha1_ast_proto_rawDescData) + file_buf_compiler_v1alpha1_ast_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_buf_compiler_v1alpha1_ast_proto_rawDesc), len(file_buf_compiler_v1alpha1_ast_proto_rawDesc))) }) return file_buf_compiler_v1alpha1_ast_proto_rawDescData } @@ -3222,7 +3242,7 @@ func file_buf_compiler_v1alpha1_ast_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_buf_compiler_v1alpha1_ast_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_buf_compiler_v1alpha1_ast_proto_rawDesc), len(file_buf_compiler_v1alpha1_ast_proto_rawDesc)), NumEnums: 7, NumMessages: 25, NumExtensions: 0, @@ -3234,7 +3254,6 @@ func file_buf_compiler_v1alpha1_ast_proto_init() { MessageInfos: file_buf_compiler_v1alpha1_ast_proto_msgTypes, }.Build() File_buf_compiler_v1alpha1_ast_proto = out.File - file_buf_compiler_v1alpha1_ast_proto_rawDesc = nil file_buf_compiler_v1alpha1_ast_proto_goTypes = nil file_buf_compiler_v1alpha1_ast_proto_depIdxs = nil } diff --git a/internal/gen/buf/compiler/v1alpha1/report.pb.go b/internal/gen/buf/compiler/v1alpha1/report.pb.go index c1636c35..c66ef8d6 100644 --- a/internal/gen/buf/compiler/v1alpha1/report.pb.go +++ b/internal/gen/buf/compiler/v1alpha1/report.pb.go @@ -14,7 +14,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.2 +// protoc-gen-go v1.36.4 // protoc (unknown) // source: buf/compiler/v1alpha1/report.proto @@ -25,6 +25,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -92,12 +93,11 @@ func (Diagnostic_Level) EnumDescriptor() ([]byte, []int) { // A diagnostic report, consisting of `Diagnostics` and the `File`s they diagnose. type Report struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Files []*Report_File `protobuf:"bytes,1,rep,name=files,proto3" json:"files,omitempty"` + Diagnostics []*Diagnostic `protobuf:"bytes,2,rep,name=diagnostics,proto3" json:"diagnostics,omitempty"` unknownFields protoimpl.UnknownFields - - Files []*Report_File `protobuf:"bytes,1,rep,name=files,proto3" json:"files,omitempty"` - Diagnostics []*Diagnostic `protobuf:"bytes,2,rep,name=diagnostics,proto3" json:"diagnostics,omitempty"` + sizeCache protoimpl.SizeCache } func (x *Report) Reset() { @@ -146,10 +146,7 @@ func (x *Report) GetDiagnostics() []*Diagnostic { // A diagnostic within a `Report`. type Diagnostic struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // Required. The message to show for this diagnostic. This should fit on one line. Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` // An optional machine-readable tag for the diagnostic. @@ -168,7 +165,9 @@ type Diagnostic struct { // Debugging information related to the diagnostic. This should only be // used for information about debugging a tool or compiler that emits the // diagnostic, not the code being diagnosed. - Debug []string `protobuf:"bytes,7,rep,name=debug,proto3" json:"debug,omitempty"` + Debug []string `protobuf:"bytes,7,rep,name=debug,proto3" json:"debug,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Diagnostic) Reset() { @@ -259,16 +258,15 @@ func (x *Diagnostic) GetDebug() []string { // A file involved in a diagnostic `Report`. type Report_File struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The path to this file. Does not need to be meaningful as a file-system // path. Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` // The textual contents of this file. Presumed to be UTF-8, although it need // not be. - Text []byte `protobuf:"bytes,2,opt,name=text,proto3" json:"text,omitempty"` + Text []byte `protobuf:"bytes,2,opt,name=text,proto3" json:"text,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Report_File) Reset() { @@ -318,10 +316,7 @@ func (x *Report_File) GetText() []byte { // A file annotation within a `Diagnostic`. This corresponds to a single // span of source code in a `Report`'s file. type Diagnostic_Annotation struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // A message to show under this snippet. May be empty. Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` // Whether this is a "primary" snippet, which is used for deciding whether or not @@ -335,8 +330,10 @@ type Diagnostic_Annotation struct { // The start offset of the annotated snippet, in bytes. Start uint32 `protobuf:"varint,4,opt,name=start,proto3" json:"start,omitempty"` // The end offset of the annotated snippet, in bytes. - End uint32 `protobuf:"varint,5,opt,name=end,proto3" json:"end,omitempty"` - Edits []*Diagnostic_Edit `protobuf:"bytes,6,rep,name=edits,proto3" json:"edits,omitempty"` + End uint32 `protobuf:"varint,5,opt,name=end,proto3" json:"end,omitempty"` + Edits []*Diagnostic_Edit `protobuf:"bytes,6,rep,name=edits,proto3" json:"edits,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Diagnostic_Annotation) Reset() { @@ -416,16 +413,15 @@ func (x *Diagnostic_Annotation) GetEdits() []*Diagnostic_Edit { // A pure insertion is modeled by `start == end`. // A pure deletion is modeled by empty `replace`. type Diagnostic_Edit struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The start offset of the edit, relative to the containing snippet. Start uint32 `protobuf:"varint,1,opt,name=start,proto3" json:"start,omitempty"` // The end offset of the edit, relative to the containing snippet. End uint32 `protobuf:"varint,2,opt,name=end,proto3" json:"end,omitempty"` // The text to insert in place of the selected region. - Replace string `protobuf:"bytes,3,opt,name=replace,proto3" json:"replace,omitempty"` + Replace string `protobuf:"bytes,3,opt,name=replace,proto3" json:"replace,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Diagnostic_Edit) Reset() { @@ -481,7 +477,7 @@ func (x *Diagnostic_Edit) GetReplace() string { var File_buf_compiler_v1alpha1_report_proto protoreflect.FileDescriptor -var file_buf_compiler_v1alpha1_report_proto_rawDesc = []byte{ +var file_buf_compiler_v1alpha1_report_proto_rawDesc = string([]byte{ 0x0a, 0x22, 0x62, 0x75, 0x66, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x15, 0x62, 0x75, 0x66, 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x69, 0x6c, @@ -555,16 +551,16 @@ var file_buf_compiler_v1alpha1_report_proto_rawDesc = []byte{ 0x61, 0xea, 0x02, 0x17, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +}) var ( file_buf_compiler_v1alpha1_report_proto_rawDescOnce sync.Once - file_buf_compiler_v1alpha1_report_proto_rawDescData = file_buf_compiler_v1alpha1_report_proto_rawDesc + file_buf_compiler_v1alpha1_report_proto_rawDescData []byte ) func file_buf_compiler_v1alpha1_report_proto_rawDescGZIP() []byte { file_buf_compiler_v1alpha1_report_proto_rawDescOnce.Do(func() { - file_buf_compiler_v1alpha1_report_proto_rawDescData = protoimpl.X.CompressGZIP(file_buf_compiler_v1alpha1_report_proto_rawDescData) + file_buf_compiler_v1alpha1_report_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_buf_compiler_v1alpha1_report_proto_rawDesc), len(file_buf_compiler_v1alpha1_report_proto_rawDesc))) }) return file_buf_compiler_v1alpha1_report_proto_rawDescData } @@ -601,7 +597,7 @@ func file_buf_compiler_v1alpha1_report_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_buf_compiler_v1alpha1_report_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_buf_compiler_v1alpha1_report_proto_rawDesc), len(file_buf_compiler_v1alpha1_report_proto_rawDesc)), NumEnums: 1, NumMessages: 5, NumExtensions: 0, @@ -613,7 +609,6 @@ func file_buf_compiler_v1alpha1_report_proto_init() { MessageInfos: file_buf_compiler_v1alpha1_report_proto_msgTypes, }.Build() File_buf_compiler_v1alpha1_report_proto = out.File - file_buf_compiler_v1alpha1_report_proto_rawDesc = nil file_buf_compiler_v1alpha1_report_proto_goTypes = nil file_buf_compiler_v1alpha1_report_proto_depIdxs = nil }