Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » get org.eclipse.jdt.core.ICompilationUnit without IJavaProject
get org.eclipse.jdt.core.ICompilationUnit without IJavaProject [message #1735266] Thu, 16 June 2016 16:52 Go to next message
Markus Oley is currently offline Markus OleyFriend
Messages: 304
Registered: July 2009
Location: Germany
Senior Member
Hi to all,

I want to write a refactoring tool for the commandline. I now have some prototypes with JDT and other Java model abstraction running.

I would prefer JDT as implementation, but only have it running in context of an eclipse headless application. Now I want to go a step further to run it without this whole eclipse workspace and equinox stuff around to get it a bit lightweight.

So can I get a IJavaProject without setting up complete eclipse?
or can I get a org.eclipse.jdt.core.ICompilationUnit without having a IJavaProject?

Would be nice to get infos from you.

Cheers
Markus
Re: get org.eclipse.jdt.core.ICompilationUnit without IJavaProject [message #1735327 is a reply to message #1735266] Fri, 17 June 2016 11:52 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
I don't see how this would be possible ...
Quote:
can I get a IJavaProject without setting up complete eclipse?

to get an IJavaProject you need an IProject -> org.eclipse.core.resources must be available.

Quote:
can I get a org.eclipse.jdt.core.ICompilationUnit without having a IJavaProject?

The closest you can probably get is org.eclipse.jdt.core.JavaCore.createCompilationUnitFrom(IFile), this seems to work without an IJavaProject, but still you need an IFile (from o.e.core.resources). Since you need jdt anyway, bypassing IJavaProject while still needing the resource doesn't seem to buy you anything. Internally, we may not really need the IFile, perhaps an IPath (o.e.core.runtime) is sufficient, but I don't see anything like this surfacing in API.

Nor is using the full o.e.jdt.core without Equinox supported.

OTOH, compared to jdt.core (almost 6MB) I wouldn't consider things like o.e.core.resources (< 900kB) as such a huge penalty...

[Updated on: Fri, 17 June 2016 11:53]

Report message to a moderator

Re: get org.eclipse.jdt.core.ICompilationUnit without IJavaProject [message #1735333 is a reply to message #1735327] Fri, 17 June 2016 12:23 Go to previous messageGo to next message
Markus Oley is currently offline Markus OleyFriend
Messages: 304
Registered: July 2009
Location: Germany
Senior Member
Hi Stephan,

thanks for your answer...
I see, it seems to be not as easy as I hoped...

Is there perhaps a way to initialize the platform in a commandline app without having the need to start an external headless application?

Thanks for you answers
Re: get org.eclipse.jdt.core.ICompilationUnit without IJavaProject [message #1735338 is a reply to message #1735333] Fri, 17 June 2016 12:44 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
I don't see the difference between "commandline app" and "external headless application" you are making?
What is it you are trying to avoid?
Re: get org.eclipse.jdt.core.ICompilationUnit without IJavaProject [message #1735355 is a reply to message #1735338] Fri, 17 June 2016 15:15 Go to previous messageGo to next message
Markus Oley is currently offline Markus OleyFriend
Messages: 304
Registered: July 2009
Location: Germany
Senior Member
I try to avoid building the app for every platform, handle downloading the right one and the whole stuff with starting the app in another java process from inside my app.

I'd like to call it inside my application (e.g. gradle plugin)
Re: get org.eclipse.jdt.core.ICompilationUnit without IJavaProject [message #1735365 is a reply to message #1735355] Fri, 17 June 2016 16:16 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
I don't think you need any platform specific stuff, just call

java -jar org.eclipse.equinox.launcher_1.3.200.v20160318-1642.jar -application your.tool.application


I'm not sure about in-process invocation though. Sounds like a question for the Equinox experts.
Re: get org.eclipse.jdt.core.ICompilationUnit without IJavaProject [message #1735426 is a reply to message #1735365] Sun, 19 June 2016 09:48 Go to previous messageGo to next message
Markus Oley is currently offline Markus OleyFriend
Messages: 304
Registered: July 2009
Location: Germany
Senior Member
OK, thank you Stephan....

One additional point would be to have fast unit tests... Because when I have to call an external program for any unit test, I guess this would be no good.

Thanks
Markus

Re: get org.eclipse.jdt.core.ICompilationUnit without IJavaProject [message #1735430 is a reply to message #1735426] Sun, 19 June 2016 12:01 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
{quote}to have fast unit tests{quote}

Can't you invoke you unit tests as "JUnit Plug-in Test"?
Re: get org.eclipse.jdt.core.ICompilationUnit without IJavaProject [message #1736252 is a reply to message #1735430] Mon, 27 June 2016 20:50 Go to previous messageGo to next message
Markus Oley is currently offline Markus OleyFriend
Messages: 304
Registered: July 2009
Location: Germany
Senior Member
Hi Stephan,

Sorry for waiting so long until answering....

I want a simple junit test, because we are building with gradle and I guess there is no support for running eclipse plugin tests so far. And another cause is - a simple junit test is more lightweight.

Smile

I am working a lot with xtext and there you can replace nearly anything by another implementation of a given interface... Did you think about opening jdt a bit more to have the possibility to use it in another scenario?

Thanks for your answer,
Cheers
Markus
Re: get org.eclipse.jdt.core.ICompilationUnit without IJavaProject [message #1736297 is a reply to message #1736252] Tue, 28 June 2016 10:12 Go to previous message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
There's one part of jdt.core that's independent from the platform: the compiler (ecj).
Everything else has not been designed with such independence in mind and retrofitting it for that requirement would be a huge effort, not to mention the necessary quality assurance to ensure that the large number of plug-ins implemented on top of JDT would not be broken by such architectural change.
So, no, I don't see a realistic option to use JDT's Java model without the platform.

If indeed gradle doesn't yet have an equivalent of tycho (does it?), then that would be the area worth investing into.
Previous Topic:java and eclipse
Next Topic:Grammar file
Goto Forum:
  


Current Time: Tue Oct 15 16:04:48 GMT 2024

Powered by FUDForum. Page generated in 0.06493 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top