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?


The concrete problem is Java search reporting matches in working copies (J SearchEngine supports this). See example below. How can I create a marker for that working copy and then (later) extract the information from the Java element to display the Java element in the Search view? Of course I could store all relevant (e.g. isConstructor()) information inside the marker but I don't think this is the right way.

Note: it works if the working copy exists in the CU but it does not work for new Java elements added in the editor (i.e. add new method x() and now search for declarations of x()).

Dani



Philippe_Mulet@xxxxxxx
Sent by: jdt-core-dev-admin@xxxxxxxxxxx

03/20/02 02:01 PM
Please respond to jdt-core-dev

       
        To:        jdt-core-dev@xxxxxxxxxxx
        cc:        
        Subject:        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



_______________________________________________
jdt-core-dev mailing list
jdt-core-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/jdt-core-dev



Back to the top