tooling-force.com icon indicating copy to clipboard operation
tooling-force.com copied to clipboard

Rename Symbol

Open ChuckJonas opened this issue 7 years ago • 2 comments

rename symbol in vscode

Not sure how hard this would be it would be amazing for refactoring. Here's the API documentation for the provider.

For my purposes, I would really just need an action to "Find All Occurrences of a symbol". It could actually be used to knock off several of the LSP capabilities.

ChuckJonas avatar Feb 11 '17 16:02 ChuckJonas

Due to the nature of SFDC this one is going to be quite hard.

Apex class, method or property may be referenced in many places.
Here is just first few that spring to mind:

  • Apex classes
  • Apex triggers
  • SOQL and SOSL statements inside apex classes/triggers
  • Visualforce pages
  • Aura/Lightning
  • SFDC metadata (e.g. Process Builder)

I am sure this is not complete list. A call like “renameSymbol” would have to be able to track/modify all those places.

Then do not forget maintenance - when SFDC adds ability to call apex methods from even more places.

Side note: Tooling API sort of provides SymbolTable which covers Apex classes part from my list above, but there are so many gotchas and limitations related to correctness of the result that (in my view) it is mostly useful for standalone static analysis tools (e.g. tool showing call graph) where you do not expect quick result and can afford to recompile all classes every time before asking for SymbolTable. Even then one has to pray that during that time nobody else updates any of the classes involved using Metadata API or some other method.

neowit avatar Feb 11 '17 20:02 neowit

ya, that totally makes sense... I didn't consider anything other than apex. Although for the purposes of being an "Apex Language Service" I think it would be acceptable to ignore thing like lightening and process builder. VisualForce would be really nice, but I that might be challenging in itself.

A "Find Usage" action might be a safer option & provide something better than just a global search.

Anyways, I hope to soon attempt to get this project building so I can start contributing.

ChuckJonas avatar Feb 12 '17 01:02 ChuckJonas