Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 345469

Summary: [xbase] problem with resource serialization
Product: [Modeling] TMF Reporter: Knut Wannheden <knut.wannheden>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: sebastian.zarnekow, sven.efftinge
Version: 2.0.0Flags: sebastian.zarnekow: indigo+
Target Milestone: RC1   
Hardware: All   
OS: All   
Whiteboard:

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