Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jdt-core-dev] How can I restore a working copy from a handle?

A working copy has no specific handle identifier currently. Therefore, it
will pretend it corresponds to a compilation unit, i.e. you will obtain a
corresponding compilation unit element (if it exists).

Why would you want mementos to working copies ? Indeed, I don't think this
is a problem.

In case the working copy element doesn't match an underlying element, then
if the workspace is exited and restarted. The memento will be rebound to
the unit corresponding element. If it doesn't exist, then this means that
the working copy did not get committed, and therefore we cannot do
anything.




                                                                                                                                          
                      Daniel_Megert@oti.c                                                                                                 
                      om                          To:      jdt-core-dev@xxxxxxxxxxx                                                       
                      Sent by:                    cc:                                                                                     
                      jdt-core-dev-admin@         Subject: [jdt-core-dev] How can I restore a working copy from a handle?                 
                      eclipse.org                                                                                                         
                                                                                                                                          
                                                                                                                                          
                      03/19/2002 11:12 AM                                                                                                 
                      Please respond to                                                                                                   
                      jdt-core-dev                                                                                                        
                                                                                                                                          
                                                                                                                                          




I have the following problem: I store the Java element handle identifier
(IJavaElement.getHandleIdentifier()) of a working copy into a marker.
Later when I need the label and icon of the Java element to display the
marker I create the Java element from the handle identifier
(JavaCore.create(String)).

Problems:
1) It seems that the handle is not recreated as before: the fact that it
was a working copy is lost (even though a corresponding working copy
exists)
        Is this correct? What's the suggested way to do this?
2) I can store the fact that it is a working copy but I can not find an API
to create a Java element as working copy. Am I right?
3) I then queried IWorkingCopyManager for the corresponding working copy
(this works) but there is no API to find the working copy element for a
given Java element which might not exist: searching inside the working copy
does not work in all cases because I need to ask the non-working copy
element for some state (e.g. isConstructor()) and this might fail because
the element might not (yet) exist in the original.
        Is there another way to find a corresponding Java element in an
existing working copy?

Example: J Core Search reports a match in a working copy (e.g. method X.y -
which does not yet exist in the original). This is stored in the marker as
handle identifier. How can I restore/find this method later?

Dani





Back to the top