Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [cdt-dev] How to find binding definition

Thanks Markus,

      Will this hold true if, say,    Project1 refers Project2 and Project3
for certain declarations,  and Project2 and Project3 both have a
declaration of a class named Class2(same name). And a file(Class1.h) from
Project1 includes the header file(Class2.h) for the declaration of Class2
in Project2.    Now to get the declaration of Class2 which is referred by
Class1.h if i do  ---

       (IIndexManager.getIndex(ICProject)),   where ICProject is Project1.

      and then index.findDefinitions(binding)

      gives back two declarations one from Project2 and other from
Project3, probably because both of these projects are referred by Project1,
even though Class2.h from Project2 is the only include statement Class1.h


  From:       "Schorn, Markus" <Markus.Schorn@xxxxxxxxxxxxx>                                                                             
  To:         "CDT General developers list." <cdt-dev@xxxxxxxxxxx>                                                                       
  Date:       11/07/2008 02:34 PM                                                                                                        
  Subject:    RE: [cdt-dev] How to find binding definition                                                                               

You should limit your index to the project of interest, then the other
projects will not be searched. (IIndexManager.getIndex(ICProject))


> -----Original Message-----
> From: cdt-dev-bounces@xxxxxxxxxxx
> [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Sanjesh R Nair
> Sent: Friday, November 07, 2008 5:14 AM
> To: cdt-dev@xxxxxxxxxxx
> Subject: [cdt-dev] How to find binding definition
> Importance: Low
> Hi All,
>       How can we find the definition of a given binding?
>       Say, I have a class like below:
>       #include "Class2.h"
>       class Class1 {
>             private:
>                   Class2 attribute1;
>       };
> And Class2 is declared in a different project. I have the
> ASTTranslationUnit of this file, which I am processing and
> find the attribute with type Class2(a binding). I need to
> identify the file containing the declaration of this binding
> type. How can I achieve this programmatically?
> One of the ways I found that can be used was to get the
> index(IIndex) of the project containing Class1 and then
> finding the binding with it by calling:
>       index.findDefinitions(binding);
> This method returns me back an array of IndexName. This is
> fine if there is only one definition for the given binding.
> But if there are multiple definitions(say, there is a class
> named Class2 declared in a third project as well) then this
> method would return multiple IndexNames. In this, scenario
> how can I identify the correct definition referenced in the project?
> Is there any other way to get the definition? Right now I
> just want to find the file containing the referenced
> definition. I am using CDT 5.0.
> Thanks,
> Sanjesh.
> _______________________________________________
> cdt-dev mailing list
> cdt-dev@xxxxxxxxxxx
cdt-dev mailing list

Back to the top