On Fri, May 8, 2009 at 1:43 PM, Jeff Johnston
<jjohnstn@xxxxxxxxxx> wrote:
I have the following C++ code:
#include <iostream>
#include <string>
using namespace std;
int main() {
string *a = new string("abc");
a->size();
a->append("a", 2);
std::cout << "!!!Hello World!!!" << std::endl; // prints !!!Hello World!!!
return 0;
}
I have written a libstdc++ hover help plugin which is generated from the actual libstdc++ documentation.
When a user hovers over the "append" method above, I backtrack and find "a". I use a SharedASTJob to get the enclosing ASTName via:
ast.getNodeSelector(null).findEnclosingName();
IASTName name = ast.getNodeSelector(null).findEnclosingName();
IBinding binding = name.resolveBinding();
String[] qualified;
if (binding instanceof ICPPBinding) {
qualified = ((ICPPBinding) binding).getQualifiedName()
} else {
qualified = new String[] { binding.getName() };
}
The only thing left is to join the names using "::" as a separator.
I then do a second SharedASTJob to getDeclarationsinAST() for the binding of "a". This gets me an IASTSimpleDeclaration to which I perform ast.getDeclSpecifier(). This gets me an IASTNamedTypeSpecifier to which I get the name via getName().
The problem for the above case is that I only get "string". I need to get: "std::string" or "std::basic_string<char, etc..>" as I have a map of fully-qualified class and typedef names to which I can resolve the online help. I use a separate SharedASTJob to resolve to the correct append method signature and this is working great. For example, if the above test is changed to use std::string explicitly, everything works fine.
So how do I resolve the namespace for the declaration of a? I can send code off-line if further details are needed.
Thanks,
-- Jeff J.
-sergey
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev