Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Howto: Register Refactoring Support"

Line 14: Line 14:
  
 
   protected void changed(Map<URI, URI> uris) {
 
   protected void changed(Map<URI, URI> uris) {
    //inform annotation framework about changes
 
 
     for (URI uri : uris.keySet())
 
     for (URI uri : uris.keySet())
        AnnotationPlugin.getManager().getRefactoringSupport().changed(uri, uris.get(uri));
+
      //inform annotation framework about changes
 +
      AnnotationPlugin.getManager().getRefactoringSupport().changed(uri, uris.get(uri));
 
     }
 
     }
 
   public void deleted(ILazyObject object) {
 
   public void deleted(ILazyObject object) {
Line 23: Line 23:
 
       URI uri = ResourceURIConverter.toURI(resource);
 
       URI uri = ResourceURIConverter.toURI(resource);
 
       if (uri != null)
 
       if (uri != null)
 +
        //inform annotation framework about resource deletion
 
         AnnotationPlugin.getManager().getRefactoringSupport().deleted(uri);
 
         AnnotationPlugin.getManager().getRefactoringSupport().deleted(uri);
 
     }
 
     }

Revision as of 08:12, 3 June 2008

< To: Tigerstripe_APIs

Introduction

Some of the annotated objects URI can be changed (for example, annotated resource can be moved to another place and its path used for annotation URI will be changed). To solve this problem Annotation Framework supports annotated object refactoring. From the Annotation Framework side - refactoring is an operation which change one URI to another. To inform framework about refactoring changes we need to use org.eclipse.tigerstripe.annotation.core.IRefactoringSupport with the following methods:

  • deleted(URI uri) - notify framework about object with the passed URI deleted;
  • changed(URI newUri, URI oldUri) - notify framework about object's URI changed to another one;

Examples

Eclipse 3.3

You can found both Java and Resource refactoring support example in the org.eclipse.tigerstripe.annotation.java.ui.refactoring plugin:

 protected void changed(Map<URI, URI> uris) {
   for (URI uri : uris.keySet())
     //inform annotation framework about changes
     AnnotationPlugin.getManager().getRefactoringSupport().changed(uri, uris.get(uri));
   }
 public void deleted(ILazyObject object) {
   IResource resource = getResource(object);
   if (resource != null) {
     URI uri = ResourceURIConverter.toURI(resource);
     if (uri != null)
       //inform annotation framework about resource deletion
       AnnotationPlugin.getManager().getRefactoringSupport().deleted(uri);
   }
 }

As you see, to support refactoring all what you need is convert object to URI and notify annotation framework (Using AnnotationPlugin.getManager().getRefactoringSupport()) about your changes.

Eclipse 3.4

In the Eclipse 3.4 refactoring didn't completely supported yet because of several concept changes in the LTK framework.

Back to the top