Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serializer Problem with unordered groups #2580

Open
cdietrich opened this issue May 15, 2017 · 1 comment
Open

Serializer Problem with unordered groups #2580

cdietrich opened this issue May 15, 2017 · 1 comment

Comments

@cdietrich
Copy link
Contributor

cdietrich commented May 15, 2017

Searializer behaves wrong for unordered groups

serializing existing models with unordered groups and adding a new element to an existing * part leads to an invalid model

Model:
	'model' site=ID '{'
        (
            xxxxValue=XXXXValue? &
            properties+=PropertyAssignment*
        )
    '}'
;	
XXXXValue:
    "xxxx" "=" value=INT
;

PropertyAssignment:
    name=ID "=" value=INT
;
import com.google.inject.Inject
import org.eclipse.xtext.serializer.ISerializer
import org.eclipse.xtext.testing.InjectWith
import org.eclipse.xtext.testing.XtextRunner
import org.eclipse.xtext.testing.util.ParseHelper
import org.junit.Assert
import org.junit.Test
import org.junit.runner.RunWith
import org.xtext.example.mydsl3.myDsl.Model
import org.xtext.example.mydsl3.myDsl.MyDslFactory

import static org.junit.Assert.assertEquals

@RunWith(XtextRunner)
@InjectWith(MyDslInjectorProvider)
class MyDslParsingTest{

	@Inject
	ParseHelper<Model> parseHelper
	
	@Inject extension ISerializer serializer

	@Test 
	def void loadModel() {
		val result = parseHelper.parse('''
			model mymodel {
			    yyyy = 1
			    xxxx = 2
			}
		''')
		Assert.assertNotNull(result)
		println(result.eResource.errors)
		result.properties += MyDslFactory.eINSTANCE.createPropertyAssignment => [
		    name = "xxxxx"
		    value = 1
		]
		
		val ser = result.serialize
		println(ser)
		println(parseHelper.parse(ser).eResource.errors)
		assertEquals(0, parseHelper.parse(ser).eResource.errors.size)
	}

}

@cdietrich
Copy link
Contributor Author

cdietrich commented May 15, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant