documentSymbol emits span of entire construct
Summary:
This diff lights up two new features in Nuclide: (1) breadcrumbs bar, (2) in outline view, it highlights the construct that your caret is on. It also makes hackLsp more compatible with VSCode outline-view plugins.
Background: When I wrote HackLSP I thought that in documentSymbol, the "range" for each symbol referred just to the identifier. But industry practice has settled on it returning the entire range of the construct, e.g. for a class it returns the range from the beginning of "public class" to the end of "}".
(Clients have to decide how to reconstruct outline view from the flat list that is documentSymbol. Because of the above industry practice, they tend to reconstruct it based on range inclusion).
This diff moves Hack over to return the range of the entire construct as well for sake of textDocument/documentSymbol. (but for textDocument/definition it returns only the range of the identifier, similar to what VSCode does, so that e.g. when you hyperclick on `foo()` then it takes you to the `foo` in `public function foo`, rather than taking you to the `public`.)
PLAN: (1) Land this Hack change. (2) Once the Hack change has shipped widely enough, change Nuclide to reconstruct outline view based on range inclusion rather than containerName.
Nuclide also uses the full ranges to highlight the current item you're on in the outline view, and also to show breadcrumbs.
Reviewed By: pittsw
Differential Revision:
D8179623
fbshipit-source-id:
b158675d591bd5cae37de1c5efc0c37509ee91f5