Apex Code Style: Functional style adjustments
I have classes that I guess follow the ‘Builder’ pattern and so when formatting these the alignment doesn’t really make sense.
It would be good in the if we could have additional check boxe(s) so that when an assignment operator (&;=') is on the previous line that we can align (with continuation indent) under the ‘Keep indents on empty lines’ check box.#39
I guess you would need options like:
- Align functional continuation with assignment operator
- Align functional continuation with dot operator
- Align Map/Set/List initializer with assignment operator
So that the formatted code option 1 could look something like:
And then for option 2 could look something like:
List<SObject> myList = cu.Collection.of(TriggerContext.getInstance().newObjects())
.filter(new Triggers.AnyFieldHasChangedFilter(COMMON_FIELDS_TO_CHECK))
.log('MyLog message Id: {0}', [SObjectField])
.asList();
but you would also have to support something like:
List<SObject> myList = cu.Collection.of(TriggerContext.getInstance()
.newObjects())
.filter(new Triggers.AnyFieldHasChangedFilter(COMMON_FIELDS_TO_CHECK))
.log('MyLog message Id: {0}', [SObjectField])
.asList();
thanks.
Comments (5)
-
reporter -
reporter Any chance of this happening?
-
should rename to Fluent Style.
Can you re-assign to my personal account?
-
Was just looking to see if this functionality existed and found this post on Jetbrains website: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360005908680-Java-Formatting-Continuation-Indent-in-Chained-Method-Calls
So in java they have an option 'Use indents relative to expression start"
Do you think you would be able to implement something similar?
-
repo owner - changed status to resolved
Issue tracker grooming. I think the formatter was properly fixed regarding builder/fluent-style APIs quite a bit back. Let me know if not.
- Log in to comment
Hmm must be a bug in the Bitbucket wiki - doesn’t like the single apostrophe and keeps replacing them with HTML escapes.