SlickEdit Community

SlickEdit Product Discussion => SlickEdit® => Topic started by: Lou C on February 20, 2012, 01:55:40 PM

Title: Are Hover References Selectable?
Post by: Lou C on February 20, 2012, 01:55:40 PM
I am using SE v16 and when I hover over a function name, the pop-up shows me a reference location for the function.  The problem is, it always points to the location of my function prototype statement and not to the actual function.  I would like to see the location of the actual function in the box so I can just click on it and be located there.  Is there a way to tell SE I want it to locate me on the source and not just the prototype?

Lou
Title: Re: Are Hover References Selectable?
Post by: Graeme on February 23, 2012, 12:01:09 PM
Doesn't look like there is but you can right click and select go to definition.
Title: Re: Are Hover References Selectable?
Post by: Mike on February 24, 2012, 03:37:43 PM
Even though this won't affect the "hover references", another related configurable item is @ 'Tools > Options > Languages > Application Languages > C/C++ > Context Tagging®'
"Prioritize navigation to:"

...and from the docs:
Here you can specify if you prefer to navigate directly to a symbol's definition (proc) or declaration (proto). If Prompt is selected, the Select Symbol Dialog is displayed, prompting you for both definitions and declarations. In any case, if you use Ctrl+Dot to jump to a symbol, you can cycle through the alternate symbols by pressing Ctrl+Dot repeatedly. You can step backwards through the list of matches by pressing Ctrl+Comma. However, once you reach the first match, Ctrl+Comma will then pop you back to your original location, where you were before you pressed Ctrl+Dot.

Independent of the settings for these options, in the following circumstances, SlickEdit® will jump directly to the definition or declaration.

If the cursor is on the first line of a symbol's declaration, it will jump directly to the definition, provided it is unique.

If the cursor is on the first line of a symbol's definition, it will jump directly to the declaration, provided it is unique.

This behavior is particularly convenient for C++ programmers to navigate from a function to its prototype and vice versa. See Symbol Navigation for more information about navigating through your code.
Title: Re: Are Hover References Selectable?
Post by: Lou C on February 28, 2012, 09:30:35 PM
Thanks Mike, that did it!  It does exactly what I want it to do now.  @graeme, right clicking and saying to go to the definition does just that, it goes to where the prototype definition is located, just like it did before.

Thanks guys!

Lou
Title: Re: Are Hover References Selectable?
Post by: Lou C on February 29, 2012, 11:11:48 PM
OK, need help again.  For some reason this stopped working.  Now, with the settings recommended by Mike above, it still goes back to the prototype definition, even though the Tools->Options ->Languages->Application Languages->C/C++->Context Tagging->Go to Definition->Prioritize navigation to: is set to "Symbol definition (proc)".  What could be wrong?  Could it somehow be not thinking my file is a C file?  Remember, this used to work.
Title: Re: Are Hover References Selectable?
Post by: Graeme on March 01, 2012, 11:10:42 AM
OK, need help again.  For some reason this stopped working.  Now, with the settings recommended by Mike above, it still goes back to the prototype definition, even though the Tools->Options ->Languages->Application Languages->C/C++->Context Tagging->Go to Definition->Prioritize navigation to: is set to "Symbol definition (proc)".  What could be wrong?  Could it somehow be not thinking my file is a C file?  Remember, this used to work.

What is it that stopped working?
What is it that used to work?

Be as specific as you can.  I can't tell from your posts whether you're using right click-> goto definition or just what you're doing that isn't working.


Title: Re: Are Hover References Selectable?
Post by: Lou C on March 01, 2012, 01:44:18 PM
What stopped working?
What used to work?

The answers to both of those questions is the same:  When hovering over a function name, and the context tagging window pops up, a left mouse click on the green arrow just to the left of the function name in the window used to locate me to the actual function (file and line number).  Now it takes me to my function prototype file and locates me on the prototype definition for the function.

I did what Mike stated and it actually was working the way I desired.  Then, for some reason unknown to me, it went back to the old way of just going to the function prototype.  I have checked settings and it says it is specified to go to the actual procedure ("Symbol definition (proc)") instead of just the prototype line ("Symbol declaration (proto)").

