[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [cdt-dev] pulling in extern definitions with CDT parser
|
You can find out how to generate an index without UI in the CDT docs.
Help > Help Contents > CDT Plug-in Developer Guide > Programmer's Guide > CDT DOM > Pre-built Indexes
Mike Kucera
Software Developer
IBM Eclipse CDT Team
mkucera@xxxxxxxxxx
Peter Kim ---07/07/2009 05:18:51 AM---Wow, that is great. Could you point me to an example of how to do
From: |
Peter Kim <chpkim@xxxxxxxxx> |
To: |
"CDT General developers list." <cdt-dev@xxxxxxxxxxx> |
Date: |
07/07/2009 05:18 AM |
Subject: |
Re: [cdt-dev] pulling in extern definitions with CDT parser |
Wow, that is great. Could you point me to an example of how to do
this? For example, I ran into a situation where CDT code would throw
an exception unless an Eclipse plugin (it was checking this against
ResourcesPlugin class) was started. I would really appreciate it if
you could demonstrate or point me to an example of how a CDT project
can be created without having to start an Eclipse plugin, entirely
from command-line (without UI).
Also, even with Eclipse plugin running, I found that
ITranslationUnit.getIndex() was returning null and although
CCorePlugin.getIndexManager().getIndex(ICProject) was returning an
IIndex, it was basically empty. What is the correct way to retrieve
IIndex?
Thank you very much.
On Tue, Jul 7, 2009 at 2:03 AM, Schorn,
Markus<Markus.Schorn@xxxxxxxxxxxxx> wrote:
> Peter,
> The indexer works out of the box on top of a CDT-project. All you need to achieve is to programmatically create a CDT project for the code you are
> interested in and it will get indexed.
>
> You can run eclipse without UI and you do not need a UI to have projects and translation units.
>
> Markus.
>
>
>
>> -----Original Message-----
>> From: cdt-dev-bounces@xxxxxxxxxxx
>> [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Peter Kim
>> Sent: Monday, July 06, 2009 7:28 PM
>> To: CDT General developers list.
>> Subject: Re: [cdt-dev] pulling in extern definitions with CDT parser
>> Importance: Low
>>
>> Hi Markus,
>>
>> Thank you for your help. Do you think it will be possible
>> for me to extract code from IIndex-related code so that the
>> linking can work without running Eclipse (i.e. without
>> classes like IProject and ITranslationUnit for which the
>> editor needs to be started). I'm trying to create a
>> standalone tool that can run from command-line without
>> running Eclipse. Please let me know if this is worth the
>> effort or I should do the linking myself.
>>
>> Thank you.
>>
>>
>> On Fri, Jul 3, 2009 at 1:23 AM, Schorn,
>> Markus<Markus.Schorn@xxxxxxxxxxxxx> wrote:
>> > Peter,
>> > while the parser corresponds to a compiler, the index
>> corresponds to a
>> > linker.
>> > So definitions can be found via
>> > IIndex.findDefinitions(IBinding binding)
>> >
>> > Markus.
>> >
>> >
>> >
>> >> -----Original Message-----
>> >> From: cdt-dev-bounces@xxxxxxxxxxx
>> >> [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Peter Kim
>> >> Sent: Thursday, July 02, 2009 6:59 PM
>> >> To: cdt-dev@xxxxxxxxxxx
>> >> Subject: [cdt-dev] pulling in extern definitions with CDT parser
>> >> Importance: Low
>> >>
>> >> I am currently working on developing a simple source-to-source
>> >> transformation tool using CDT. I've managed to pull the parser
>> >> component out of CDT as a standalone tool (so that we
>> don't have to
>> >> rely on Eclipse). Namely, whereas before the AST had to
>> be retrieved
>> >> in the following way:
>> >>
>> >> ITranslationUnit tu = (ITranslationUnit)selected;
>> IASTTranslationUnit
>> >> ast = tu.getAST();
>> >>
>> >> Now, the AST is retrieved through a standalone parser, whose
>> >> getAST() is a slightly modified, almost identical version, of
>> >> ITranslationUnit.getAST():
>> >>
>> >> StandaloneCParser parser = new StandaloneCParser("c:\\foo.c", tu);
>> >> IASTTranslationUnit astTu = parser.getAST();
>> >>
>> >> The parser is able to resolve bindings to definitions in
>> header files
>> >> (e.g. foo.h), but isn't able to do so for "extern" declarations,
>> >> whose actual definitions are located in other .c files
>> (e.g. bar.c).
>> >> For example, if foo.c calls a method called "barMethod()" that is
>> >> declared as "extern void barMethod();" in foo.h and
>> actually defined
>> >> in bar.c, calling IASTName.resolveBinding() on "barMethod()" name
>> >> returns a CFunction whose CFunction.getDefinition() returns null.
>> >>
>> >> Does CDT provide a mechanism for linking, so that these external
>> >> definitions can be pulled in automatically? If not, what do you
>> >> recommend for connecting these various files together? I
>> know CDT is
>> >> more of an IDE tool than a traditional parser/compiler, but I've
>> >> found it very useful and I'd like to keep using it if possible.
>> >>
>> >>
>> >> --
>> >> Peter Kim
>> >> Ph.D. Student
>> >> Automated Software Design Group
>> >> Department of Computer Sciences
>> >> The University of Texas at Austin, USA
>> >>
>> >> http://www.cs.utexas.edu/~chpkim
>> >> Phone: +1-512-461-9381
>> >> Office: ACES 5.246
>> >> _______________________________________________
>> >> 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
>> >
>>
>>
>>
>> --
>> Peter Kim
>> Ph.D. Student
>> Automated Software Design Group
>> Department of Computer Sciences
>> The University of Texas at Austin, USA
>>
>> http://www.cs.utexas.edu/~chpkim
>> Phone: +1-512-461-9381
>> Office: ACES 5.246
>> _______________________________________________
>> 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
>
--
Peter Kim
Ph.D. Student
Automated Software Design Group
Department of Computer Sciences
The University of Texas at Austin, USA
http://www.cs.utexas.edu/~chpkim
Phone: +1-512-461-9381
Office: ACES 5.246
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev