Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Getting ITranslationUnit from IASTTranslationUnit

No. You wouldn’t do that. You’d only have the implementations of IASTTranslationUnit do that. There’s a pretty standard pattern for that.

 

e.g. in CASTTranslationUnit;

 

                public Object getAdapter(Class adapter) {

                                if (adapter.equals(ITranslationUnit.class))

                                                return someCachedITranslationUnitObject;

                                return super.getAdapter(adapter);

                }

 

You wouldn’t need to use the extension in this case and this is much faster.

 

D.

 

 

From: sprigogin@xxxxxxxxxx [mailto:sprigogin@xxxxxxxxxx] On Behalf Of Sergey Prigogin
Sent: Monday, March 07, 2011 3:04 PM
To: Schaefer, Doug
Cc: CDT General developers list.; elaskavaia.cdt@xxxxxxxxx
Subject: Re: [cdt-dev] Getting ITranslationUnit from IASTTranslationUnit

 

It's probably not a good idea to define getAdapter method on IASTNode that can adapt to ITranslationUnit since mapping from an IASTNode to ITranslationUnit can be done in many different ways.

 

-sergey

On Mon, Mar 7, 2011 at 11:58 AM, Schaefer, Doug <Doug.Schaefer@xxxxxxxxxxxxx> wrote:

PlatformObject gives you the ability to add an adaptable through an extension without changing the code. Very handy for third party plug-ins. I’ve used it a couple of times.

 

Doug.

 

From: sprigogin@xxxxxxxxxx [mailto:sprigogin@xxxxxxxxxx] On Behalf Of Sergey Prigogin
Sent: Monday, March 07, 2011 2:56 PM


To: CDT General developers list.

Cc: Schaefer, Doug; elaskavaia.cdt@xxxxxxxxx


Subject: Re: [cdt-dev] Getting ITranslationUnit from IASTTranslationUnit

 

Instead of extending PlatformObject it can simply implement IAdaptable.

 

-sergey

On Mon, Mar 7, 2011 at 11:48 AM, Schaefer, Doug <Doug.Schaefer@xxxxxxxxxxxxx> wrote:

Great question. I don't really see a downside. It doesn't take up any per object memory and there's a default implementation of getAdapter, i.e. the one that looks things up in the extension registry. You'd have to put it up as the superclass of ASTNode, which is probably what you want anyway. Can't be that easy can it?


> -----Original Message-----
> From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx]

> On Behalf Of Alena Laskavaia
> Sent: Monday, March 07, 2011 2:44 PM
> To: CDT General developers list.
> Subject: Re: [cdt-dev] Getting ITranslationUnit from IASTTranslationUnit
>
> What stops us from making it PlatformObject now?
>
> On Mon, Mar 7, 2011 at 2:11 PM, Schaefer, Doug
> <Doug.Schaefer@xxxxxxxxxxxxx> wrote:
> > I was waiting for the IBM guys to respond since I thought they had a
> > requirement to be able to run the parser and AST outside the CDT and
> > without the ICElement hierarchy. But since they didn't respond, I must be
> mistaken.
> >
> >
> >
> > getCElement() or getCTranslationUnit()?
> >
> >
> >
> > Too bad we didn't make these PlatformObjects. Then you'd just use
> > getAdapter().
> >
> >
> >
> > D.
> >
> >
> >
> >
> >
> > From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-
> bounces@xxxxxxxxxxx]
> > On Behalf Of Sergey Prigogin
> > Sent: Monday, March 07, 2011 2:05 PM
> > To: CDT General developers list.
> > Subject: Re: [cdt-dev] Getting ITranslationUnit from
> > IASTTranslationUnit
> >
> >
> >
> > Since nobody responded I assume that there is no good reason not to
> > have a method in IASTTranslationUnit returning the corresponding
> ITranslationUnit.
> > I'm going to add such method. Any suggestions for the name?
> >
> >
> >
> > -sergey
> >
> > On Fri, Mar 4, 2011 at 5:12 PM, Sergey Prigogin
> > <eclipse.sprigogin@xxxxxxxxx> wrote:
> >
> > Does anybody know why IASTTranslationUnit doesn't provide a method
> > returning the ITranslationUnit from which the AST was built? Such
> > method would be handy in many places, for example in
> CodanCReconciler.reconciled method.
> >
> >
> >
> > -sergey
> >
> >
> >
> > _______________________________________________
> > 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