Closed javierfernandes closed 7 years ago
org.antlr.runtime.RecognitionException
* To avoid English-only error messages and to generally make things
* as flexible as possible, these exceptions are not created with strings,
* but rather the information necessary to generate an error. Then
* the various reporting methods in Parser and Lexer can be overridden
* to generate a localized error message. For example, MismatchedToken
At xtext level
org.eclipse.xtext.parser.antlr.ISyntaxErrorMessageProvider.IErrorContext
And more specifically to customize messages at xtext level
/**
* A {@link ISyntaxErrorMessageProvider} can be used to customize the error messages
* that the parser attaches to syntax errors.
*
* Implementors should extends the {@link SyntaxErrorMessageProvider} rather than implementing
* the interface directly.
*
* @author Sebastian Zarnekow - Initial contribution and API
* @noimplement This interface is not intended to be implemented by clients.
*/
@ImplementedBy(SyntaxErrorMessageProvider.class)
public interface ISyntaxErrorMessageProvider {
In org.uqbar.project.wollok.WollokDslRuntimeModule add
binder.bind(ISyntaxErrorMessageProvider.class).to(WollokSyntaxErrorMessageProvider.class);
Then customize
class WollokSyntaxErrorMessageProvider extends SyntaxErrorMessageProvider {
override getSyntaxErrorMessage(IParserErrorContext context) {
println("************** ERROR: " + context.getDefaultMessage())
println("************** ERROR CURRENT CONTEXT: " + context.currentContext)
println("************** ERROR CURRENT CONTEXT: " + context.currentNode.text)
super.getSyntaxErrorMessage(context)
}
}
This is great news!
On Sun, Sep 4, 2016 at 7:36 PM, javierfernandes notifications@github.com wrote:
In org.uqbar.project.wollok.WollokDslRuntimeModule add
binder.bind(ISyntaxErrorMessageProvider.class).to(WollokSyntaxErrorMessageProvider.class);
Then customize
class WollokSyntaxErrorMessageProvider extends SyntaxErrorMessageProvider {
override getSyntaxErrorMessage(IParserErrorContext context) { println("************** ERROR: " + context.getDefaultMessage()) println("************** ERROR CURRENT CONTEXT: " + context.currentContext) println("************** ERROR CURRENT CONTEXT: " + context.currentNode.text) super.getSyntaxErrorMessage(context) }
}
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/uqbar-project/wollok/issues/350#issuecomment-244616738, or mute the thread https://github.com/notifications/unsubscribe-auth/AEa1OS60y2iMfZaxCuO9FQVZBU_leNhXks5qmwGtgaJpZM4GTv9W .
Just found the point in the code. Now Im not sure how in the hell we could code a logic to enhance those errors heje
El Monday, September 5, 2016, Nico Passerini notifications@github.com escribió:
This is great news!
On Sun, Sep 4, 2016 at 7:36 PM, javierfernandes <notifications@github.com javascript:_e(%7B%7D,'cvml','notifications@github.com');> wrote:
In org.uqbar.project.wollok.WollokDslRuntimeModule add
binder.bind(ISyntaxErrorMessageProvider.class).to( WollokSyntaxErrorMessageProvider.class);
Then customize
class WollokSyntaxErrorMessageProvider extends SyntaxErrorMessageProvider {
override getSyntaxErrorMessage(IParserErrorContext context) { println("****** ERROR: " + context.getDefaultMessage()) println("****** ERROR CURRENT CONTEXT: " + context.currentContext) println("****** ERROR CURRENT CONTEXT: " + context.currentNode.text) super.getSyntaxErrorMessage(context) }
}
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/uqbar-project/wollok/issues/350# issuecomment-244616738, or mute the thread https://github.com/notifications/unsubscribe-auth/ AEa1OS60y2iMfZaxCuO9FQVZBU_leNhXks5qmwGtgaJpZM4GTv9W .
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/uqbar-project/wollok/issues/350#issuecomment-244705146, or mute the thread https://github.com/notifications/unsubscribe-auth/AEORWC8hm3xlmf00sJgRIjdTWIBAEorHks5qm-RqgaJpZM4GTv9W .
maybe another issue for a newbie to learn
This was already achieved: now you have a class WollokSyntaxErrorMessageProvider, so I'm closing this issue.
We must see how to customise this xtext messages