DavidFeldhoff / al-codeactions

MIT License
17 stars 8 forks source link

[Suggestion] Remove hungarian notation #116

Closed fvet closed 2 years ago

fvet commented 3 years ago

It would be nice if we had a code action on 'procedure' level that allows to replace any (legacy) hungarian notations. Right now we're forced to do a 'rename symbol' on each function parameter. (I'd limit the action to function parameters / return variables only, since these are exposed externally. Locals can remain the same)

procedure CreateAlert(pcodAlertID: Code[20]; pvarSourceRecord: Variant; ptxtMessage: Text[250]; pintPageID: Integer) AlertCreated: Boolean
    var
        AdditionalRemarks: list of [Text[250]];
    begin
        AlertCreated := CreateAlert(pcodAlertID, pvarSourceRecord, ptxtMessage, AdditionalRemarks, pintPageID);
    end;

expected result

procedure CreateAlert(AlertID: Code[20]; SourceRecord: Variant; Message: Text[250]; PageID: Integer) AlertCreated: Boolean
    var
        AdditionalRemarks: list of [Text[250]];
    begin
        AlertCreated := CreateAlert(AlertID, SourceRecord, Message, AdditionalRemarks, PageID);
    end;

Other option might be to have a (powershell) script available on file / workspace level, that applies the rule to all files. Not sure if a 'rename symbol' would then still be required, or if a simple 'replace all' could do the trick. (function parameters for integrationevents should not be changed)

Preferably with a pre-defined list of values to be replaced : pint, pcod, pvar, ptxt, prec, pdec, ...

DavidFeldhoff commented 3 years ago

I get the point. I think I'll add then a setting like you suggested: "alCodeActions.prefixesOfVariables": ["pint", "pcod", ...] And then there could be a code action "Remove Prefixes of variables".

But I think this has a lower prio than 118 or 119, right? So it may be queued up a bit, I hope that's fine. Maybe you can pray for some rainy days, then it'll be implemented faster by me :)

All the best and thanks for your ideas! David

fvet commented 3 years ago

This one is indeed a (very) nice to have (the others are far more usefull for us and the community I suppose)