Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Modify error message from IResourceValidator
Modify error message from IResourceValidator [message #1754033] Mon, 13 February 2017 22:09 Go to next message
Eclipse UserFriend
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] Mon, 13 February 2017 23:05 Go to previous messageGo to next message
Eclipse UserFriend
The extension point is ILinkingDiagnosticMessageProvider
Re: Modify error message from IResourceValidator [message #1754044 is a reply to message #1754034] Tue, 14 February 2017 01:59 Go to previous messageGo to next message
Eclipse UserFriend
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 02:24 Go to previous messageGo to next message
Eclipse UserFriend
why not simply

def Class<? extends ILinkingDiagnosticMessageProvider> bindILinkingDiagnosticMessageProvider() {
return CustomDiagnostic
}
Re: Modify error message from IResourceValidator [message #1754058 is a reply to message #1754048] Tue, 14 February 2017 03:26 Go to previous message
Eclipse UserFriend
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: Fri Jul 04 11:25:04 EDT 2025

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

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

Back to the top