How to get to object which is owner of a method?

If my editor cursor is in a member, variable or method which are defined in an object, how do I navigate to the object declaration?

For example if I have  jquery-1.4_4.js file open. I want to jump to the object which owns bindReady or the object in which bindReady is defined, what's the shortcut for it?

.
.
.
},

    bindReady: function() {
        if ( readyBound ) {
            return;
        }

.
.
.

11 comments
Comment actions Permalink

holding down ctrl and left clicking on  bindReady will take you to the place where it is defined.

or if you dont want to use the mouse, put the cursor over bindReady and use the shortcut ctrl+b

0
Comment actions Permalink

bindReady as I am showing it is where it is defined. The code after function() is the body of the function. bindReady is not a call to the function. It is the function declaration itself. See the comma before it? There are other functions defined too for an object. I want to navigate to the decleration of that object. This feature is useful when the object is large and has tens of members.

0
Comment actions Permalink

Hi adbu,

I do not know any possible shortcut for this (so it can be done just in 1 key-press combination), but you can achieve this by using Structure panel:
1) make sure you have "Scroll from Source" and "Autoscroll to Source" selected (the last 2 buttons on than panel)
2) position your cursor on desired place in code editor window -- Structure panel should scroll and select appropriate entry
3) activate Structure panel (Alt+7)
4) press Left -- it should go to the parent of that method/property.

This requires to use 2 different shortcuts/key combinations, but you can try and record such sequence as a macros (and then assign shorter/more convenient shortcut).

0
Comment actions Permalink

I don't underdstand what "Left --" means in #4.

Wouldn't it make sense to add the functionality as an option for the Go To context menu item?

0
Comment actions Permalink
I don't underdstand what "Left --" means in #4.

"Left" means Left arrow key (the one with the arrow pointing left, hence "Left").

Wouldn't it make sense to add the functionality as an option for the Go To context menu item?

Above I have described how this can be achieved using currently available functionality. If you want such new functionality (action) to be added to future versions of Web/PhpStorm -- you are welcome to submit a feature request on Issue Tracker. It is possible that such request already been made -- please check existing tickets.

0
Comment actions Permalink

I am missing something. If the structure is already open nothing happens. Do you mean the focus should be in the structure panel when left key is pressed? Because left in the editor just causes the cursor to go left!

How do you close the structure panel? I can only hide/unhide it.

0
Comment actions Permalink
Do you mean the focus should be in the structure panel when left key is pressed?

Yes -- step #3 is to activate Structure panel (so it has focus) and step #4 is to be executed when still staying in Structure panel. The conditions described in step #1 are essential for this to work.

How do you close the structure panel? I can only hide/unhide it.

I'm not sure that you can fully close this panel -- but hide should be enough. You can quickly jump (move focus) from any side panel back to code editor by pressing Esc.

0
Comment actions Permalink

I have clicked all over the editor and the structure panel never scrolls. I have clicked on 'bindReady' and nothing scrolled in the structure panel. However if I click on an entry in the structure panel the source scrolls.

You can see a demo of this : http://www.screencast.com/users/Freehosting/folders/Default/media/d11ea734-0cdc-4f3f-bb2a-880c3a5459bd

0
Comment actions Permalink

Hi abdu,

I have double checked this on latest jquery 1.5 source ... and it is indeed does not work for the elements you are trying to select (properties/methods -- sorry, I'm not good at JS) but working fine for functions (where you have word "function"). Originally I have tested this on PHP code as well as simple JS code (where normal functions were used). Sorry for missleading you.

I would recommend to submit this as feature request to the Issue Tracker.

0
Comment actions Permalink

It's not working in 2.0 EAP either. If I click on a object function in source, structure panel doesn't not scroll.

0
Comment actions Permalink

Hello,

Bug filed as http://youtrack.jetbrains.net/issue/WI-5298. Please watch it or vote for it to be notified on updates and fixes.

Regards,
Kirill

0

Please sign in to leave a comment.