Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Understanding Bindings

Hi Simon,

On Sun, May 12, 2013 at 2:52 AM, Simon Taddiken <simon.taddiken@xxxxxxxxxxxxxx> wrote:
Hi all,

after crawling through the code for some hours I finally considered asking you again would be a far more easy way to help me understand the semantical bindings in CDT.
In my understanding I should for example be able to get a collection of places where a certain declaration is used, or the other way around, the declaration to an IASTIdExpression. My first impression is that all the different IBinding subclasses just do not deliver those information in the first place.
Most simplistic use-case would be the following scenario: I have an IASTIdExpression and I want information where this identifier was declared and all the other locations in the document where the same declaration was used. From the IASTIdExpression I get an IASTName, from there I get an IBinding, which might be of type IVariable. But now? How do I determine, for example, whether this variable is a constant and where it is also used?

From an IBinding you can get all declarations, definitions and references (IIndex.findDeclarations(IBinding), IIndex.findDefinitions(IBinding), IIndex.findReferences(IBinding)) or limit the search to a particular source file (IASTTranslationUnit.getDeclarationsInAST(IBinding), IASTTranslationUnit.getDefinitionsInAST(IBinding), IASTTranslationUnit.getReferences(IBinding)).

I'd be happy if someone would give me a short explanation or a link to further documentation (if existing) on how these things work.

greetings,
Simon

-sergey 

_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev


Back to the top