This Question is Answered

1 "helpful" answer available (2 pts)
6 Replies Last post: Mar 13, 2014 9:02 PM by Daniel Hall  
Daniel Hall Newbie 36 posts since
Jan 9, 2014
Currently Being Moderated

Mar 6, 2014 5:55 AM

Code completion features missing in 2.5.4

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)

 

Specifically:

 

- 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;

 

@end

 

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:

 

Screen Shot 2014-03-05 at 6.44.56 PM.png

Screen Shot 2014-03-05 at 6.41.39 PM.png

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?

 

References:

 

From blog post:  http://blog.jetbrains.com/objc/2012/05/appcode-code-completion-101/


"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: 

 

http://jetbrains.dzone.com/articles/top-20-code-completions-in-intellij-idea

 

"Chain completion


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."

Alexey Ushakov Newbie 39 posts since
Aug 5, 2013
Currently Being Moderated
Mar 6, 2014 1:13 PM in response to: Daniel Hall
Re: Code completion features missing in 2.5.4

Thanks for the detailed report. We've filed an issue (http://youtrack.jetbrains.com/issue/OC-9337) concerning completion problem with property of a class .

However, I'm afraid there is no error in completion of the asignment to the variable of BOOL. The BOOL is not a dedicated type here it's just typedef of char.

Alexey Ushakov Newbie 39 posts since
Aug 5, 2013
Currently Being Moderated
Mar 7, 2014 5:08 PM in response to: Daniel Hall
Re: Code completion features missing in 2.5.4

Daniel,

 

We might want to add some sorting to the list of alternatives for BOOL variables in the future (in order to suggest YES/NO first) but I'm afraid that removing all the alternatives except YES/NO might break someone's workflow. What is about logical expressions where some people might want to use any value != 0 as true?

 

Concerning enums - they are distinct types (not typedefs) in C/Objective-C with implicit conversion of their members to int. So, it's quite straightforward to handle the example with case statement that you've mentioned.

 

I've also seen cases where smart completion suggests completely mismatched symbols (like CGRect for an NSString expression), which I will document better the next time I encounter it.

Yes, sometime we may be wrong, so please, send us all such cases.

 

Best Regards,

Alexey

Alexey Ushakov Newbie 39 posts since
Aug 5, 2013
Currently Being Moderated
Mar 13, 2014 1:39 AM in response to: Daniel Hall
Re: Code completion features missing in 2.5.4

Daniel,

 

Thanks for such a complete investigation of possible behaviour of completion. We'll concider it in our development of next release of AppCode. Here the issue http://youtrack.jetbrains.com/issue/OC-9374

 

Best Regards,

Alexey

More Like This

  • Retrieving data ...