Bug 441517 - Semantic Modification creates Broken model
Summary: Semantic Modification creates Broken model
Status: NEW
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.6.1   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2014-08-11 10:22 EDT by Christian Dietrich CLA
Modified: 2017-02-09 05:17 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Dietrich CLA 2014-08-11 10:22:21 EDT
The semantic modification produces invalid code if the first element of a rule is created. 

here are the steps to reproduce

(1) grammar

Model:
	(ausgaben+=Ausgabedatum)*;
	
Ausgabedatum:
	name=ID '(' 'beschreibung' beschreibung=STRING ')' '{'
		(datumReferenzen+=DatumReferenzOhnePflicht)+
	'}'
	;

DatumReferenzOhnePflicht returns DatumReferenz:
	(
		name=ID
		'(' 
			'typ' ( idTyp?='ID' | basistyp=ID | ("$" wertebereich=ID))
			(('minOccurs' minOcc=INT)? & ('beschreibung' beschreibung=STRING)?)
		')' ':'
	)?	
	(
		nil?='nil'	
		|	(
				(referenz=FunktionsvariablenReferenzkette | referenz=DatenmodellReferenzkette)
				(mapped?='mapped')?
			)
	)
	;
	
FunktionsvariablenReferenzkette:
	"#" name=ID
;	

DatenmodellReferenzkette:
	"$" name=ID
;

(2) Check

  public static val INVALID_NAME = 'invalidName'

	@Check(CheckType.NORMAL)
	def checkName(DatumReferenz a) {
		if (a.name == null) {
			error('there should be a name', 
					a, null,
					INVALID_NAME)
		}
	}

(3) Quickfix

	@Fix(MyDslValidator::INVALID_NAME)
	def capitalizeName(Issue issue, IssueResolutionAcceptor acceptor) {
		acceptor.accept(issue, 'Give name', 'Give the name.', 'upcase.png') [
			element, context |
			if (element instanceof DatumReferenz) {
				element.name = "Name_" + System.nanoTime
				element.idTyp = true
				}
		]
	}

(4) Test modell (execute the quickfix on $b)

xxxx (beschreibung "yyyy") {
	$a
	$b
}
Comment 1 Christian Dietrich CLA 2016-08-31 04:19:40 EDT
still an issue with 2.10
Comment 2 Christian Dietrich CLA 2017-02-09 05:17:25 EST
Still an issue in 2.11.

Interestingly it works fine in the serializer