Using refactoring support from commandline [message #1694135] |
Thu, 30 April 2015 15:39  |
Eclipse User |
|
|
|
Hi anyone,
we have written a source migration tool with jdt which allows to migrate some code with rules you have to configure before in xml format.
Now we want to use this from commandline (e.g. gradleplugin).
Can you give me a hind, how I can create an IJavaProject from outside eclipse? Please don't answer to use a headless eclipse application because I don't want to have this overhead. It should be created with a plain java application.
Thanks in advance
Markus
|
|
|
Re: Using refactoring support from commandline [message #1694146 is a reply to message #1694135] |
Thu, 30 April 2015 18:04   |
Eclipse User |
|
|
|
If you say "Refactoring" in the JDT sense: refactoring heavily relies on search, search needs an index and the index is managed by the "IndexManager", which in turn is owned by the JavaModelManager.
See this snippet in JavaModelManager:
if (Platform.isRunning()) {
this.indexManager = new IndexManager();
...
Ergo, if the platform is not running there's not index manager etc. and hence no Refactoring.
Also an IJavaProject needs an IProject which needs an IWorkspace.
I'm not saying it's impossible to mock all this some how, but that'd be a huge project, and I wouldn't bet that at the end of the day you'd save any overhead.
Doing without all this infrastructure is possible when manipulating individual files, but if you need the full power, then you need the appropriate engine.
Now, that I've told you how difficult things are, have a look at org.eclipse.jdt.core.index.JavaIndexerApplication, e.g., and see how simple it is to write your own headless application 
Stephan
|
|
|
|
Re: Using refactoring support from commandline [message #1701596 is a reply to message #1694147] |
Tue, 14 July 2015 06:47  |
Eclipse User |
|
|
|
Hi again,
for the ones with the same or a similar problem: I have solved it by creating a product with a headless eclipse application and a gradle plugin, which handles downloading and launching this product. Our users don't have any additional effort with this solution.
Regards
Markus
|
|
|
Powered by
FUDForum. Page generated in 0.03247 seconds