Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 301606

Summary: Make dependency to JDT optional
Product: [Modeling] TMF Reporter: Sebastian Zarnekow <sebastian.zarnekow>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Holger.Schill, sven.efftinge
Version: 0.7.0Keywords: helpwanted
Target Milestone: M7Flags: sebastian.zarnekow: helios+
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
Patch to make dependency to JDT optional
none
Patch to make dependency to JDT optional none

Description Sebastian Zarnekow CLA 2010-02-02 17:20:48 EST
It is currently not possible to create a product without the JDT due to some required dependencies (they are marked as optional in the Manifest but are actually required at runtime).

E.g. the IStorage2UriMapper is annotated with @ImplementedBy and the implementation class implements the jdt.core.IElementChangeListener interface. This seems to cause a NoClassDefFoundError even if the IStorage2UriMapper is bound to another class in the ui module of my language.
Comment 1 Sven Efftinge CLA 2010-02-24 07:44:56 EST
I've resolved the mentioned issue with IStorage2UriMapper.
Comment 2 Sven Efftinge CLA 2010-02-24 07:45:39 EST
Someone should actually test what other problems occur when running Xtext without JDT.
Comment 3 Sebastian Zarnekow CLA 2010-03-18 05:33:07 EDT
The SharedStateModule will always return an implementation of the JavaProjectsState. 

public Provider<? extends IAllContainersState> provideIAllContainersState() {
	return Access.provider(JavaProjectsState.class);
}

It should return an implementation that is bound in the SharedModule or SharedModuleWithJDT respectively.
Comment 4 Holger Schill CLA 2010-04-27 09:00:01 EDT
Due to https://bugs.eclipse.org/bugs/show_bug.cgi?id=309631 the last mentioned point is no problem any more.
Comment 5 Holger Schill CLA 2010-04-27 09:11:02 EDT
org.eclipse.emf.mwe2.language.ui has a non optional dependency to org.eclipse.jdt.ui.
Comment 6 Holger Schill CLA 2010-04-29 08:42:05 EDT
There is only on implementation for org.eclipse.xtext.ui.editor.model.JavaClassPathResourceForIEditorInputFactory -> org.eclipse.xtext.ui.editor.model.JavaClassPathResourceForIEditorInputFactory.

The implementation has a dependency to JDT.

We have to provide another implementation that is JDT independent.
Comment 7 Holger Schill CLA 2010-04-29 08:43:00 EDT
Sorry i ment there is only one implemention for org.eclipse.xtext.ui.editor.model.IResourceForEditorInputFactory on course.
Comment 8 Holger Schill CLA 2010-04-29 09:01:01 EDT
The org.eclipse.xtext.ui.resource.XtextResourceSetProvider as only implementation of org.eclipse.xtext.ui.resource.IResourceSetProvider has a dependency to JDT.
Comment 9 Holger Schill CLA 2010-04-30 08:23:03 EDT
Created attachment 166603 [details]
Patch to make dependency to JDT optional

I made the dependency to JDT optional by implementing some JDT independent variants of the above mentioned classes. By the way I made the generated ProjectCreator JDT independent and I refactored the class EclipseResourceUtil in that way that we do not have static methods any more. I introduced some new classes to get rid of the tons of parameters in the invokement of projectcreation.
Comment 10 Holger Schill CLA 2010-04-30 08:56:30 EDT
Created attachment 166607 [details]
Patch to make dependency to JDT optional

One thing on using google Guice wasn't clear to me. If you define a Provider for a class but don't use it, the class is instancetiated anyway. This caused an unment dependency to JDT. So here the patched patch. ;-)
Comment 11 Sebastian Zarnekow CLA 2010-04-30 11:38:36 EDT
I'll review the patch.
Comment 12 Sebastian Zarnekow CLA 2010-05-03 03:34:49 EDT
Comment on attachment 166607 [details]
Patch to make dependency to JDT optional

I restructured the code to remove some static dependencies and unnecessary complexity.
Comment 13 Sebastian Zarnekow CLA 2010-05-03 05:31:04 EDT
Fixed in HEAD. Thanks for the initial patch, Holger.

Major changes I made befor applying the patch:
- Refactor the ProjectDescriptionCreator to a ProjectFactory hierarchy with JavaProjectFactory and PluginProjectFactory
- Extracted some common parts from JavaClassPathResourceForIEditorInputFactory and ResourceForIEditorInputFactory
Comment 14 Karsten Thoms CLA 2017-09-19 16:01:07 EDT
Closing bug which were set to RESOLVED before Eclipse Neon.0.