DavidFeldhoff / al-codeactions

MIT License
17 stars 8 forks source link

Refactor: Replace object id with object name in variables/parameters #106

Closed dannoe closed 2 years ago

dannoe commented 3 years ago

I often copy old CAL methods via textexport to al. The first step is removing the @ and the id in the variables and parameters. The second step is replacing all Record <Id>; occurences with the correct object name. e.g. Record 27; will be replaced with Record Item;

Would be great, if I could do this with the quick actions. (maybe even for all variables and parameters in this method or this object)

Same for Codeunit <Id>, Report <id>, etc.

DavidFeldhoff commented 3 years ago

Hi and thanks for reaching out. I understand the topic, but I never had to convert cal to al yet on my own, so sorry if I ask dumb questions. Isn't the txt2al command for that, so that the whole cal file is converted?

https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/upgrade/devenv-code-conversion

Nevertheless, I think I can add code actions for the conversions.

dannoe commented 3 years ago

Yes for our base product we used txt2al. But for single implementations on function/procedure level I use copy&paste from the text export. I don't even know if the txt2al works for single files, because it somehow needs the names of the referenced objects.

I started an implementation of this feature at the weekend. It took me some time, since it was the first time developing an vscode extension. It already worked in some small tests, but I realisied its not very handy to apply this code action for every variable/parameter manually, so I am planing to convert this code-action to an command-palette command: "Convert object ids to object names for this file". It's still a big WIP, so the PR is still a draft, but you can take a look at it: #107 In fact, as I write this, it occurs to me that I am not correcting the parameters at all. 🤦🏼‍♂️

DavidFeldhoff commented 2 years ago

As Andrzej picked up the second step, I'll close this. Sorry for never getting back to you again. The pressure wasn't that high on my side after your comment here..

The command in the "AZ AL Dev Tools/AL Code Outline" extension is called "Convert Object Ids to Names in the Active Project" https://github.com/anzwdev/al-code-outline#code-transformation-commands