Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » problem with using import quickfix (quickfix deletes all lines after a syntax error (example typo in keyword))
problem with using import quickfix [message #1745127] Wed, 05 October 2016 13:29 Go to next message
Mehmet Karaman is currently offline Mehmet KaramanFriend
Messages: 63
Registered: November 2012
Location: Berlin

i've a problem with an import quick fix. For example i have a file with a syntax error and there is also an unresolved element, for which i use the import quickfix. The import will be added, but all lines below the syntax error gets lost.

I can imagine that XText can't deserialize the whole file, so the result is an incomplete EObject structure. The import quick fix adds an namespace import object by modifying the EObject structure and then the whole model structure can't be serialized back. I was counting on that XText serializes the local changes only instead of the whole model.

Is it a usual way to modify the EObjects or should a quickfix use the NodeModel to modify it's content?

Thank you in advance.

Best regards
Re: problem with using import quickfix [message #1745133 is a reply to message #1745127] Wed, 05 October 2016 14:15 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14492
Registered: July 2009
Senior Member
Hi you have the choice if you modify the document directly (imodification) or the model (semantic modification)

Need professional support for Xtext, Xpand, EMF?
Go to:
Twitter : @chrdietrich
Blog :
Re: problem with using import quickfix [message #1745289 is a reply to message #1745133] Fri, 07 October 2016 10:33 Go to previous message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1850
Registered: July 2009
Senior Member
I believe there's a general problem with serialization on behalf of a quick fix:
Xtext determines the region that has to be replaced as the parent EObject of the current modification.
In case of an import this is always the entire model, i.e., we can only modify the list of imports in error-free models.

A smarter algorithm could instead identify the parent feature, here the list of imports.
Rewriting only this list could work independently of any problems in the rest of the model.
This reminds me of the JDT concept of distinguishing between the main ASTRewrite and individual ListRewrites.

(I'm aware that grammars exist, that populate a semantic list from various locations in the syntax,
but for "well-behaved" grammers that define a single (myFeature+=SomeRule)* assignment,
a list like 'myFeature' could be serialized as one isolated region of the text, without touching the rest)

If Xtext would support more fine grained rewriting, model based quick fixes would be much more powerful.
Currently it seems, that a quick fix can only resolve a single problem in a file.
If multiple problems exist, many quick fixes will simply fail, or even worse: discard data.

Are there any plans to improve Xtext in this direction?
Disclaimer: I'm discussion this at the state of 2.8.4, not sure if subsequent version have already improved on this issue.

Previous Topic:Linking issue while programmatic validation
Next Topic:Get Project Name in new Project Wizard for Eclipse
Goto Forum:

Current Time: Tue May 30 12:12:59 GMT 2023

Powered by FUDForum. Page generated in 0.01515 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top