anzwdev / al-code-outline

AL Code Outline for Visual Studio Code
MIT License
51 stars 13 forks source link

CodeActionsOnSave is terribly slow (AL <> AL code outline) #261

Closed fvet closed 2 years ago

fvet commented 3 years ago

We've tried to start fixing some of the code warnings by having variables / properties sorted upon saving the file.

"alOutline.codeActionsOnSave": [
        "SortProperties",
        "SortVariables"
    ],

However, AL is acting terribly slow (https://github.com/microsoft/AL/issues/5664) in larger projects (4700+ files) when formatOnSave is enabled (even on files with a few hundred code lines) and it does not seem like we should expect any fixes soon from MS :( Disabling formatOnSave is not the answer we'd expected.

Is there any workaround / better way to have the SortProperties / SortVariables (manually) ran as part of a Code Action, separate commandlet, ... instead of upon saving the file? Right now, we need to wait 10+ minutes untill we then finally decide to cancel the save/format operation.

anzwdev commented 3 years ago

If you remove these actions from "alOutline.codeActionsOnSave" setting, then you can run them manually by moving cursor to object keyword (page/codeunit/table/...) or object name and then clicking on the yellow bulb. These actions should be visible in the menu that will be opened.

anzwdev commented 2 years ago

Hi

I've released a new version of the extension, it contains a few fixes that should help you with performance issues with large al projects:

  1. CodeCop warning fixes code actions are disabled by default, they can be enabled by changing "alOutline.enableCodeCopFixes" setting to true. I had to do it, because they need diagnostics reported by al code analyzers to work which means that whole visual studio code actions discovery process would have to wait for CodeCop/Microsoft AL Extension to finish parsing ana analyzing current solution.
  2. I've added "FormatDocument" value to the list of available actions in "alOutline.codeActionsOnSave" setting. You can try to disable standard document formatting which is done by Microsoft AL Extension and enable this one. It could help as mine extension should not be so busy parsing files so VS Code won't have to wait so long for the result. But don't expect it to always return results immediately. I've found during my tests that when you enable code analyzers and open very big al projects, Microsoft AL Extension sometimes can use 100% of processor power not leaving much to other processes, so saving document can still take 2-3 seconds.