1

I have hundreds of projects in my workspace, some of which are dependent on others. I have a generated Java file (Example.java) with static fields that are being referenced throughout the codebase. I have also generated files within specific modules that have these static fields. I want to migrate the references to the fields to the modularized version of the fields that belong in the specific packages.

For instance, Example.java contains:

public static final ObjectType OT1 = ObjectTypeFactory.makeObject("OT1");
public static final ObjectType OT2 = ObjectTypeFactory.makeObject("OT2");
public static final ObjectType OT3 = ObjectTypeFactory.makeObject("OT3");

Then Modularized Java files within the packages look something like:
Mod1.java
public static final ObjectType OT1 = ObjectTypeFactory.makeObject("OT1");

Mod2.java
public static final ObjectType OT2 = ObjectTypeFactory.makeObject("OT2");

Mod3.java
public static final ObjectType OT3 = ObjectTypeFactory.makeObject("OT3");

I want to move the references to Example.OT1 to Mod1.OT1 throughout my codebase, as well as change the rest of them. I have thousands of such changes to make.

1
  • You may also use Maven to handle inter-project dependencies in order not to rely too much on Eclipse Commented Jun 20, 2016 at 10:26

1 Answer 1

1

JDT supports refactoring scripts. However I have never used them so I do not know what is possible.

Otherwise you may try using Eclipse EASE coupled with the JDT APIs for refactoring and in particular the move static field refactoring.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, I had already been through these before. Are there any tutorials for this or a step by step as to how to use the refactoring api? Any help would be much appreciated!!
Sure, I have grouped a few links here: github.com/JnRouvignac/AutoRefactor/wiki/Useful-links

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.