Search code examples
javaeclipseeclipse-jdt

JDT: Replace one type for another in eclipse plugin


I'm developing an eclipse plug-in that performs some code transformations. One of the tasks I have to perform is to locate all uses of the type ArraList<?> and replace them by the type Vector.

To locate classes using ArrayList, I'm reading each class imports and search for java.util.ArrayList. I know how to change the imports, but I can't find information on how to change all ArrayList references.


Solution

  • You need to walk the AST, find all variable and field declarations and change the type.

    This question contains pointers how to start with writing refactoring plugins: Writing a new refactoring plugin for Eclipse?