Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 369773 - Ecore Model Editor doesn't work with inferred JvmTypes
Summary: Ecore Model Editor doesn't work with inferred JvmTypes
Status: CLOSED DUPLICATE of bug 326581
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.2.1   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-26 03:47 EST by Oliver L CLA
Modified: 2012-01-26 04:30 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Oliver L CLA 2012-01-26 03:47:48 EST
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
Comment 1 Sebastian Zarnekow CLA 2012-01-26 03:51:54 EST
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.
Comment 2 Oliver L CLA 2012-01-26 04:17:08 EST
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?
Comment 3 Sebastian Zarnekow CLA 2012-01-26 04:21:00 EST
(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 ;-)
Comment 4 Oliver L CLA 2012-01-26 04:30:48 EST
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 ***