Looking for more control over code style.

I would like to make some very specific changes to the configured code style for obj c, that aren't supported by the current options. I'm wondering if writing a plugin is the way to go about this, and if the obj c formatter is even available in the open api? I poked around a bit in the plugin code and didn't see a way to customize formatting for obj c.

Here's an example:
I want method call arguments to wrap if long, align by colons ONLY if it doesn't violate continuation indent. For example (indent is 2, continuation indent is 4, right margin is 20):

  //this line:
  [obj withFoo:foo andBar:bar];
  // is wrapped as I like:
  [object withFoo:foo
           andBar:bar];

  // but this line with a longer message param name:
  [obj withFoo:foo longMessage:bar];
  // is wrapped in a way that violates my continuation indent:
  [obj withFoo:foo
   longMessage:bar];

  // I would prefer in this case to align on the continuation indent:
  [obj withFoo:foo
      longMessage:bar];

There are a bunch of additional rules I'd like to add as well:
- Similar to aligning messages params / arguments on colons, in function calls I want to align the params / arguments only if doing so doesn't violate the right margin *and* keeps the argument intact. Otherwise, wrap at the continuation indent. Current behavior will wrap within an argument:
  // current appcode:

  doSomething(ii[1],
              jj[ii[2]],
              doSomething(
                  123));
  // preferred

  doSomething(ii[1],
      jj[ii[2]],
      doSomething(123));



- Nested method calls should have nested continuation indents.
- If wrapping any [method|function] [parameter|call argument], wrap them all (in the same style)

Any pointers on how to go about this would be appreciated.

Thanks!

1 comment
Comment actions Permalink

Jon,

It is not possible to write a plugin for AppCode's formatter, and doubtly will ever be.
Your request is quite reasonable, though, so you may want to file corresponding youtrack issues.

0

Please sign in to leave a comment.