Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » quick fix (ISemanticModification) for file with errors?
quick fix (ISemanticModification) for file with errors? [message #895965] Mon, 16 July 2012 16:39 Go to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1764
Registered: July 2009
Senior Member
I have the simplest of quick fixes which just adds one line at the top of a file. I used an ISemanticModification (although this particular use case might be better served with a plain IModification). Unfortunately this quick fix fails if the file contains a syntax error.

The element added by the quick fix corresponds to a field of the root model EObject. Thus, the change is recognized as changing the root object, thus the entire file is being serialized, which throws IConcreteSyntaxValidator.InvalidConcreteSyntaxException on any syntax error in the file, thus aborting the modification.

Is there a way the quickfix could signal to the framework that some regions are not affected by the change? Or are semantic modifications of files with errors out of scope ATM?

Would you be interested in a discussion of how the JDT addresses similar problems?

best,
Stephan
Re: quick fix (ISemanticModification) for file with errors? [message #896001 is a reply to message #895965] Mon, 16 July 2012 19:53 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1764
Registered: July 2009
Senior Member
OK, maybe my previous example could actually be solved with an IModification. Maybe a too broken document is not a good starting point for an ISemanticModification.

But the next experiment surprised me a bit more. I must be doing s.t. wrong:

I'm trying to write a quickfix for a broken cross reference, proposing to insert the corresponding import, makes sense?

I got the machinery in place to find the element and to create the import. But again applying the modification fails because there's an error in the document. Guess which error is preventing the quick fix from cleanly applying: the unresolved cross reference it is trying to fix.

Ups?
To understand recursion you must first understand recursion?
Smile
Stephan
Re: quick fix (ISemanticModification) for file with errors? [message #896012 is a reply to message #896001] Mon, 16 July 2012 22:12 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1764
Registered: July 2009
Senior Member
More details regarding the cross-references issue:

In one situation it works OK, in another it doesn't. I think the distinguishing facts are:
- in one case the cross reference happens via an explicit reference node
- in the other case the cross reference happens inline
like this:
Element1: 'element1' name=ID ref=Reference ; // unresolved Reference is fixable
Reference: target=[Target] ;

Element2: 'element2' other=[otherModel::Target] ; // unresolved otherModel::Target is not fixable


Not sure if crossing model boundaries (otherModel::Target is imported) makes a difference. Another factor might be, that the name of an otherModel::Target is also used as the name of the Element2.

The error preventing serialization is s.t. like
Feature Element2.other must be set. Source: Model.elements[13]->Element2


best,
Stephan

[Updated on: Mon, 16 July 2012 22:14]

Report message to a moderator

Re: quick fix (ISemanticModification) for file with errors? [message #896433 is a reply to message #896012] Wed, 18 July 2012 11:44 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3107
Registered: July 2009
Senior Member
Hi Stephan,

do you set the fixed value on the reference or do you just add the import?

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 17.07.12 00:12, schrieb Stephan Herrmann:
> More details regarding the cross-references issue:
>
> In one situation it works OK, in another it doesn't. I think the
> distinguishing facts are:
> - in one case the cross reference happens via an explicit reference node
> - in the other case the cross reference happens inline
> like this:
>
> Element1: element1 name=ID ref=Reference ;
> Reference: target=[Target] ; // OK
>
> Element2: element2 other=[otherModel::Target] ; // NOT OK
>
>
> Not sure if crossing model boundaries (otherModel::Target is imported)
> makes a difference. Another factor might be, that the name of an
> otherModel::Target is also used as the name of the Element2.
>
> The error preventing serialization is s.t. like
> Feature Element2.other must be set. Source: Model.elements[13]->Element2
>
> best,
> Stephan
>
Re: quick fix (ISemanticModification) for file with errors? [message #896533 is a reply to message #896433] Wed, 18 July 2012 17:53 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1764
Registered: July 2009
Senior Member
Sebastian Zarnekow wrote on Wed, 18 July 2012 13:44
do you set the fixed value on the reference or do you just add the import?


I was just adding a new import.

It seems, the unresolved reference prevents any serialization. Also the unrelated quick fix from my initial post is broken if such an unresolved reference is present (not only when syntax errors are present, as I initially thought).

Stephan
Re: quick fix (ISemanticModification) for file with errors? [message #896601 is a reply to message #896533] Thu, 19 July 2012 06:06 Go to previous messageGo to next message
Knut Wannheden is currently offline Knut WannhedenFriend
Messages: 298
Registered: July 2009
Senior Member
Hi Stephan,

I think you may possibly have been bitten by the same problem as I:
http://www.eclipse.org/forums/index.php/t/341799/. The problem being that
modifying a model which contains unresolved lazy linking proxies may end up
rendering the URI fragments of those proxies "incompatible" with the model, as
the object paths it encodes are no longer valid.

There is an enhancement request for this problem:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=378088.

Regards,

--knut

On 7/18/12 7:53 PM, Stephan Herrmann wrote:
> Sebastian Zarnekow wrote on Wed, 18 July 2012 13:44
>> do you set the fixed value on the reference or do you just add the import?
>
>
> I was just adding a new import.
>
> It seems, the unresolved reference prevents any serialization. Also the
> unrelated quick fix from my initial post is broken if such an unresolved
> reference is present (not only when syntax errors are present, as I initially
> thought).
>
> Stephan
>
Re: quick fix (ISemanticModification) for file with errors? [message #897103 is a reply to message #896601] Sat, 21 July 2012 19:55 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1764
Registered: July 2009
Senior Member
Do URI fragments change even if the resource containing the target of the x-ref is not changed at all?

If so, this might well explain that part of the problem. I'd be happy to try the patch from the bug once it appears in a public build. Is it ready for a test drive?

What about serializing a document with syntax errors? Is that somehow supported?

thanks,
Stephan
Re: quick fix (ISemanticModification) for file with errors? [message #899722 is a reply to message #897103] Thu, 02 August 2012 06:12 Go to previous message
Knut Wannheden is currently offline Knut WannhedenFriend
Messages: 298
Registered: July 2009
Senior Member
Hi Stephan,

On 7/21/12 9:55 PM, Stephan Herrmann wrote:
> Do URI fragments change even if the resource containing the target of the
> x-ref is not changed at all?
>

No, not if the reference could be resolved. Then there should in fact, under
normal circumstances, not be any proxies with URIs in play at all.

This is different when there are unresolved references. These are represented
by lazy linking proxies whose URI depends on the owning object's location in
the resource (relative to the root). The lazy linking proxy URI may thus
become invalid when changing the model and would then result in exceptions
during serialization.

> If so, this might well explain that part of the problem. I'd be happy to try
> the patch from the bug once it appears in a public build. Is it ready for a
> test drive?
>

The patch has not been committed. You would have to apply it in your own code
base by making corresponding Guice bindings.

> What about serializing a document with syntax errors? Is that somehow supported?
>

What is being serialized is the model and as such can't really contain any
syntax errors. The model can although contain semantic errors which may or may
not prevent serialization.

Regards,

--knut
Previous Topic:guava dependencies
Next Topic:From 2.1 to 2.3
Goto Forum:
  


Current Time: Sun Feb 23 23:43:07 GMT 2020

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

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

Back to the top