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

Bug 312896

Summary: ConcreateSyntaxValidation gives false negative when serializing model
Product: [Modeling] TMF Reporter: Joerg Reichert <joerg83reichert>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: major    
Priority: P3 CC: moritz.eysholdt, sebastian.zarnekow
Version: unspecifiedFlags: sebastian.zarnekow: helios+
Target Milestone: RC1   
Hardware: PC   
OS: Windows Vista   
Whiteboard:
Attachments:
Description Flags
example project
none
example project without actions none

Description Joerg Reichert CLA 2010-05-14 08:16:13 EDT
Build Identifier: I20100429-1549

in context of MWE2, Writer component:

ConcreateSyntaxValidation complains about invalid model, but when validation is set off the model is properly serialized:

extract from model

* Predicate name = null
** Predicate name = "Lower"
** Predicate name = "lower"
** Predicate name = "<"

error when validation is set on: 

735  ERROR Mwe2Launcher       - These errors need to be fixed before the model an be serialized.
WsQualitySpecification.elements[1]->Predicate: The feature Predicate.left contains non-transient values but has no corresponding assignment in rule ModelElement.
WsQualitySpecification.elements[1]->Predicate: The feature Predicate.left contains non-transient values but has no corresponding assignment in rule TerminalPredicate.
WsQualitySpecification.elements[1]->Predicate: The feature Predicate.alias contains non-transient values but has no corresponding assignment in rule TerminalPredicate.
WsQualitySpecification.elements[2]->Predicate: The feature Predicate.left contains non-transient values but has no corresponding assignment in rule ModelElement.
WsQualitySpecification.elements[2]->Predicate: The feature Predicate.left contains non-transient values but has no corresponding assignment in rule TerminalPredicate.
WsQualitySpecification.elements[2]->Predicate: The feature Predicate.alias contains non-transient values but has no corresponding assignment in rule TerminalPredicate.

org.eclipse.xtext.validation.IConcreteSyntaxValidator$InvalidConcreteSyntaxException: These errors need to be fixed before the model an be serialized.
WsQualitySpecification.elements[1]->Predicate: The feature Predicate.left contains non-transient values but has no corresponding assignment in rule ModelElement.
WsQualitySpecification.elements[1]->Predicate: The feature Predicate.left contains non-transient values but has no corresponding assignment in rule TerminalPredicate.
WsQualitySpecification.elements[1]->Predicate: The feature Predicate.alias contains non-transient values but has no corresponding assignment in rule TerminalPredicate.
WsQualitySpecification.elements[2]->Predicate: The feature Predicate.left contains non-transient values but has no corresponding assignment in rule ModelElement.
WsQualitySpecification.elements[2]->Predicate: The feature Predicate.left contains non-transient values but has no corresponding assignment in rule TerminalPredicate.
WsQualitySpecification.elements[2]->Predicate: The feature Predicate.alias contains non-transient values but has no corresponding assignment in rule TerminalPredicate.

at org.eclipse.xtext.parsetree.reconstr.Serializer.serialize(Serializer.java:49)
at org.eclipse.xtext.parsetree.reconstr.Serializer.serialize(Serializer.java:59)
at org.eclipse.xtext.resource.XtextResource.doSave(XtextResource.java:289)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:1406)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:993)
at de.abg.jreichert.serviceqos.ServiceQosWriter.write(ServiceQosWriter.java:178)
at de.abg.jreichert.serviceqos.ServiceQosWriter.invokeInternal(ServiceQosWriter.java:114)
at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:129)
at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:199)
at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.invoke(AbstractCompositeWorkflowComponent.java:31)
at org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow.java:19)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:73)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:51)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:74)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:35) 



Reproducible: Always

Steps to Reproduce:
1. model over multiple files merged in one model
2. try to serialize model with writer component in MWE2
3.
Comment 1 Joerg Reichert CLA 2010-05-14 08:17:10 EDT
Created attachment 168529 [details]
example project
Comment 2 Sebastian Zarnekow CLA 2010-05-14 08:52:14 EDT
Scheduled for RC2.
Comment 3 Moritz Eysholdt CLA 2010-05-14 12:49:25 EDT
hi Joerg,

thanks for the report. The ConcreteSyntaxValidator can't validate based on grammar rules that contain assigned actions. The expected behavior is that validation for those rules is disabled. The problem you unveiled was that rules which have unassigned rule calls to disabled rules were not implicitly disabled as well.

Disabling rules with assigned actions leads to unfortunate consequences for your grammar, since your rule 'ModelElement' delegates to many other rules of which one rule ('Predicate') contains an assigned action ('{sqos::Predicate.left=current}').

----
ModelElement returns sqos::ModelElement :
	Namespace | Service | Unit | Metric | 
	NonFunctionalProperty | NonFunctionalPropertyMeasurement | 
	QoSAspect | QoSParameterApplication |
	Predicate | Guarantee
;

Predicate returns sqos::Predicate :
	"predicate" TerminalPredicate ({sqos::Predicate.left=current} 
    ("alias" alias+=TerminalPredicate ("," alias+=TerminalPredicate)* )?)
;

TerminalPredicate returns sqos::Predicate :
	{sqos::Predicate} name=PredicateIdent
;
----

Thereby, validation is disabled for almost all delegates of 'ModelElement', which is more than 50% of your grammar...


