vscode-uncrustify icon indicating copy to clipboard operation
vscode-uncrustify copied to clipboard

No option to treat space around colon inside a a [] itself inside a ()

Open KevinGossentCap opened this issue 6 years ago • 3 comments

exemple List<Account> accounts = new List<Account>([SELECT id, Name, ShippingStreet, ShippingCity, ShippingCountry, ShippingPostalCode FROM Account WHERE id IN :whatIds]);

if we format, whatever the options used we moves the colon : character to List<Account> accounts = new List<Account>([SELECT id, Name, ShippingStreet, ShippingCity, ShippingCountry, ShippingPostalCode FROM Account WHERE id IN: whatIds]); this result can give errors in the code (the :variable is used to put a variable entry inside the query and it might not work with a space between : and the variable name)

KevinGossentCap avatar May 04 '18 13:05 KevinGossentCap

This extension interfaces with uncrustify and doesn't do any actual formatting by itself. Is this an option that's supported by uncrustify, but somehow not presented in the extension ? What language are you using ?

LaurentTreguier avatar May 04 '18 17:05 LaurentTreguier

The language is Apex (which uses the Java structure). The problem is the additional space forced after the colon. I tested to have the [] out of the () and the space is still added but the one before is not removed. Maybe I'm just struggling with the options but I found none to remove the "after space" inside of []

KevinGossentCap avatar May 09 '18 07:05 KevinGossentCap

Apex is not officially supported by Uncrustify. While this extension allows formatting Apex as if it was Java, it's only because at some point, it seemed to work, it's done in the atom-beautify package for Atom, and people seem to use it frequently for Apex. The problem is simply that Uncrustify doesn't support Apex. The only workaround I see right now would be to use some other settings to remove spaces before colons, even it it's going to remove them in more places.

LaurentTreguier avatar May 09 '18 18:05 LaurentTreguier