mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-15 18:38:13 +00:00
This PR updates the construction of clang::clangd::DocumentSymbol to produce "range" and "selectionRange" properties that match the [textDocument/documentSymbol](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_documentSymbol) spec. "selectionRange" is constructed by finding start and end position of the symbols identifier. "range" property is constructed by finding the left most and right most token of the AST, the code makes an assumption that left most token is always the first node in postorder traversal from that node, and the right most is the node itself. AFAIK this is true for most of the grammar other than infix operators. For symbols with a body, the right most token is the open bracket, so we extend the range to its matching closing bracket.