osate / osate2

Open Source AADL2 Tool Environment
http://osate.org
Eclipse Public License 2.0
39 stars 8 forks source link

Xtext Concrete Syntax Validation Error / Error Creating Abstract Feature Graphically #990

Closed philip-alldredge closed 6 years ago

philip-alldredge commented 6 years ago

@lwrage I just found this issue and I'm not sure the best way to resolve. I would appreciate the thoughts of the appropriate SEI team members.

This is an issue that affects the graphical editor but it was triggered by a change in the core. Not sure if the best path forward is to modify the GE or the core.

When attempting to create an abstract feature graphically while the xtext document is not open, the feature is not created. The graphical editor calls validateConcreteSyntax() on the xtext resource and it returns the following error:

!MESSAGE org.osate.ge.internal.services.impl.DefaultAadlModificationService.modifySafely(): Feature AbstractFeature.featurePrototype must be set. Constraint: (featurePrototype|abstractFeatureClassifier?) Quantities: abstractFeatureClassifier:0, featurePrototype:0 Source: AadlPackage'midpoint_bug'.ownedPublicSection->PublicPackageSection'midpoint_bug_public'.ownedClassifier[1]->AbstractType'new_classifier'.ownedAbstractFeature[0]->AbstractFeature'new_classifier_new_feature2'

The graphical editor calls that function as a (potentially overcautious) precaution against saving an invalid model. If the check is removed, then everything seems to work correctly. However, if there is a fix on the core side, then that would be preferred.

I am guessing this is related to the fix for #883. Presumably xtext doesn't know how to serialize the feature.

lwrage commented 6 years ago

I'll have a look. Can you send me instruction how to reproduce the exception, please?

philip-alldredge commented 6 years ago

An exception isn't actually thrown, but the graphical editor does log the validation errors. This is an area where the GE needs to be improved with better error reporting.

Without having the AADL file open.

!ENTRY org.osate.ge 1 0 2018-01-04 08:18:54.433 !MESSAGE org.osate.ge.internal.services.impl.DefaultAadlModificationService.modify(): Executing modification without a thread switch

!ENTRY org.osate.ge 4 0 2018-01-04 08:18:54.493 !MESSAGE org.osate.ge.internal.services.impl.DefaultAadlModificationService.modifySafely(): Error. Undoing modification

!ENTRY org.osate.ge 4 0 2018-01-04 08:18:54.493 !MESSAGE org.osate.ge.internal.services.impl.DefaultAadlModificationService.modifySafely(): Concrete Syntax Validation Errors:

!ENTRY org.osate.ge 4 0 2018-01-04 08:18:54.509 !MESSAGE org.osate.ge.internal.services.impl.DefaultAadlModificationService.modifySafely(): Feature AbstractFeature.featurePrototype must be set. Constraint: (featurePrototype|abstractFeatureClassifier?) Quantities: abstractFeatureClassifier:0, featurePrototype:0 Source: AadlPackage'abc'.ownedPublicSection->PublicPackageSection'abc_public'.ownedClassifier[0]->AbstractType'new_classifier'.ownedAbstractFeature[0]->AbstractFeature'new_classifier_new_feature'

lwrage commented 6 years ago

This looks like a bug in the concrete syntax validator: It determines that featurePrototype must be set, which is obviously wrong. BTW, I don't think it is necessary to call the concreteSyntaxValidator after you test serialization. AFAIK, the serializer never produces text with syntax or linking errors.

lwrage commented 6 years ago

I found that changing the grammar from ('prototype' featurePrototype | 'feature' featureClassifier?) to ('prototype' featurePrototype | 'feature' featureClassifier | 'feature') seems to be a work-around.

philip-alldredge commented 6 years ago

Okay. I'll disable the call to concreteSyntaxValidator to avoid similar issues in the future.