Good morning, i'm new in xtext. I wrote a grammar for my dsl and in the genrator a method generated in the model give we wrong result: the grammar snipped that is wrong is: Feature:
'Feature' name=ID '{'
'verb' verb= [Activity]
'objects' '('(classes+=[Class] (','classes+=[Class])*)?')'
'common' '('(common+=[Feature] (','common+=[Feature])*)?')'
'optional' '('(optional+=[Feature] (','optional+=[Feature])*)?')'
'variabilities' '(' (variabilities+=[FeatureVariability] (','variabilities+=FeatureVariability])*)?')'
'generalization' '('(generalization+=[Feature] (','generalization+=Feature])*)?')'
'}';
an then have model with the following Features:
Feature f2{
verb act1
objects (C4, C3)
common()
optional(f32, f31)
variabilities()
generalization()
}
Feature f3{
verb act1
objects (C1, C2, C3)
common()
optional(f31, f32)
variabilities()
generalization()
}
Feature f31{
verb act2
objects (C3)
common()
optional()
variabilities()
generalization()
}
Feature f32{
verb act1
objects (C1, C2, C3)
common()
optional()
variabilities()
generalization()
}
Feature f4{
verb act1
objects (C1, C2, C3)
common()
optional(f32, f31)
variabilities()
generalization()
}
Feature f1{
verb act1
objects (C1, C4)
common(f2)
optional(f31)
variabilities()
generalization()}
when i display the features names, common's size common's contains , optional
size optionnal size, optionnal contain, i have the following results:
feature name:f2, size of common:2 common featuresf32,f31
feature name:f2, size of optional:2 optional featuresf32,f31
feature name:f3, size of common:2 common featuresf31,f32
feature name:f3, size of optional:2 optional featuresf31,f32
feature name:f31, size of common:0 common features
feature name:f31, size of optional:0 optional features
feature name:f32, size of common:0 common features
feature name:f32, size of optional:0 optional features
feature name:f4, size of common:2 common featuresf32,f31
feature name:f4, size of optional:2 optional featuresf32,f31
feature name:f1, size of common:2 common featuresf2,f31
feature name:f1, size of optional:2 optional featuresf2,f31
but when i use Junit to test, everithing is ok. thanks for your help
make sure if you work with your feature lists in the validator and generator, that you dont accientially do a model2model transformation e.g.
feature.common + feature.optional