Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 326493 - Cache IEditorInput as a Resource eAdapter
Summary: Cache IEditorInput as a Resource eAdapter
Status: RESOLVED WORKSFORME
Alias: None
Product: EMF
Classification: Modeling
Component: Core (show other bugs)
Version: 2.6.0   Edit
Hardware: PC Windows Vista
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Ed Merks CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-29 04:26 EDT by Ed Willink CLA
Modified: 2010-09-29 14:18 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Willink CLA 2010-09-29 04:26:25 EDT
Background:

Xtext supports a text view of Ecore models and successfully registers this view so that text can be used as Ecore, and opened in the Sample Ecore Editor.

Xtext also supports resolution of text tokens to Java types.

Problem:

An Xtext text document with Java type references fails to resolve the Java types when opened in the Sample Ecore Editor.

Diagnosis:

The Java type resolution requires a suitable IJavaProject to provide the classpath for Java resolution. This classpath is not easily obtainable from the worker thread of a ValidateAction which may be the first occasion on which an attempt to resolve the Java reference is made.

Workaround:

The resolution code can use a Display.syncExec runnable to discover the IEditorInput of the active editor and use the Java class path of the corresponding IProject.

Hazards:

Issuing a syncExec from a worker thread to the main thread provides an opportunity for deadlock.

Using global workspace state to rediscover local context is not in accord with e4 policies.

Suggestion:

Let the EcoreEditor createModel code cache the IEditorInput in a Resource Adapter and/or the IProject in the EditingDomain, so that application code can access it.
Comment 1 Ed Merks CLA 2010-09-29 09:57:34 EDT
I have no idea what this is really asking for. There's no test case, nothing to reproduce a problem, nor anything that would let me verify that something we provide is the best solution to a problem.  I don't even understand how the IEditorInput is important.  

As I understand it, you'd know the URI of each resource, if it's platform:/resource you'd know what project it was in, and you'd be able to figure out the classpath for the project.  Why isn't that sufficient for classpath resolution?
Comment 2 Ed Willink CLA 2010-09-29 14:18:14 EDT
Spot on. Thanks.

The URI provides the correct bundle ..., rather than IEditorInput which was just a pretty good guess.

Just need Xtext to provide the specific Resource rather than the whole ResourceSet.