File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -1497,26 +1497,31 @@ func defToOptionMessage(file *file, def ast.DeclDef) ir.MessageValue {
14971497 return ir.MessageValue {}
14981498}
14991499
1500+ // isTokenType returns true if the tokens are valid for a type declaration e.g "buf.registry.Type".
15001501func isTokenType (tok token.Token ) bool {
15011502 kind := tok .Kind ()
15021503 return kind == token .Ident || (kind == token .Keyword && tok .Text () == "." )
15031504}
15041505
1506+ // isTokenSpace returns true for spaces, excluding newlines.
15051507func isTokenSpace (tok token.Token ) bool {
15061508 return tok .Kind () == token .Space && strings .IndexByte (tok .Text (), '\n' ) == - 1
15071509}
15081510
1511+ // isTokenParen returns true for '(' or ')' tokens.
15091512func isTokenParen (tok token.Token ) bool {
15101513 return tok .Kind () == token .Keyword &&
15111514 (strings .HasPrefix (tok .Text (), "(" ) ||
15121515 strings .HasSuffix (tok .Text (), ")" ))
15131516}
15141517
1518+ // isTokenTypeDelimiter returns true if the token represents a delimiter for completion.
1519+ // A delimiter is a newline or start of stream. This handles invalid partial declarations.
15151520func isTokenTypeDelimiter (tok token.Token ) bool {
15161521 kind := tok .Kind ()
15171522 return (kind == token .Unrecognized && tok .IsZero ()) ||
15181523 (kind == token .Space && strings .IndexByte (tok .Text (), '\n' ) != - 1 ) ||
1519- (kind == token .Comment )
1524+ (kind == token .Comment && strings . HasSuffix ( tok . Text (), " \n " ) )
15201525}
15211526
15221527// extractAroundOffset extracts the value around the offset by querying the token stream.
You can’t perform that action at this time.
0 commit comments