Lou

Title: Re: Are Hover References Selectable?
Post by: chrisant on March 01, 2012, 07:36:15 PM
Are you trying to go to the implementation of an interface method?
If so, see this thread (http://community.slickedit.com/index.php/topic,2795.msg32827.html#msg32827) for more information.
Title: Re: Are Hover References Selectable?
Post by: Lou C on March 01, 2012, 08:21:14 PM
Yes, I see later in the thread it addresses exactly what I am seeing.  Since it did confirm that version 16.0.3 had the problem and a hoxfix fixed it, I guess I might try that and see what happens.  Thanks for the link.

Lou
Title: Re: Are Hover References Selectable?
Post by: Lou C on March 01, 2012, 08:36:25 PM
Well, I tried the hoxfix, but it did not take care of the problem.
Title: Re: Are Hover References Selectable?
Post by: Graeme on March 02, 2012, 12:01:29 AM
On my system, clicking on the green arrow always takes me to the prototype rather than the definition but I hardly ever do that so I'm not sure what it's supposed to do.  I normally use Ctrl-dot - push_tag to go to a definition.
Title: Re: Are Hover References Selectable?
Post by: chrisant on March 02, 2012, 02:17:47 AM
Can you share a snippet of the code where it isn't working?
To help clarify specifics of what isn't working.
E.g.
Code: [Select]
class Foo : public IUnknown
{
public:
    Foo() : _cRef(0) {}
    ULONG AddRef();
private:
    ULONG _cRef;
}

ULONG Foo::AddRef()
{
    return ++_cRef;
}

extern IUnknown* CreateFoo();

main()
{
    IUnknown* p = CreateFoo();
    p->AddRef();    // This AddRef won't go to Foo::AddRef.
}
Title: Re: Are Hover References Selectable?
Post by: Lou C on March 02, 2012, 05:53:27 PM
Sure, see the following example I wrote in a .c file:

Code: [Select]
void MyFunction(void);

void
MyFunction(void)
{
}

void
main(void)
{
  MyFunction();
}

When I hover over the function name in main, and the pop-up appears with the green arrow, if I left click on the green arrow, it takes me to the prototype definition at the top instead of locating me on the definition itself.  But if I right click and select "Go to definition of MyFunction", it goes to the correct location.

Lou
Title: Re: Are Hover References Selectable?
Post by: chrisant on March 02, 2012, 09:51:36 PM
Ctrl+. is bound to push_tag().

The green arrow on the symbol tooltip works differently.  The tooltip always shows declarations, never definitions.  If there are multiple declarations, it shows "< 1 of 9 >" at the beginning of the tooltip, to let you choose which declaration.  The green arrow is special minihtml markup "<<pushtag", which gets handled in codehelp.e by ctlminihtml1.on_change(), and calls gotoFunctionTag().  The gotoFunctionTag() function accesses the list of declarations shown by the tooltip, and literally jumps to the selected declaration.

In short, the green arrow is designed to jump to literally whatever the tooltip is showing.  And since the tooltip shows declarations, the green arrow can only ever jump to declarations.

There's a loophole, though, and I wonder if it's why it appeared to work temporarily:  If there's only a definition (i.e. the declaration and the definition are the exact same spot) then the tooltip shows the declaration, and clicking the green arrow arrives at the definition because the declaration is the definition.
Title: Re: Are Hover References Selectable?
Post by: Lou C on March 02, 2012, 10:41:59 PM
That is really interesting, and your findings seem very complete.  I definitely know that I was able to click on the green arrow and it took directly to the function, every time, and every function had a prototype somewhere (either in the same file, or in a global function prototype file).  Now it ALWAYS goes to the prototype, wherever it is, every time. It is acting as if the "Symbol definition (proc)" option is simply being ignored, and it always uses "Symbol declaration (proto)."

To get around this problem, I right click on the function and select "Go to definition of <function>".  And that works fine.  But coming from CodeWright, I thought they might offer the same function CodeWright has.  And it looks like they tried.  It just doesn't work consistently, and not at all for me now.  Thanks for your help.

Lou