Multiline method chaining frustration

I do a LOT of method chaining (use ReactiveCocoa all over the place). Finding appCode really frustrating for this.

Here's what I can do in Xcode: http://www.screencast.com/t/QNjZnPvLj

However in appCode if I move to a new line it seems to completely lose the context for autocompletion on the previous method return value.

If I turn on "Always Wrap" for method chaining, turn the continuation indent down to 4, and type directly after the previous method it somewhat works:

http://www.screencast.com/t/vDdoANTEG

But then all method chaining wraps. No I don't want alloc/init on two lines.

If I could get appCode to do autocompletion properly when I move to a new line and haven't closed the previous one with a semi-colon I think I'd be in good shape.

2 comments

Hi Bob - There are some areas of bugginess related to code completion within chained method calls.  For example:  http://youtrack.jetbrains.com/issue/OC-9039   (which you can upvote if you'd like to get JetBrains to prioritize it higher).

Some possible workarounds:

1) I've noticed that in most instances where I'm not getting proper code completion after a space, if I use dot completion (type a dot immediately following the last element or closing bracket) I will get proper code completion.  Since the dot completion will actually list methods as well as properties, and complete them correctly (with a space, no dot), this is a usable alternative.  Example:

Screen Shot 2014-04-16 at 3.24.04 PM.png
^ notice no code completion offered for "substringToIndex:"

Screen Shot 2014-04-16 at 3.24.21 PM.png
^ typing a "." instead of a space after the ] will pop up correct code completion

Screen Shot 2014-04-16 at 3.24.43 PM.png
^ selecting the substringToIndex: code completion correctly chains the method call (without the dot) and even wraps it on the next line for me automatically, due to my method chaining style settings (more on that below).

So hopefully, in your case, the dot completion workaround will get you correct code completion where the normal code completion isn't working properly after a space.


2) Have you tried "Wrap if Long" for your method chaining instead of "Wrap Always"?  This will not wrap things like alloc/init, but will allow you to just type continuously without manually inserting line breaks, and will cause the code completion / auto formatting to create the new lines for you.

Hope some of that helps.  I would like to see some of the nitty gritty details of auto-bracketing and code completion cleaned up in AppCode 3.0.  They have been the subject of some debates in the past, but the current implementation doesn't work as well for me as 2.0 did.

0

Thanks Daniel.

That's helpful, though not sure if I want to get used to typing dot when I'm not actually wanting one. Hopefully this is cleaned up in 3.0!

0

Please sign in to leave a comment.