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

Well, in fact, your problem is the problem of source code parsing: you
are parsing more than compiler will build.
To differenciate which declaration was used you need some additional
info: which include directories are used for this unit compilation,
etc.

I never tried how indexer work with project dependency, but in generic
case, you can configure which include paths are used. Perhaps, this
can be configured on file-basis (i.e. some specific include paths for
any file. Guys from CDT team will correct me if this is not possible.)

If include paths cannot be configured this way, you will need to
filter-out irrelevant declarations by yourself (based on that
additional info).

2008/11/10 Sanjesh R Nair <sanjesh.nair@xxxxxxxxxx>:
> If it takes a performance hit, I may not be able to use it, as this sort of
> processing would be used very heavily.
> Is there any better solutions?
>
> Thanks,
> Sanjesh.
>
>
>
>  From:       "Schorn, Markus" <Markus.Schorn@xxxxxxxxxxxxx>
>
>  To:         "CDT General developers list." <cdt-dev@xxxxxxxxxxx>
>
>  Date:       11/10/2008 02:10 PM
>
>  Subject:    RE: [cdt-dev] How to find binding definition
>
>
>
>
>
>
> What you get back from IASTTranslationUnit.getDeclarationsInAST()
> depends on
> how you created the translation-unit. In the case where it is backed by
> the index
> it will not return declarations from within included files that have
> been pulled
> in via the index. If you create an AST without the use of an index,
> you'll find
> what you need. However the creation of the entire AST is slow and
> usually not an
> option.
>
> Markus.
>
>> -----Original Message-----
>> From: cdt-dev-bounces@xxxxxxxxxxx
>> [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Sanjesh R Nair
>> Sent: Monday, November 10, 2008 9:24 AM
>> To: CDT General developers list.
>> Subject: Re: [cdt-dev] How to find binding definition
>> Importance: Low
>>
>> Would this API give back the declaration of a binding
>> declared is some other file but referred in this TranslationUnit?
>>
>> Sanjesh.
>>
>>
>>
>>
>>
>>   From:       "Dmitry Smirnov" <divis1969@xxxxxxxxx>
>>
>>
>>
>>
>>
>>   To:         "CDT General developers list."
>> <cdt-dev@xxxxxxxxxxx>
>>
>>
>>
>>
>>   Date:       11/10/2008 12:31 PM
>>
>>
>>
>>
>>
>>   Subject:    Re: [cdt-dev] How to find binding definition
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> Have you tried IASTTranslationUnit.getDeclarationsInAST()?
>> This probably will give you what you need (if I correctly
>> understand its description).
>>
>> 2008/11/7 Sanjesh R Nair <sanjesh.nair@xxxxxxxxxx>:
>> > 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 has.
>> >
>> >
>> > Sanjesh.
>> >
>> >
>> >
>> >  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))
>> >
>> > Markus.
>> >
>> >> -----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
>> >> https://dev.eclipse.org/mailman/listinfo/cdt-dev
>> >>
>> > _______________________________________________
>> > cdt-dev mailing list
>> > cdt-dev@xxxxxxxxxxx
>> > https://dev.eclipse.org/mailman/listinfo/cdt-dev
>> >
>> >
>> >
>> > _______________________________________________
>> > cdt-dev mailing list
>> > cdt-dev@xxxxxxxxxxx
>> > https://dev.eclipse.org/mailman/listinfo/cdt-dev
>> >
>> _______________________________________________
>> cdt-dev mailing list
>> cdt-dev@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/cdt-dev
>>
>>
>>
>> _______________________________________________
>> cdt-dev mailing list
>> cdt-dev@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/cdt-dev
>>
> _______________________________________________
> cdt-dev mailing list
> cdt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/cdt-dev
>
>
>
> _______________________________________________
> cdt-dev mailing list
> cdt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/cdt-dev
>


Back to the top