Skip to content

Commit db5725b

Browse files
authored
Fix LSP symbol resolve on missing rpc types (#4258)
1 parent 74f2768 commit db5725b

File tree

1 file changed

+24
-21
lines changed

1 file changed

+24
-21
lines changed

private/buf/buflsp/file.go

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -629,31 +629,34 @@ func (f *file) irToSymbols(irSymbol ir.Symbol) ([]*symbol, []*symbol) {
629629

630630
input, _ := irSymbol.AsMethod().Input()
631631
// Method input must be a single message type.
632-
inputAST := irSymbol.AsMethod().AST().AsMethod().Signature.Inputs().At(0)
633-
inputSym := &symbol{
634-
ir: irSymbol,
635-
file: f,
636-
span: inputAST.RemovePrefixes().Span(), // We always strip prefixes in case of streaming.
637-
kind: &reference{
638-
def: input.AST(), // Only messages can be method inputs and outputs
639-
fullName: input.FullName(),
640-
},
632+
if astInputs := irSymbol.AsMethod().AST().AsMethod().Signature.Inputs(); astInputs.Len() == 1 {
633+
inputAST := astInputs.At(0)
634+
inputSym := &symbol{
635+
ir: irSymbol,
636+
file: f,
637+
span: inputAST.RemovePrefixes().Span(), // We always strip prefixes in case of streaming.
638+
kind: &reference{
639+
def: input.AST(), // Only messages can be method inputs and outputs
640+
fullName: input.FullName(),
641+
},
642+
}
643+
unresolved = append(unresolved, inputSym)
641644
}
642-
unresolved = append(unresolved, inputSym)
643-
644645
output, _ := irSymbol.AsMethod().Output()
645646
// Method output must be a single message type.
646-
outputAST := irSymbol.AsMethod().AST().AsMethod().Signature.Outputs().At(0)
647-
outputSym := &symbol{
648-
ir: irSymbol,
649-
file: f,
650-
span: outputAST.RemovePrefixes().Span(), // We always strip prefixes in case of streaming.
651-
kind: &reference{
652-
def: output.AST(), // Only messages can be method inputs and outputs
653-
fullName: output.FullName(),
654-
},
647+
if astOutputs := irSymbol.AsMethod().AST().AsMethod().Signature.Outputs(); astOutputs.Len() == 1 {
648+
outputAST := astOutputs.At(0)
649+
outputSym := &symbol{
650+
ir: irSymbol,
651+
file: f,
652+
span: outputAST.RemovePrefixes().Span(), // We always strip prefixes in case of streaming.
653+
kind: &reference{
654+
def: output.AST(), // Only messages can be method inputs and outputs
655+
fullName: output.FullName(),
656+
},
657+
}
658+
unresolved = append(unresolved, outputSym)
655659
}
656-
unresolved = append(unresolved, outputSym)
657660
unresolved = append(unresolved, f.messageToSymbols(irSymbol.AsMethod().Options())...)
658661
}
659662
return resolved, unresolved

0 commit comments

Comments
 (0)