|
|
Re: Stop lexing and parsing at first error? [message #646491 is a reply to message #646452] |
Sat, 25 December 2010 13:34 |
Andreas Semt Messages: 3 Registered: December 2010 |
Junior Member |
|
|
Hello Alexander,
Quote: | why would you want that (i.e. what do you want to achieve)?
|
The problem I see is, that a user of the DSL in the editor makes one single error (for example forgetting to type a required symbol) and gets a whole bunch of markers shown, indicating other, unrelated errors. That behavior is IMHO not very user friendly, especially for untrained users.
So why not:
- stop the lexing and parsing process at the first error,
- show only this single error to the user,
- let the user correct this error,
- restart the lexing and parsing process.
Quote: | If you are in an editor context, you often have partial models and losing all functionality because of a single parse error is not very user friendly.
|
Perhaps you are right, however two much shown subsequent errors caused by a single 'real' error may be to much information to handle for an untrained user.
Best regards,
Andreas Semt
|
|
|
|
|
|
Re: Stop lexing and parsing at first error? [message #646847 is a reply to message #646626] |
Sat, 01 January 2011 11:43 |
Alexander Nittka Messages: 1193 Registered: July 2009 |
Senior Member |
|
|
Hi,
sorry, an answer from a couple of das ago seems not to have made it, so
here it is again (somewhat condensed).
1. Stopping lexing does not make sense.
2. What is the parser supposed to do with the document that remains
unparsed after the first error.
3. Creating the markers should cause a performance problem, so the
document could be parsed completely and all errors created, but you
don't show them all.
(If this is not correct in your case, file an enhancement request
containing a reproducible example)
In order to achieve the "filtering" of the errors, I did the following
in a sample project. Bind my own XtextResource implementation in the
RuntimeModule:
@Override
public Class<? extends XtextResource> bindXtextResource() {
return MyXtextResource.class;
}
override the getError method in that implementation removing every but
the first error
@Override
public EList<Diagnostic> getErrors() {
EList<Diagnostic> result = super.getErrors();
if(result!=null &&result.size()>1){
for (int i = 1; i < result.size(); i++) {
result.remove(i);
}
}
return result;
}
Maybe something similar is working for you as well.
Alex
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
|
|
|
Powered by
FUDForum. Page generated in 0.03881 seconds