eclipse-xtext / eclipse-xtext/xtext
Serializer Problem with unordered groups
Open
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 831
- Forks
- 330
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 12
Description
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)
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the MyDslParsingTest reproducer and the injected ISerializer used after adding a PropertyAssignment to result.properties. Run the test with the unordered-group grammar shown in the issue, then trace why serialization produces text that parseHelper.parse reports as invalid. Done means the modified model serializes to text that reparses with zero resource errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- compilers, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100