Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Automatic handling of errors/warnings
Automatic handling of errors/warnings [message #1036332] Mon, 08 April 2013 08:42 Go to next message
Marco Naddeo is currently offline Marco NaddeoFriend
Messages: 62
Registered: November 2012
Member
Hi all. Smile

On a linking error, I can raise appropriate diagnostic (say MyDSL.MY_APPROPRIATE_DIAGNOSTIC) and then write, in MyDSLQuickfixProvider, a quick fix for it by annotating it in this way:

@Fix(MyDSL.MY_APPROPRIATE_DIAGNOSTIC)
public void fixMyAppropriateDiagnostic(final Issue issue, final IssueResolutionAcceptor acceptor) {
  ...
}


What about if I wanted to automatically resolve a diagnostic, i.e. automatically execute an IModification without propose it to the user as quick fix (imagine the quick fix for the diagnostic is unique)?

Is there a way to associate a (immediate) handling code to a diagnostic in a similar manner to what happens for (user-proposed) quick fixes?


Thanks in advance,
Marco
Re: Automatic handling of errors/warnings [message #1038144 is a reply to message #1036332] Wed, 10 April 2013 13:08 Go to previous messageGo to next message
Marco Naddeo is currently offline Marco NaddeoFriend
Messages: 62
Registered: November 2012
Member
Anyone has any hint to do that? Sad
Re: Automatic handling of errors/warnings [message #1038432 is a reply to message #1038144] Wed, 10 April 2013 21:42 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
On 2013-10-04 15:08, Marco Naddeo wrote:
> Anyone has any hint to do that? :(
I can imagine running a builder that kicks in after parsing and linking
(it needs to see the produced errors) it then searches for those that it
knows how to autofix.

But why are they errors in the first place? Are they linking errors? If
so, you can write a custom linker an implement the callback method that
is executed after normal linking is done.

Does that help?

I use the technique above in cloudsmith / geppetto at github.

Regards
- henrik
Re: Automatic handling of errors/warnings [message #1040336 is a reply to message #1038432] Sat, 13 April 2013 11:49 Go to previous messageGo to next message
Marco Naddeo is currently offline Marco NaddeoFriend
Messages: 62
Registered: November 2012
Member
Henrik Lindberg wrote on Wed, 10 April 2013 17:42
But why are they errors in the first place? Are they linking errors? If
so, you can write a custom linker an implement the callback method that
is executed after normal linking is done.


Hi and first of all thanks for your answer. Smile

Yes, they are linking errors.

I already tried to call the method that autofixes these errors after normal linking is done, but I don't understand where and how I could hook this call.

I saw that the XtextResource class has a method named updateInternalState whose last instruction is the call of the doLinking method... after this call, I should know the produced errors and so I should be able to trigger the appropriate method to autofix some of them, as I want.

Now, my problem is substantially that what I want to execute is an IModification (or ISemanticModification), as I do in the implementation of my quick fix, but obviously I cannot directly use a UI class from the model package... so I need a way to circumnavigate this problem.

Do you have any hint about this? Rolling Eyes


Thanks again,
Marco
Re: Automatic handling of errors/warnings [message #1040341 is a reply to message #1040336] Sat, 13 April 2013 12:01 Go to previous messageGo to next message
Marco Naddeo is currently offline Marco NaddeoFriend
Messages: 62
Registered: November 2012
Member
P.S.: in cloudsmith / geppetto you use the latter of two techniques you indicated? if so, could you kindly tell me in that project from which package or classes can I take inspiration? Smile
Re: Automatic handling of errors/warnings [message #1040570 is a reply to message #1040341] Sat, 13 April 2013 20:40 Go to previous message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
On 2013-13-04 14:01, Marco Naddeo wrote:
> P.S.: in cloudsmith / geppetto you use the latter of two techniques you
> indicated? if so, could you kindly tell me in that project from which
> package or classes can I take inspiration? :)

Ok, so Geppetto uses a completely different way of linking than the
built in Xtext way. It is not done with EMF References so to "correct"
something, I simply link it the way it is supposed to be linked.
Geppetto's linker kicks in after the regular linker has done its work.

Look at the Geppetto class PPLinker which is responsible for calling
the special PPResourceLinker as well as triggering comment text processing.

The PPResourceLinker that performs the actual linking is based on a
different mechanism than the regular EMF linking, but you can look at it
for inspiration and use regular EReferences instead of the special
linking that is going on in Geppetto.

Regards
- henrik
Previous Topic:Highlight certain parts in comments
Next Topic:Xtext Custom Lexer
Goto Forum:
  


Current Time: Thu Mar 28 16:17:39 GMT 2024

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

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

Back to the top