Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Resolving and listing fields of a struct

> Can someone point me in the right direction how to search the 
> index for the declaration, so that I can list the fields in the struct? I 
> am currently trying to get this information by using the index and 
> bindings. However, this is not working.
> IASTName sourceName = fieldReference.getFieldName();
> IBinding myBinding = index.findBinding(sourceName);
> IBinding resovledBinding = sourceName.resolveBinding();
> IBinding owner = resovledBinding.getOwner();
> System.out.println("Owner: " + owner.getName());

Apart from the call to index.findBinding(), which you don't need and whose result you're not using anyways, this looks fine. 'resolvedBinding' should be the binding representing the field, and 'owner' the binding representing the structure that contains the field.

If that's not what you're seeing, could you be more specific about what you are seeing? Is something null?


Back to the top