Skip to content

Adding a new Java refactoring descriptor

Mohsen Vakilian edited this page Jan 7, 2014 · 5 revisions

Sometimes, the exact type of the refactoring is not known at the time of instrumentation (see issue #163, commits 9233b02edf15564a9ad2627f4dce8b115ec81e11 and a78e01f0331a9444df77e2b75653ce8dd7fb8fd3). In such cases, you need to create a new kind of refactoring descriptor. Let the name of your new refactoring be "NewRe". To be able to deserialize the NewRe refactoring descriptor from the XML files, you need to configure your refactoring descriptor as follows.

  1. Add a constant string that is the ID of the new refactoring descriptor to the class IJavaRefactorings.
  2. Create a new class called NewReDescriptor that extends JavaRefactoringDescriptor.
  3. Add the following two factory methods to RefactoringSignatureDescriptorFactory.
        public static NewReDescriptor createNewReDescriptor() {
            return new NewReDescriptor();
        }
        public static NewReDescriptor createNewReDescriptor(String project, String description, String comment, Map arguments, int flags) {
            return new NewReDescriptor(project, description, comment, arguments, flags);
        }
  1. Add a new class called NewReRefactoringContribution that extends JavaUIRefactoringContribution.
  2. Add the following node to the extension point org.eclipse.ltk.core.refactoring.refactoringContributions in org.eclipse.jdt.ui/plugin.xml.
        <contribution class="<the fully qualified name of NewReRefactoringContribution>" id="<the string representing the ID of the NewRe refactoring>"/>
Clone this wiki locally