Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 10:54 Go to next message
Alexey Romanov is currently offline Alexey RomanovFriend
Messages: 263
Registered: May 2010
Senior Member
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] Tue, 29 March 2016 03:21 Go to previous messageGo to next message
Larry LeBron is currently offline Larry LeBronFriend
Messages: 124
Registered: October 2015
Senior Member
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] Tue, 29 March 2016 03:58 Go to previous messageGo to next message
Anton Kosyakov is currently offline Anton KosyakovFriend
Messages: 9
Registered: March 2016
Junior Member
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)


Get professional support from the Xtext committers at www.typefox.io.
Re: Adding validation errors (and handling exceptions) in JvmModelInferrer [message #1727949 is a reply to message #1727884] Tue, 29 March 2016 16:57 Go to previous message
Larry LeBron is currently offline Larry LeBronFriend
Messages: 124
Registered: October 2015
Senior Member
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: Fri Apr 19 02:58:43 GMT 2024

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

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

Back to the top