Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 354834 - Relinking to inferred jvm types sometimes does not work
Summary: Relinking to inferred jvm types sometimes does not work
Status: RESOLVED WORKSFORME
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.0.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 354910
Blocks:
  Show dependency tree
 
Reported: 2011-08-16 10:12 EDT by Vladimir Piskarev CLA
Modified: 2016-08-19 02:54 EDT (History)
1 user (show)

See Also:


Attachments
'example' project (1.83 KB, application/zip)
2011-08-16 10:14 EDT, Vladimir Piskarev CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Piskarev CLA 2011-08-16 10:12:58 EDT
Build Identifier: I20110613-1736

As a rule, inferred jvm types should shadow 'physical' (e.g. generated) Java types. That is, if the inferred jvm type exists, the reference will be linked to it; if not, the reference will be linked to the corresponding 'physical' Java type (if it exists).

This behavior is not always obeyed in Xtext editors in presence of cross-resource references, as we shall see below.

Reproducible: Always

Steps to Reproduce:
1. Import the standard 'Xtext Domain-Model Example' projects into the workspace.

2. Run the runtime workbench and import the attached 'example' project into the
runtime workspace.

3. Open 'Foo.dmodel' and 'Bar.dmodel' in Xtext editors.

4. In 'Bar.dmodel' point to 'Foo' in the 'extends foo.Foo' clause. 
A hover 'Entity Foo' appears (as expected). 

5. Switch to 'Foo.dmodel' and comment out 'entity Foo {}'. Switch back to 'Bar.dmodel' and point to the 'Foo'. A hover 'foo.Foo' [Java class] appears (that's expected, because now the reference resolves to the generated Java class).

6. Switch to 'Foo.dmodel' and uncomment 'entity Foo {}'. Switch back to 'Bar.dmodel' and point to the 'Foo' again. A hover 'foo.Foo' [Java class] appears (that's NOT expected). If we then try to navigate to the 'Foo', it will open 'Foo.java', not 'Foo.dmodel'.

Debugging shows that the last change to 'Foo.dmodel' (#6) does not cause relinking in 'Bar.dmodel' (i.e. JvmModelXbaseLazyLinker is not called for 'Bar.dmodel').
Comment 1 Vladimir Piskarev CLA 2011-08-16 10:14:54 EDT
Created attachment 201573 [details]
'example' project
Comment 2 Vladimir Piskarev CLA 2011-08-23 07:48:17 EDT
Debugging revealed that this bug is caused by bug 354910.

In particular, at step 5 the resource 'Foo.dmodel' is unloaded from the resource set underlying the 'Bar.dmodel' editor. At step 6 DirtyStateEditorSupport#UpdateEditorStateJob is run for 'Bar.dmodel', but the editor's resource set doesn't contain the affected resource 'Foo.dmodel' (it was unloaded at step 5) and reparse is not deemed required because 'Bar.dmodel' has no imported names (and hence, will not be 'affected' by _any_ delta). Thus both conditions are false in 'if (affectedResources != null && !affectedResources.isEmpty() || isReparseRequired[0])' and no relinking occurs.
Comment 3 Christian Dietrich CLA 2016-08-19 02:54:02 EDT
can no longer be reproduced