1

How can I automatically correct the indentation of my apex classes on Visual Studio Code?? I installed the Uncrustify extension but it is not working.

Also is there any way to document my methods automatically with visual studio?? With "document" I mean:

@Author
@params
@Description

In Eclipse there is a function that enables to select the method and it gives you an automatical way to do this.

5

While I know some folks are happily and successfully using uncrustify, the formatting route that's currently recommended with the Visual Studio Code Extension Pack for Salesforce is Prettier.

The setup for Prettier on Apex is documented as part of the user guide for the extension pack. I've used it to a limited extent with success.

3

Uncrustify

It only works if you enable an override (by default, it works on other languages). I found this blog post that explains more. You need to create a configuration file (uncrustify.create), then include the following settings:

{    "uncrustify.langOverrides": {
        "apex": "JAVA"
    }
}

Auto-Generate Documentation

You can use Snippets to create your own documentation patterns, or install one from, say, Java, and configure it to work with Apex as well.

ApexDoc

You can use ApexDoc to generate documentation for your code, just as you would in Java.

  • 4
    n.b ApexDoc is unmaintained and is known not to work for some projects. – David Reed Feb 24 at 17:42
  • @DavidReed I couldn't find an updated version of it; if you know where it went off to, I'd be glad to reflect that in my answer. – sfdcfox Feb 24 at 17:44
  • As far as I know, nobody is maintaining it at this point. I'd be delighted to be wrong. – David Reed Feb 24 at 17:46
  • 4
    In a chat with Chris Peterson, back in January this year, he said "we are taking a look at making a new ApexDoc tool that's based off the real Apex compiler, rather than an attempt to reverse engineer it. There's an early prototype internally, but I don't have a timeline for when it will be available more generally". – Phil W Feb 24 at 18:15
  • 4
    @PhilW Cool stuff. Hopefully we get it soon, it's been about 13 years late, if you ask me. – sfdcfox Feb 24 at 19:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.