Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] C++ Hover Help

Has anybody successfully implemented C++ hover help/completion for member functions?

I have been looking into it to support the libstdc++ library documentation and have reached an impasse.

I am attempting to extend an existing ICHelpProvider extension. I don't think the ICHelpProvider extension was ever meant to support C++ since it only passes the member name and does not give enough information to figure out the context (i.e. what class it is really from and what it's parameter signature is). To get around this problem, I created an interface that extends ICHelpInvocationContext and provides the IRegion of the call being hovered over.

For example,

   std::string *k = new string("abc");

Hovering over size, we can figure out from the TranslationUnit contents that size is being referenced by a pointer k and has no parameters.

Now to figure out what k points to. This information can be found in the AST from the TranslationUnit that is already passed in the ICHelpInvocationContext (via the getAST methods).

A major snag I have run into is that it is taking far too long to get the AST. I timed over 10 seconds debugging my simple C++ Hello world example which added the above 2 statements. This is too long to expect a user to wait to get hover help. I tried using the AST_SKIP_ALL_HEADERS and AST_SKIP_INDEXED_HEADERS but that resulted in a null IASTTranslationUnit. Theoretically, could it not figure out that k points to an unknown type: std::string without looking at any headers? Obviously, this would not support macro expansion, but it would cover a lot of scenarios. Just a thought.

Is there anything I could have done differently which would speed things up enough to be useful?

Am I trying to solve a problem already figured out by somebody else?


-- Jeff J.

Back to the top