Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Adding validation errors (and handling exceptions) in JvmModelInferrer
Adding validation errors (and handling exceptions) in JvmModelInferrer [message #937891] Tue, 09 October 2012 06:54 Go to next message
Eclipse UserFriend
How can I add validation errors found while trying to infer the JVM model (after cross-indexing, so they can't be checked in the validator)? I've tried injecting first ValidationMessageAcceptor (which couldn't be found) and then IDLJavaValidator. But it inherits this implementation from AbstractDeclarativeValidator:
	public void acceptError(String message, EObject object, EStructuralFeature feature, int index, String code, String... issueData) {
		this.state.get().hasErrors = true;
		state.get().chain.add(createDiagnostic(Severity.ERROR, message, object, feature, index, code, issueData));
	}

and state.get() returns null. While I've found I could initialize the state threadLocal by doing validation.setMessageAcceptor(validation).getState() 1) this is obviously wrong Smile 2) it still didn't work because state.get().chain was null.

So is there a proper mechanism for reporting errors from inferring the model?
Re: Adding validation errors (and handling exceptions) in JvmModelInferrer [message #1727883 is a reply to message #937891] Mon, 28 March 2016 23:21 Go to previous messageGo to next message
Eclipse UserFriend
I have this same question, which appears was never answered.

My JvmModelInferrer calls certain methods (e.g. reflection on Java classes), which may discover that the EObject being inferred is invalid.

Right now, I detect this error in the JvmModelInferrer and bypass inferring for that object.

Then, during validation, I run the same tests again, which discover the error and report it.

Is there a better way to do this, which will eliminate the redundant testing? (e.g. by reporting the error directly from the jvmModelInferrer as suggested by the original poster?)
Re: Adding validation errors (and handling exceptions) in JvmModelInferrer [message #1727884 is a reply to message #1727883] Mon, 28 March 2016 23:58 Go to previous messageGo to next message
Eclipse UserFriend
You can add an instance of EObjectDiagnosticImpl directly to errors or warnings of a resource:
resource.errors += new EObjectDiagnosticImpl(severity, code, msg, object, feature, index, data)
Re: Adding validation errors (and handling exceptions) in JvmModelInferrer [message #1727949 is a reply to message #1727884] Tue, 29 March 2016 12:57 Go to previous message
Eclipse UserFriend
This seems like exactly what I'm looking for. Thanks!
Previous Topic:Missing xmi file. What is it? Where should it come from?
Next Topic:RPG, RPGLE and RPG Free Format
Goto Forum:
  


Current Time: Tue Jul 08 01:07:47 EDT 2025

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

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

Back to the top