eclipse-xtext / eclipse-xtext/xtext

Bad Behaviour of IChangeSerializer regarding unassigned keyword

Open
#2,552 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
831
Forks
330
Avg merge
3d 7h
Merged PRs (30d)
12

Description

given the grammar

Model:
	"model" name=ID "{"
		(expressions+=Expression ';'?)*
	"}"
	;

Expression:
	TrueLiteral | FalseLiteral
;

TrueLiteral:
	{TrueLiteral}"true"
;

FalseLiteral:
	{FalseLiteral}"false" 
;

and Validation

	@Check
	def void checkFalse(FalseLiteral falseLiteral) {
		error("false is bad", falseLiteral, null, "FALSE_IS_BAD")
	}

and Quickfix

	@Fix("FALSE_IS_BAD")
	def makeItTrue(Issue issue, IssueResolutionAcceptor acceptor) {
		acceptor.acceptMulti(issue, 'Make It True', 'Make It True.', 'upcase.png') [
			EObject o, context |
			context.addModification(o)[
				EcoreUtil.replace(o, MyDslFactory.eINSTANCE.createTrueLiteral)
			]
		]
	}

applied to this model

model demo {
	false ; false ; false;
}

results in

model demo { true true true ;  ; ;
}

as you can see the semicolons keep dangling at the end (new literals are introduced at the beginning, and removed from the place they where without removing the ;

if i make the semicolon required

(expressions+=Expression ';')*

the result is

model demo { true true true ;  ; ;
}

@meysholdt any hints?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the grammar, validation, and quickfix example from the issue, then inspect IChangeSerializer handling of replaced EObjects and unassigned semicolons. Trace how the replacement is serialized and add a regression test covering both optional and required semicolons; done means the resulting model preserves the intended separators without dangling semicolons.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
compilers, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.