Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [cdt-dev] CElements adapting to IResource

Hi Chris,
you are right, I am a lazy writer and my wording does not always
reveal the full story. I try to improve.

If you do it right, you get the adapter for IResource and IFile at
the same time (IResource is assignable from IFile).

Object getAdapter(Class clazz) {
   if (clazz.isAssignableFrom(IFile.class)) {
      return theIFileObject;
   }
   return null;
} 

Markus.

> -----Original Message-----
> From: cdt-dev-bounces@xxxxxxxxxxx 
> [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Chris Recoskie
> Sent: Mittwoch, 23. August 2006 14:44
> To: CDT General developers list.
> Subject: RE: [cdt-dev] CElements adapting to IResource
> 
> Ok... sorry for the misunderstanding.  I thought you meant 
> you were going
> to remove the adaptation for all ICElements.  What you say 
> makes perfect
> sense then... my vote is to go for it.
> 
> BTW just for reference (you might already know this but can't 
> tell 100%
> your intent from your wording), but I seem to recall that the adapter
> mechanism isn't too smart and won't know that if you are 
> adaptable to IFile
> that IFile is in fact an IResource, and hence the same 
> adapter should work
> for IResource.  You have to be separately adaptable to 
> IResource as well,
> even if they end up doing the exact same thing ultimately.
> 
> ===========================
> 
> Chris Recoskie
> Team Lead, IBM CDT Team
> IBM Toronto
> http://www.eclipse.org/cdt
> 
> 
> 
>                                                               
>              
>              "Schorn, Markus"                                 
>              
>              <Markus.Schorn@wi                                
>              
>              ndriver.com>                                     
>           To 
>              Sent by:                  "CDT General 
> developers list."      
>              cdt-dev-bounces@e         <cdt-dev@xxxxxxxxxxx>  
>              
>              clipse.org                                       
>           cc 
>                                                               
>              
>                                                               
>      Subject 
>              23/08/2006 08:35          RE: [cdt-dev] 
> CElements adapting to 
>              AM                        IResource              
>              
>                                                               
>              
>                                                               
>              
>              Please respond to                                
>              
>                "CDT General                                   
>              
>              developers list."                                
>              
>              <cdt-dev@eclipse.                                
>              
>                    org>                                       
>              
>                                                               
>              
>                                                               
>              
> 
> 
> 
> 
> Hi Chris,
> that's actually what I meant to do. ITranslationUnits shall remain to
> be adaptable to IFile, but not ICElements like IFunction, IVariable,
> etc.
> Markus.
> 
> 
> > -----Original Message-----
> > From: cdt-dev-bounces@xxxxxxxxxxx
> > [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Chris Recoskie
> > Sent: Mittwoch, 23. August 2006 14:27
> > To: CDT General developers list.
> > Subject: Re: [cdt-dev] CElements adapting to IResource
> >
> > The thing to be careful about is object contributions.  The
> > extension point
> > for them has an "isAdaptable" flag or something like that (I
> > forget the
> > exact details), that allows your action to show up for any
> > object adaptable
> > to IResource.  If you change this, then such actions won't 
> show up for
> > translation units etc.  It is pretty common for a lot of
> > tools to provide
> > their actions this way.  E.g., a Team provider would 
> generally need to
> > operate on any kind of file in the workspace, so I would
> > expect them to use
> > this method to provide source control actions.
> >
> > I wonder if it wouldn't make more sense to have the the
> > adaptation only
> > work for the implementors of ICElement that make sense to adapt to
> > IResource.  There is nothing saying that every ICElement has
> > to allow the
> > adaptation.
> >
> > ===========================
> >
> > Chris Recoskie
> > Team Lead, IBM CDT Team
> > IBM Toronto
> > http://www.eclipse.org/cdt
> >
> >
> >
> >
> >
> >              "Schorn, Markus"
> >
> >              <Markus.Schorn@wi
> >
> >              ndriver.com>
> >           To
> >              Sent by:                  "CDT General
> > developers list."
> >              cdt-dev-bounces@e         <cdt-dev@xxxxxxxxxxx>
> >
> >              clipse.org
> >           cc
> >
> >
> >
> >      Subject
> >              23/08/2006 05:37          [cdt-dev] CElements
> > adapting to
> >              AM                        IResource
> >
> >
> >
> >
> >
> >              Please respond to
> >
> >                "CDT General
> >
> >              developers list."
> >
> >              <cdt-dev@eclipse.
> >
> >                    org>
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > Hi,
> > currently most of the CElements can be adapted to IResources.
> > This makes
> > perfectly sense for translation units, folders or projects.
> > However, it
> > is problematic for others as the context menu of classes, functions,
> > vars,
> > etc. gets populated with actions that apply for files, only.
> > For example select a function in the CView and choose 'Delete' from
> > the context menu. This deletes the entire file.
> >
> > I plan to change that. Doing so it is possible that I break 
> code that
> > obtains the enclosing resource from an ICElement by means of the
> > adaptable
> > mechanism rather than using a direct call to 
> ICElement.getResource().
> > I believe we have enough time until 4.0 to find all related
> > problems and
> >
> > fix them.
> >
> > Is that ok for you?
> > Markus.
> >
> > _______________________________________________
> > 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