Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » [AST] Find using declaration AST node from a ICPPUsingDeclaration binding
[AST] Find using declaration AST node from a ICPPUsingDeclaration binding [message #783327] Wed, 25 January 2012 14:23 Go to next message
Yves Thrier is currently offline Yves ThrierFriend
Messages: 2
Registered: January 2012
Junior Member
Hi,

I try to obtain the AST node of an using declaration from the binding of this using declaration.
namespace A
{
  void foo()
  {
  }
  namespace B
  {
    using A::foo;
  }
}

The binding is obtained via CIndex.findBindings.

For other binding types, it was possible for me to find the related AST node using CIndex.findDeclarations. However, the using declaration binding yields the function declaration name of foo, but it was not possible to find the AST node of the using declaration. Using CIndex.findReferences instead of findDeclarations was not successful as well.

Is there a recommended way to find the AST node related to the using declaration binding?

Thanks in advance
Re: [AST] Find using declaration AST node from a ICPPUsingDeclaration binding [message #792849 is a reply to message #783327] Tue, 07 February 2012 13:45 Go to previous messageGo to next message
Yves Thrier is currently offline Yves ThrierFriend
Messages: 2
Registered: January 2012
Junior Member
So it looks like there is no solution for this. At least I haven't found one by myself yet. However, I'd like to provide
a workaround for people encountering the similar problem.

First of all, the obtained ICPPUsingDeclaration binding provides a getOwner method
which in my case will yield a namespace binding. Using this namespace binding, you
can request all declarations and definitions of the owning namespace from using the
index. After resolving the found nodes to AST nodes, it is possible to apply an
ASTVisitor instance visiting all names in the AST checking whether a binding for a
visited name is equal to the previously obtained ICPPUsingDeclaration binding. If
this is the case, you found the node of the using declaration (there may are
multiple). Make sure to compare the index adapted bindings, otherwise the comparision
may fail.

Regards
Re: [AST] Find using declaration AST node from a ICPPUsingDeclaration binding [message #793237 is a reply to message #792849] Tue, 07 February 2012 23:07 Go to previous message
Yevgeny Shifrin is currently offline Yevgeny ShifrinFriend
Messages: 208
Registered: July 2009
Senior Member
Maybe you should ask this question in cdt-dev mailing list.

Thanks,
Yevgeny
Previous Topic:Standalone parser
Next Topic:Project directory does not expand
Goto Forum:
  


Current Time: Thu Mar 28 20:11:36 GMT 2024

Powered by FUDForum. Page generated in 0.02507 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top