Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Modify error message from IResourceValidator
Modify error message from IResourceValidator [message #1754033] Tue, 14 February 2017 03:09 Go to next message
chris yo is currently offline chris yoFriend
Messages: 146
Registered: February 2013
Senior Member
I am using cross-reference from xcore. If an entry does not have a valid reference, xcore will throw an error like this:
Couldn't resolve reference to Test 'trial'.


I don't want xcore to specify the grammar name 'Test' in the error message as the user does not really care about the grammar part. "Couldn't resolve reference to 'trial'" is enough for me.

How can I modify the error message that the validator is throwing?
Re: Modify error message from IResourceValidator [message #1754034 is a reply to message #1754033] Tue, 14 February 2017 04:05 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 14729
Registered: July 2009
Senior Member
The extension point is ILinkingDiagnosticMessageProvider

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Modify error message from IResourceValidator [message #1754044 is a reply to message #1754034] Tue, 14 February 2017 06:59 Go to previous messageGo to next message
chris yo is currently offline chris yoFriend
Messages: 146
Registered: February 2013
Senior Member
I created my own custom diagnostic message provider.
class CustomDiagnostic extends LinkingDiagnosticMessageProvider {
	override DiagnosticMessage getUnresolvedProxyMessage(ILinkingDiagnosticContext context) {
		val DiagnosticMessage diagnostic = super.getUnresolvedProxyMessage(context)
                String msg = "my custom msg"
		return new DiagnosticMessage(msg, diagnostic.getSeverity(),
			diagnostic.getIssueCode(), diagnostic.getIssueData())
	}
}


But when I bind it with my runtime module, I get the error saying "The method bindILinkingDiagnosticMessageProvider() must override a superclass method."

I added this in my runtime module:
	override Class<? extends ILinkingDiagnosticMessageProvider> bindILinkingDiagnosticMessageProvider() {
		return CustomDiagnostic 
	}

Re: Modify error message from IResourceValidator [message #1754048 is a reply to message #1754044] Tue, 14 February 2017 07:24 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 14729
Registered: July 2009
Senior Member
why not simply

def Class<? extends ILinkingDiagnosticMessageProvider> bindILinkingDiagnosticMessageProvider() {
return CustomDiagnostic
}


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Modify error message from IResourceValidator [message #1754058 is a reply to message #1754048] Tue, 14 February 2017 08:26 Go to previous message
chris yo is currently offline chris yoFriend
Messages: 146
Registered: February 2013
Senior Member
it works now! thanks! it did not work the first time i tried to use "def" but restarting eclipse seems to fix it.
Previous Topic:How to fix warning on bidirectional reference
Next Topic:See all feature accesses in Xtend files using Eclipse?
Goto Forum:
  


Current Time: Tue Nov 05 16:20:25 GMT 2024

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

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

Back to the top