Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 345469 - [xbase] problem with resource serialization
Summary: [xbase] problem with resource serialization
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.0.0   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: RC1   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-11 12:46 EDT by Knut Wannheden CLA
Modified: 2017-09-19 17:34 EDT (History)
2 users (show)

See Also:
sebastian.zarnekow: indigo+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Knut Wannheden CLA 2011-05-11 12:46:15 EDT
XtextResource#doSave() verifies that the resource only contains a single top-level object (i.e. getContents().size() == 1).  At the same time the JvmModelXbaseLazyLinker will install additional top-level objects for any inferred objects.

Should the check in XtextResource#doSave() be weakened or is a language such as Domainmodel required to subclass LazyLinkingResource if it needs to serialize a model using the standard EMF resource API?

Domainmodel test case to reproduce the problem:

public class Main {

	public static void main(String[] args) throws IOException {
		Injector injector = new DomainmodelStandaloneSetup().createInjectorAndDoEMFRegistration();
		XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class);
		Resource resource = resourceSet.createResource(URI.createURI("foo.dmodel"));
		resource.load(new StringInputStream("entity Foo {}"), null);
		resource.save(null);
	}
}
Comment 1 Knut Wannheden CLA 2011-05-11 12:54:51 EDT
Reclassifying as enhancement. Although one could argue that it is a bug for languages like Xtend2 and Domainmodel, as it breaks the EMF resource API contract.
Comment 2 Sebastian Zarnekow CLA 2011-05-11 12:57:54 EDT
Xbaseified languages should use the XbaseResource. The precondition could be weakend there.
Comment 3 Knut Wannheden CLA 2011-05-11 14:52:01 EDT
Sounds reasonable.
Comment 4 Sven Efftinge CLA 2011-05-15 11:03:01 EDT
We've decided to make the mentioned behavior default, because the pattern we use in Xbase, to put derived EObjects into the resource's contents list after the root element, is generally useful.
Pushed to master.
Comment 5 Karsten Thoms CLA 2017-09-19 17:22:44 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 6 Karsten Thoms CLA 2017-09-19 17:34:09 EDT
Closing all bugs that were set to RESOLVED before Neon.0