waldo1001 / crs-al-language-extension

Make working with the (Dynamics NAV / 365) AL Language easier and more efficient.
MIT License
34 stars 43 forks source link

Add (Leave) Quotation Marks to Field/Control Names for AL Keywords #214

Open pri-kise opened 2 years ago

pri-kise commented 2 years ago

Hi, Right now AL Keywords are saved without quotes when I use the OnSave Features of the Waldo's CRS AL Language Extension. What do you think about adding quotation marks around AL Keywords.

There is a related issue on the al-code-outline extension: https://github.com/anzwdev/al-code-outline/issues/302#issuecomment-1003387295

fvet commented 2 years ago

@waldo1001 This is indeed an annoying side effect when running the alCodeOutline cleanup commands (including FormatDocument) combined with an app that has filenames controlled by CRS.

alCodeOutline settings:

image

CRS settings:

image

It results in additional / excessive delta's in our commits / PR's.

Result when running alCodeOutline cleanup (" " have been removed)

image

Result when saving the file (" " are added again on reserved keywords)

image

JavierFuentes commented 2 years ago

Hi, I have this problem too in all my projects, but I think the best is TO KEEP all this quotes because in some special names like "Code" , "Type", "Document Type"::"Order", ObjectType::"Codeunit", etc which are spread throughout the standard code and in my custom code too, the VSCode AL Language automatic coloring highlights this words erroneusly in blue color because it thinks they are Keywords and not Identifiers.

waldo1001 commented 2 years ago

I personally don't mind the extra quotes .. same reason as Javier.. .

In terms of the extension: it doesn't have any parser in the system, so it doesn't know if whatever it generates is going to be "compileable". That's why I chose the "will always compile" way.. 🤷‍♂️. I could be adding additional coding on every part of where it changes/adds code to handle cases like this - but in a way, it's almost like building a parser myself. And that's simply something I can't, won't and have the time for.

That being said - since Vjeko now has a parser out there, I might throw everything overboard, and go with that. At least, when it's able to catch what I need ... I talked to him, and he doesn't have the bits I need yet .. 🤷‍♂️.

fvet commented 2 years ago

@waldo1001 I want to pick up this issue again, this time not because it adds too much delta in our Pull requests once files are being renamed by CRS in combination with the AZ AL Dev Tools cleanup action, but because it simply creates invalid AL files.

I've disabled all 3rd party AL extensions except for CRS.

I've created a page with following action (mind the " " around Event, which is a reserved keyword)

actions
    {
        area(Creation)
        {
            action("Event")
            {
                trigger OnAction()
                begin
                    ;
                end;
            }
        }
    }

When enabling the setting below and saving the file again ...

"CRS.OnSaveAlFileAction": "Rename",

... the page is 'formatted' and the " " are stripped from the action / Event.

actions
    {
        area(Creation)
        {
            action(Event)
            {
                trigger OnAction()
                begin
                    ;
                end;
            }
        }
    }

leading to the page no longer compiling :(

image

As a work-around we've temporarily disabled the OnSaveAlFileAction, but we would like files to be (re)named automatically upon save.

Any hints on how to get this solved?

Related issues: #153 , #178

fvet commented 2 years ago

Sample project attached ALProject14.zip