Apex Code Style: Functional style adjustments

Issue #1310 new
Justin Julicher created an issue

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.

I guess you would need options like:

  1. Align functional continuation with assignment operator
  2. Align functional continuation with dot operator
  3. 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 (4)

  1. Justin Julicher reporter

    Hmm must be a bug in the Bitbucket wiki - doesn’t like the single apostrophe and keeps replacing them with HTML escapes.

  2. Log in to comment