• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Xcode 4, llvm and jump to definition
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Xcode 4, llvm and jump to definition


  • Subject: Re: Xcode 4, llvm and jump to definition
  • From: Thomas Clement <email@hidden>
  • Date: Wed, 12 Oct 2011 11:49:27 +0200

On Oct 12, 2011, at 11:18 AM, Quincey Morris wrote:

On Oct 12, 2011, at 01:08 , Thomas Clement wrote:

Xcode 4 and llvm was said to improve symbols indexing so with such code:

NSCache *cache = ...
[cache setDelegate:self];

If you ask to jump to definition on the "setDelegate:" method it would jump you to the definition of -[NSCache setDelegate:].
Well actually it does not, instead it displays a menu filled with all the setDelegate: methods gathered from all the frameworks and project. And this happens also all the time with my own methods as well, Xcode displays menus of methods instead of jumping directly to the appropriate method based on the receiver type.

I'm not sure why you think this is a result of deficient *indexing* rather than a design decision. Jump to Definition takes you to the definition of the *selector*, not to the definition of the method being called. So, if there are multiple methods declared with that selector, you get to choose.

In part, the reason it behaves like this is that the editor (and the compiler, for that matter) doesn't strictly know which of the methods is going to be called. At the 'setDelegate:' call, 'cache' might be a subclass of NSCache with its own implementation of that method.

You can certainly argue that defaulting to the "obvious" method would be a better choice, but that would leave a need for a separate function for calling up the menu. I would speculate that the Xcode editor interface is so overloaded with modifier-key variations on basic functions that it was decided to leave out what was thought to be the less essential function, but I'm just guessing.

Also, I realize you may just be using NSCache as an example, but what's the point of jumping to -[NSCache setDelegate:] anyway? You're just going to go to the .h file, which contains no useful information. If in fact your problem is really with jumping to your own methods, then I think the following considerations arise:

1. If the "duplicate" method signatures are unrelated methods in different classes, it might be a better choice to make them unique. There are some dangers in Obj-C using one selector for different (i.e. non-polymorphic) purposes.

2. If the "duplicate" signatures are overrides within a class hierarchy, you can't really expect the editor to choose one for you.

3. If the "duplicate" signatures are in separate classes but intentionally identical (i.e. real polymorphism), then it would probably be reasonable to expect the editor to choose the correct one, wherever the type is known at compile time.

My logic here is imperfect -- you could certainly dispute my reasoning -- but I'm trying to make the point that the issue you raise is deeper than it might seem, and there are multiple competing factors in any possible resolution.

FWIW.

Right I agree with what you say.
However in pratice I'd like Xcode to be smart and guess my intent which is to look up the definition of the method which is likely to be called. Therefore I would expect it to jump me to the definition of the method that belongs to the class of the receiver or it could display a menu if it also finds subclasses of the receiver class which declare the same method.

Getting a menu with all the methods from the entire code and frameworks and having to look through that menu to find the one method you're interested in is largely overkill. Xcode could be smarter about this. This is just bad workflow in my opinion, I find myself annoyed by this everyday.

Regards,
Thomas

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Xcode 4, llvm and jump to definition (From: Thomas Clement <email@hidden>)
 >Re: Xcode 4, llvm and jump to definition (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: Xcode 4, llvm and jump to definition
  • Next by Date: Re: ndexing Xcode4 project
  • Previous by thread: Re: Xcode 4, llvm and jump to definition
  • Next by thread: Re: Xcode 4, llvm and jump to definition
  • Index(es):
    • Date
    • Thread