Using MoveClassesOrPackagesRefactoring to refactor a java file

I am trying to write a code which  can refactor an input project. I know the file I want to refactor and I  want to create a new package in which I want to move this file.  (Although unconventional but the file could contain multiple classes and  I would want the refactoring to work with such a file too).

I  saw that IntelliJ does this brilliantly through the IDE. I also see  that there is an openapi available to use the code of Intellij.

I saw that I could use the class MoveClassesOrPackagesRefactoring to achieve this.

What  I can't figure out however, is that how do I give the input project  folder to the API and also the output folder where I want the refactored  code to be put. If output folder cannot be given, I am ok with  refactoring the same input project.

I would really appreciate  if you could give me a sample code which I  could use to achieve my  purpose, or help me understand how to achieve  moving a java file to  another package.
1 comment
Comment actions Permalink

There is a forum for Open API, you could try asking this question there:


Please sign in to leave a comment.