Atom-beautify: Adding extra indentation in Apex code

Created on 16 Nov 2016  路  9Comments  路  Source: Glavin001/atom-beautify

The results of beautification are not what I expect.

This is what the code looked like before:

@isTest
private class MyTestClass {
@testSetup
static void createCommonData(){
(tab)Account a = newAccount();
(tab)insert a;

The beautified code should have looked like this:

@isTest
private class MyTestClass {
(tab)@testSetup
(tab)static void createCommonData(){
(tab)(tab)Account a = newAccount();
(tab)(tab)insert a;

Actual Output

The beautified code actually looked like this:

@isTest
private class MyTestClass {
(tab)(tab)@testSetup
(tab)(tab)static void createCommonData(){
(tab)(tab)(tab)(tab)Account a = newAccount();
(tab)(tab)(tab)(tab)insert a;

Steps to Reproduce

  1. Add code to Atom editor
  2. Run command Atom Beautify: Beautify Editor
  3. This beautified code does not look right!

Debug

Here is a link to the debug.md Gist: https://gist.github.com/anonymous/f1b5b9139d6337b588e53b83bb9945e5

Checklist

I have:

  • [x] Tried uninstalling and reinstalling Atom Beautify to ensure it installed properly
  • [x] Reloaded (or restarted) Atom to ensure it is not a caching issue
  • [x] Searched through existing Atom Beautify Issues at https://github.com/Glavin001/atom-beautify/issues
    so I know this is not a duplicate issue
  • [x] Filled out the Input, Expected, and Actual sections above or have edited/removed them in a way that fully describes the issue.
  • [x] Generated debugging information and added link for debug.md Gist to this issue
bug published waiting-for-user-information

Most helpful comment

Thanks @mihaipopescu I will recommend some reconfigurations to Atom Beautify.

All 9 comments

If this is not a problem with Atom Beautify settings it is mostly like a problem from the beautifier, uncrustify. You might try opening an issue with uncrustify and linking it to this issue.

I am working on uncrustify.
Could you push an example source and the config file you use with?

@gmaurel Those should be available in https://gist.github.com/anonymous/f1b5b9139d6337b588e53b83bb9945e5

Just let us know if there is additional information we should be including.

Uncrustify does not support Apex as a language but Atom beautify thinks otherwise https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/uncrustify/index.coffee#L57.

From what I've read Apex is closer to Java and you could try to use that as language override (unless there are some Apex-isms that will break the parsing).

Thanks @mihaipopescu I will recommend some reconfigurations to Atom Beautify.

To confirm, should Apex be removed from Uncrustify beautifier support in Atom-Beautify or is there some configuration changes required to make it work?

I don't know anything about Apex language other than it's a Java dialect but where does it start to differ that I don't know.

should Apex be removed from Uncrustify beautifier support in Atom-Beautify or is there some configuration changes

I think that's entirely your call. Uncrustify supports Java and if that's ok with you I guess you can make some changes to the configs to use that language instead. Better have something than nothing.

Once https://github.com/Glavin001/atom-beautify/pull/1707 has been merged Apex will be treated as JAVA language for Uncrustify.

Published to v0.30.0

Was this page helpful?
0 / 5 - 0 ratings