@@ -30,8 +30,8 @@ import (
3030 "github.com/bufbuild/protocompile/experimental/ast/syntax"
3131 "github.com/bufbuild/protocompile/experimental/id"
3232 "github.com/bufbuild/protocompile/experimental/ir"
33- "github.com/bufbuild/protocompile/experimental/report"
3433 "github.com/bufbuild/protocompile/experimental/seq"
34+ "github.com/bufbuild/protocompile/experimental/source"
3535 "github.com/bufbuild/protocompile/experimental/token"
3636 "github.com/bufbuild/protocompile/experimental/token/keyword"
3737 "go.lsp.dev/protocol"
@@ -842,7 +842,7 @@ func optionKeywords() iter.Seq[keyword.Keyword] {
842842func keywordToCompletionItem (
843843 keywords iter.Seq [keyword.Keyword ],
844844 kind protocol.CompletionItemKind ,
845- span report .Span ,
845+ span source .Span ,
846846 offset int ,
847847) iter.Seq [protocol.CompletionItem ] {
848848 return func (yield func (protocol.CompletionItem ) bool ) {
@@ -871,7 +871,7 @@ func keywordToCompletionItem(
871871func typeReferencesToCompletionItems (
872872 current * file ,
873873 parentFullName ir.FullName ,
874- span report .Span ,
874+ span source .Span ,
875875 offset int ,
876876 allowEnums bool ,
877877) iter.Seq [protocol.CompletionItem ] {
@@ -976,7 +976,7 @@ func typeReferencesToCompletionItems(
976976// optionToCompletionItems returns completion items for options.
977977func optionToCompletionItems (
978978 current * file ,
979- span report .Span ,
979+ span source .Span ,
980980 offset int ,
981981 optionsType ir.Type ,
982982 targetKind ir.OptionTarget ,
@@ -1036,7 +1036,7 @@ func optionToCompletionItems(
10361036// extensionToCompletionItems returns completion items for options from extensions.
10371037func extensionToCompletionItems (
10381038 current * file ,
1039- span report .Span ,
1039+ span source .Span ,
10401040 offset int ,
10411041 optionsType ir.Type ,
10421042 targetKind ir.OptionTarget ,
@@ -1107,7 +1107,7 @@ func extensionToCompletionItems(
11071107// It walks through the path segments to find the current message type and suggests valid fields.
11081108func optionNamesToCompletionItems (
11091109 current * file ,
1110- pathSpans []report .Span ,
1110+ pathSpans []source .Span ,
11111111 offset int ,
11121112 optionType ir.Type ,
11131113 targetKind ir.OptionTarget ,
@@ -1218,7 +1218,7 @@ func optionNamesToCompletionItems(
12181218func messageFieldCompletionItems (
12191219 current * file ,
12201220 messageType ir.Type ,
1221- tokenSpan report .Span ,
1221+ tokenSpan source .Span ,
12221222 offset int ,
12231223 isValueType bool ,
12241224) iter.Seq [protocol.CompletionItem ] {
@@ -1347,7 +1347,7 @@ func getDeclForOffsetHelper(body ast.DeclBody, offset int, path []ast.DeclAny) [
13471347// parseOptionSpan returns the span associated with the option declaration and
13481348// the fields up until the offset. This handles invalid declarations from
13491349// partial syntax.
1350- func parseOptionSpan (file * file , offset int ) (report .Span , []report .Span ) {
1350+ func parseOptionSpan (file * file , offset int ) (source .Span , []source .Span ) {
13511351 hasStart , hasGap := false , false
13521352 var tokens []token.Token
13531353 typeSpan := extractAroundOffset (
@@ -1373,12 +1373,12 @@ func parseOptionSpan(file *file, offset int) (report.Span, []report.Span) {
13731373 isTokenType ,
13741374 )
13751375 if ! hasStart {
1376- return report .Span {}, nil
1376+ return source .Span {}, nil
13771377 }
13781378 // If no tokens were found, return an empty span at the offset.
13791379 if len (tokens ) == 0 {
1380- emptySpan := report .Span {File : file .file , Start : offset , End : offset }
1381- return emptySpan , []report .Span {emptySpan }
1380+ emptySpan := source .Span {File : file .file , Start : offset , End : offset }
1381+ return emptySpan , []source .Span {emptySpan }
13821382 }
13831383 slices .Reverse (tokens )
13841384 if typeSpan .Start > 0 && file .file .Text ()[typeSpan .Start - 1 ] == '(' {
@@ -1389,14 +1389,14 @@ func parseOptionSpan(file *file, offset int) (report.Span, []report.Span) {
13891389 if strings .HasPrefix (file .file .Text ()[typeSpan .End :], ")" ) {
13901390 typeSpan .End += 1
13911391 }
1392- return typeSpan , []report .Span {typeSpan }
1392+ return typeSpan , []source .Span {typeSpan }
13931393 }
1394- pathSpans := []report .Span {tokens [0 ].Span ()}
1394+ pathSpans := []source .Span {tokens [0 ].Span ()}
13951395 for i := 1 ; i < len (tokens )- 1 ; i += 2 {
13961396 dotToken := tokens [i ]
13971397 identToken := tokens [i + 1 ]
13981398 if dotToken .Text () != "." || identToken .Kind () != token .Ident {
1399- return report .Span {}, nil
1399+ return source .Span {}, nil
14001400 }
14011401 pathSpans = append (pathSpans , identToken .Span ())
14021402 }
@@ -1520,20 +1520,20 @@ func isTokenTypeDelimiter(tok token.Token) bool {
15201520}
15211521
15221522// extractAroundOffset extracts the value around the offset by querying the token stream.
1523- func extractAroundOffset (file * file , offset int , isTokenBefore , isTokenAfter func (token.Token ) bool ) report .Span {
1523+ func extractAroundOffset (file * file , offset int , isTokenBefore , isTokenAfter func (token.Token ) bool ) source .Span {
15241524 if file .ir .AST () == nil {
1525- return report .Span {}
1525+ return source .Span {}
15261526 }
15271527 stream := file .ir .AST ().Stream ()
15281528 if stream == nil {
1529- return report .Span {}
1529+ return source .Span {}
15301530 }
15311531 before , after := stream .Around (offset )
15321532 if before .IsZero () && after .IsZero () {
1533- return report .Span {}
1533+ return source .Span {}
15341534 }
15351535
1536- span := report .Span {
1536+ span := source .Span {
15371537 File : file .file ,
15381538 Start : offset ,
15391539 End : offset ,
@@ -1557,7 +1557,7 @@ func extractAroundOffset(file *file, offset int, isTokenBefore, isTokenAfter fun
15571557 return span
15581558}
15591559
1560- func splitSpan (span report .Span , offset int ) (prefix string , suffix string ) {
1560+ func splitSpan (span source .Span , offset int ) (prefix string , suffix string ) {
15611561 if offsetInSpan (offset , span ) != 0 {
15621562 return "" , ""
15631563 }
@@ -1566,7 +1566,7 @@ func splitSpan(span report.Span, offset int) (prefix string, suffix string) {
15661566 return text [:index ], text [index :]
15671567}
15681568
1569- func offsetInSpan (offset int , span report .Span ) int {
1569+ func offsetInSpan (offset int , span source .Span ) int {
15701570 if offset < span .Start {
15711571 return - 1
15721572 } else if offset > span .End {
0 commit comments