LaurentTreguier / vscode-uncrustify

Code format using uncrustify
66 stars 10 forks source link

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

Open KevinGossentCap opened 6 years ago

KevinGossentCap commented 6 years ago

exemple List accounts = new List([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 accounts = new List([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)

LaurentTreguier commented 6 years ago

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 ?

KevinGossentCap commented 6 years ago

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 []

LaurentTreguier commented 6 years ago

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.