Community
Participate
Working Groups
Build Identifier: If you use inferred JvmTypes the model cannot be displayed as an EMF model. The JdtTypeProviderFactory returns a NullJdtTypeProvider instead of a JdtTypeProvider, because the JavaProject cannot be determined. The IJavaProjectProvider is responsible for determining a JavaProject from a ResourceSet. Unfortunately there is only one implementation (XtextResourceSetBasedProjectProvider) which only works for instances of XtextResourceSet. In this case I get an instance of org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain$AdapterFactoryEditingDomainResourceSet. Is there a way to resolve the JavaProject from AdapterFactoryEditingDomainResourceSet? Reproducible: Always
You could bind an implementation of the JdtTypeProviderFactory that checks for Is AdapterFactoryEditingDomainResourceSet, takes it's first resource, checks for platform:/resource uri and determines the project from the first segment.
My solution is to bind a IJavaProjectProvider which extends XtextResourceSetBasedProjectProvider and does exactly what you have described. I wonder, if this was a safe operation as my ResourceSet might contain resources located in several projects. I don't know how the AdapterFactoryEditingDomainResourceSet is initialized. Is the resource which is displayed in my editor tab always the first resource of the ResourceSet?
(In reply to comment #2) > My solution is to bind a IJavaProjectProvider which extends > XtextResourceSetBasedProjectProvider and does exactly what you have described. > I wonder, if this was a safe operation as my ResourceSet might contain > resources located in several projects. Same problem for the IJavaProject that is associated with the XtextResourceSet. See bug 326581 > I don't know how the AdapterFactoryEditingDomainResourceSet is initialized. Is > the resource which is displayed in my editor tab always the first resource of > the ResourceSet? Don't know whether that would be mission critical anyway ... Feel free to debug the constructor invocation ;-)
Ok, the code Ed Willink posted is exactly what I did, too ;-) Bug 326581 is classified as an enhancement, but I would call it "bug" as you lose the ability to view the inferred EMF model. Don't you think so? *** This bug has been marked as a duplicate of bug 326581 ***