JDT Integration

This page is a brainstorm of problems/possible solution for the JDT Integration

Groovy - Java

Problems

  • How to call the Java refactoring
  • How to find the element in Java that is affected by a refactoring in groovy
  • Cannot call any refactoring dialog of JDT because the actions needed are internal. e.g. RenameJavaElementAction. And if the selection does not cover a JavaElement that can be refactored the dialog does not appear

Possible Solution

RenameJavaElementDescriptor descriptor = (RenameJavaElementDescriptor) RefactoringCore.getRefactoringContribution(IJavaRefactorings.RENAME_METHOD).createDescriptor();
descriptor.setJavaElement(IMethod);
//-->Does not work, because we can't provide an IMethod. Implementations of IMethod are "internal" and therfore not accessible. Satisfy the interface is also not possible
  • ReplaceInvocationsRefactoring is only for rename of methods and furthermore it is also "internal" -> can't be used either
ASTParser parser= ASTParser.newParser(AST.JLS3);
parser.createAST();
//-->would provide us an AST of Java Code. Use finder of the special Refactoring to find the !JavaElement. Might also not work cause the finder are "internal"

Java - Groovy

Problems

  • the rename refactoring is not enabled in JDT when trying to rename a groovy-method in a java-file.
  • in the method initialise(Object element) of the RenameParticipant we get the Java element that is going to be renamed. We need to check there, if this element is used from groovy code . "Problem": solution to find the assignment

Possible Solution

  • have a look at RenameParticipants?
    <extension point="org.eclipse.ltk.core.refactoring.renameParticipants">
       <renameParticipant
             class="org.codehaus.groovy.eclipse.refactoring.core.GroovyRenameParticipant
             id="org.codehaus.groovy.eclipse.refactoring.ui.GroovyRenameParticipant"
             name="GroovyRename">
          <enablement>
             <with
                   variable="element">
                <instanceof
                      value="org.eclipse.jdt.core.IMethod">
                </instanceof>
             </with>
          </enablement>       
       </renameParticipant>
    </extension>
    
  • in the class GroovyRenameParticipant the method initialize(Object element) is called from the framework. In the xml-Description above, this element must be of type IMethod. So the GroovyRenameParticipant participates when a Java "RenameMethod" is made.