Mar 6, 2014 5:55 AM
Hello, it seems from my testing that there are a couple code completion features missing from AppCode 2.5.4 (and there was no mention of any fixes to code completion in 2.5.5)
- Pressing Ctrl+Space twice is supposed to do completion based on unimported headers (I assume Ctrl+Space once is supposed to only complete based on current imports)? In my testing, there is no difference between pressing Ctrl+Space once or twice. Either way will complete using unimported headers.
- Smart completion (Ctrl+Shift+Space) is supposed to examine local scope variables and chain method calls up to two levels deep to find suggestions of the expected type. In my testing, only local scope variables themselves, methods chained on Foundation classes, and single depth methods called on self will appear in smart code completion. So if I have a class in my project called Foo that is defined like this:
@interface Foo : NSObject
@property(nonatomic, copy) NSString *name;
And I call smart code completion after the = sign in the below statement:
-(void) someMethod:(Foo *)foo
NSString* string =
I would expect to see "foo.name" in the smart code completion suggestions, but I do not. Also, pressing the smart completion shortcut a second time doesn't sem to increase the number of suggestions at all, but only reloads the same suggestions that were present after only pressing the shortcut once.
- Smart code completion often suggests symbols of the wrong type. In the below screenshot, I decalre a variable "something" of type BOOL, and smart complete on the right hand side of the expression. The first two smart completion suggestions are enum constants, not BOOL types at all (see screenshot). Further down, the suggestions list includes some BOOL values, bool values, Boolean values, glBoolean values, NSTextAlignment values, NSCalculationError values, more enum constant values, etc. See second screenshot below:
I realize that these all could theoretically be a 0 or a 1, just like BOOL, but it seems inappropriate here. I have also seen smart completion offer me things like a CGRect local variable when it should be suggestion only NSStrings.
Am I missing a setting or something else? Or are these features not working as expected?
"Trick #3: Smarter completion
Actually there’s more intelligence hidden behind both completion kinds that can be revealed by pressing the corresponding shortcut twice.
Press ⌃Space for basic completion twice, and AppCode will find not yet imported symbols (for example, functions) and add the import for you.
If Smart Type completion didn’t suggest you anything, try pressing the same shortcut (⌃⇧Space) one more time: AppCode will look up values of the expected type which can be retrieved through a chained method call."
From blog post:
Next feature, which makes you even more productive, is Chain completion. If you need to type a chain like getModule().getProject(), just call Smart completion twice. In that case IntelliJ IDEA will scan variables, fields and methods, visible from the context, and offer you a chain, which satisfies expected type.
As you might know, recently there was a plugin for Eclipse Juno, called Code Recommenders. This is quite interesting plugin, which also claims to provide a kind of chain completion. However, it works in a different way. While Code Recommenders suggests only chains of Eclipse SDK APIs classes, IntelliJ IDEA provides chains of any classes from your code."