When using VS Code, certain language extensions can provide codelens that display reference counts above functions, variables, and other symbols. Check it out here.
I've recently taken on a project and one of my first tasks is to restructure it. In doing so, I'd like to pull references into local or external without having to constantly "show all references".
After going through the extension API example and exploring the API further, I experimented with building a few extensions to gain more knowledge about how they function. While I can insert a codelens with customized data, I'm encountering an issue now. It doesn't appear that there's a way to access existing codelenses or the information used in generating the "i references".
Another discovery I made during this process is that the language defines the symbols, yet there seems to be no way to iterate over them either. Although I could re-parse everything and create my own codelens analysis, this approach would be more time-consuming than manually checking the scope. Additionally, it feels overly complicated.
I was hoping for an event that triggers when a codelens is created or modified, allowing me to retrieve that codelens information. However, it appears that the codelens events are handled internally and not accessible to me.
My ideal scenario would involve retrieving two pieces of information:
- Retrieve the number referenced as "i references"
- Determine the line to which it corresponds
Is this feasible within the API's scope or beyond its capabilities? Although I am prepared to rewrite my parsing code, the fact remains that there's already a mechanism in place generating this information, which I'd prefer to tap into.