I'd recommend not to left-factor your 'Predicate' rule. Left-factoring is not needed in your scenario anyway since your don't have rules calling each other unassigned and recursively.

----
Predicate returns sqos::Predicate:
  "predicate" (TerminalPredicate|left=TerminalPredicate "alias"
  alias+=TerminalPredicate ("," alias+=TerminalPredicate)*);

TerminalPredicate returns sqos::Predicate:
  name=PredicateIdent;
----

With this suggestion, you don't need assigned actions and thereby don't need to accept restrictions on the ConcreteSyntaxValidator.
Comment 4 Moritz Eysholdt CLA 2010-05-14 12:50:35 EDT
The fix will already be available in RC1.
Comment 5 Joerg Reichert CLA 2010-05-15 03:56:59 EDT
Hi Moritz,

I changed the grammar (and the imported ecore too), as you proposed, i.e. now it does not use actions anymore, but the serializer with ConcreteSyntaxValidator still fails. Here the grammar excerpt:

Predicate returns sqos::Predicate :
   "predicate" (
      TerminalPredicate |
      left=TerminalPredicate "alias" alias+=TerminalPredicate 
           ("," alias+=TerminalPredicate)*
   )
;

TerminalPredicate returns sqos::TerminalPredicate:
   name=PredicateIdent; 


Now I get this error:

751  ERROR Mwe2Launcher       - These errors need to be fixed before the model an be serialized.
WsQualitySpecification.elements[1]->Predicate: An object of type WsQualitySpecification or Unit or QoSAspect or ModelElement or Metric or Guarantee or NonFunctionalProperty or QoSParameterApplication or NonFunctionalPropertyMeasurement or TerminalPredicate or Service is needed instead of Predicate for serialization with rule ModelElement. Constraint: (()|()|name|()|()|()|()|()|(name|())|()) Quantities: name:0
WsQualitySpecification.elements[2]->Predicate: An object of type WsQualitySpecification or Unit or QoSAspect or ModelElement or Metric or Guarantee or NonFunctionalProperty or QoSParameterApplication or NonFunctionalPropertyMeasurement or TerminalPredicate or Service is needed instead of Predicate for serialization with rule ModelElement. Constraint: (()|()|name|()|()|()|()|()|(name|())|()) Quantities: name:0

org.eclipse.xtext.validation.IConcreteSyntaxValidator$InvalidConcreteSyntaxException: These errors need to be fixed before the model an be serialized.
WsQualitySpecification.elements[1]->Predicate: An object of type WsQualitySpecification or Unit or QoSAspect or ModelElement or Metric or Guarantee or NonFunctionalProperty or QoSParameterApplication or NonFunctionalPropertyMeasurement or TerminalPredicate or Service is needed instead of Predicate for serialization with rule ModelElement. Constraint: (()|()|name|()|()|()|()|()|(name|())|()) Quantities: name:0
WsQualitySpecification.elements[2]->Predicate: An object of type WsQualitySpecification or Unit or QoSAspect or ModelElement or Metric or Guarantee or NonFunctionalProperty or QoSParameterApplication or NonFunctionalPropertyMeasurement or TerminalPredicate or Service is needed instead of Predicate for serialization with rule ModelElement. Constraint: (()|()|name|()|()|()|()|()|(name|())|()) Quantities: name:0

	at org.eclipse.xtext.parsetree.reconstr.Serializer.serialize(Serializer.java:49)
	at org.eclipse.xtext.parsetree.reconstr.Serializer.serialize(Serializer.java:59)
	at org.eclipse.xtext.resource.XtextResource.doSave(XtextResource.java:289)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:1406)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:993)
	at de.abg.jreichert.serviceqos.ServiceQosWriter.write(ServiceQosWriter.java:178)
	at de.abg.jreichert.serviceqos.ServiceQosWriter.invokeInternal(ServiceQosWriter.java:114)
	at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:129)
	at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:199)
	at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.invoke(AbstractCompositeWorkflowComponent.java:31)
	at org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow.java:19)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:73)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:51)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:74)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:35)


When I switch the ConcreteSyntaxValidator off again, it works.

That is the model as shown in the XMI editor

* WsQualitySpecification
** Predicate name = null
*** TerminalPrediate name = Lower
*** TerminalPrediate name = lower
*** TerminalPrediate name = <
** Predicate name = null
*** TerminalPrediate name = Equal
*** TerminalPrediate name = equal
*** TerminalPrediate name = ==
Comment 6 Joerg Reichert CLA 2010-05-15 03:58:30 EDT
Created attachment 168628 [details]
example project without actions
Comment 7 Moritz Eysholdt CLA 2010-05-15 05:10:32 EDT
For me, /de.abg.jreichert.serviceqos.generator/src/workflow/ServiceQosGenerator.mwe2 executes without errors. This is the workflow that is supposed to reproduce the errors, isen't it? Could you please update to the latest nightly version (or RC1, which is scheduled for Tuesday) of Xtext and check again?
Comment 8 Joerg Reichert CLA 2010-05-16 04:28:06 EDT
used the last nightly build (1.0.0.v201005152002) and it works.
Comment 9 Karsten Thoms CLA 2017-09-19 16:04:34 EDT
Closing bug which were set to RESOLVED before Eclipse Neon.0.