DavidFeldhoff / al-codeactions

MIT License
17 stars 8 forks source link

[Suggestion] Refactor Assignment to Validate #91

Closed JeremyVyska closed 3 years ago

JeremyVyska commented 3 years ago

Not sure if feasible, but would it be possible to select a large chunk of code, then have a Code Action that replaces any

Rec.Field := [something];

With

Rec.Validate(Field,[something]);

DavidFeldhoff commented 3 years ago

Hi Jeremy, thanks for your idea. I'm currently on vacation and as it's pretty tricky to code while hiking, I can't make it this week :) I'll come back to you if I find some time. Best, David

DavidFeldhoff commented 3 years ago

Hi Jeremy, I added a new functionality for that. I'll release it shortly :) Here you can already see how it'll look like. Any suggestions? https://github.com/DavidFeldhoff/al-codeactions/blob/develop/images/RefactorValidate.gif

JeremyVyska commented 3 years ago

I love it lots! That's marvelous.

Is it possible to expand, just as it is, to be able to select a region of code, say 5 (or even 20 for the crazy) lines of field assignments, and then have the same CodeAction apply to each of 5 the 5 lines?

DavidFeldhoff commented 3 years ago

Don't know exactly what you mean :) So yes, if there are 20 lines directly underneath, you just have to select all of them and execute the codeAction just once. Is that what you're asking for?

JeremyVyska commented 3 years ago

Precisely.

So, given these lines, you select all three:

SomethingJournal."Posting Date" := newDate;
SomethingJournal."Document No." := newDocNo;
SomethingJournal."Amount" := newAmount;

And after one CodeAction, that selection becomes:

SomethingJournal.Validate("Posting Date",newDate);
SomethingJournal.Validate("Document No.",newDocNo);
SomethingJournal.Validate("Amount",newAmount);
DavidFeldhoff commented 3 years ago

That'll work :)

DavidFeldhoff commented 3 years ago

I just released it. Feel free to test it and close the issue afterwards :)

rihlsul commented 3 years ago

Super good. Though I lack permissions in GitHub's Issues to Close this.

DavidFeldhoff commented 3 years ago

Glad to hear !