Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to disable error message from Composite EValidator
How to disable error message from Composite EValidator [message #1754273] Thu, 16 February 2017 03:03 Go to next message
chris yo is currently offline chris yoFriend
Messages: 146
Registered: February 2013
Senior Member
I am getting this error message whenever there is an invalid cross-reference configuration.

1    [main] ERROR text.validation.CompositeEValidator  - Error executing EValidator
java.lang.NullPointerException
	at org.prscDeveloper.impl.TestImpl.getSName(Unknown Source)
	at org.prscDeveloper.impl.TestImpl.eIsSet(Unknown Source)
	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eIsSet(BasicEObjectImpl.java:1241)
	at org.eclipse.emf.ecore.util.EObjectValidator.validate_DataValueConforms(EObjectValidator.java:832)
	at org.eclipse.emf.ecore.util.EObjectValidator.validate_EveryDataValueConforms(EObjectValidator.java:820)
	at org.eclipse.emf.ecore.util.EObjectValidator.validate_EveryDefaultConstraint(EObjectValidator.java:363)
	at org.eclipse.emf.ecore.util.EObjectValidator$DynamicEClassValidator.validate(EObjectValidator.java:1420)
	at org.eclipse.emf.ecore.util.EObjectValidator.validate(EObjectValidator.java:333)
	at org.eclipse.xtext.validation.CompositeEValidator.validate(CompositeEValidator.java:151)
	at org.eclipse.emf.ecore.util.Diagnostician.doValidate(Diagnostician.java:171)
	at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:158)
	at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:137)
	at org.eclipse.xtext.validation.CancelableDiagnostician.validate(CancelableDiagnostician.java:39)
	at org.eclipse.emf.ecore.util.Diagnostician.doValidateContents(Diagnostician.java:181)
	at org.eclipse.xtext.validation.CancelableDiagnostician.doValidateContents(CancelableDiagnostician.java:70)
	at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:161)
	at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:137)
	at org.eclipse.xtext.validation.CancelableDiagnostician.validate(CancelableDiagnostician.java:39)
	at org.eclipse.emf.ecore.util.Diagnostician.doValidateContents(Diagnostician.java:181)
	at org.eclipse.xtext.validation.CancelableDiagnostician.doValidateContents(CancelableDiagnostician.java:70)
	at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:161)
	at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:137)
	at org.eclipse.xtext.validation.CancelableDiagnostician.validate(CancelableDiagnostician.java:39)
	at org.eclipse.emf.ecore.util.Diagnostician.doValidateContents(Diagnostician.java:181)
	at org.eclipse.xtext.validation.CancelableDiagnostician.doValidateContents(CancelableDiagnostician.java:70)
	at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:161)
	at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:137)
	at org.eclipse.xtext.validation.CancelableDiagnostician.validate(CancelableDiagnostician.java:39)
	at org.eclipse.emf.ecore.util.Diagnostician.doValidateContents(Diagnostician.java:185)
	at org.eclipse.xtext.validation.CancelableDiagnostician.doValidateContents(CancelableDiagnostician.java:70)
	at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:161)
	at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:137)
	at org.eclipse.xtext.validation.CancelableDiagnostician.validate(CancelableDiagnostician.java:39)
	at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:120)
	at org.eclipse.xtext.validation.ResourceValidatorImpl.validate(ResourceValidatorImpl.java:146)
	at org.eclipse.xtext.validation.ResourceValidatorImpl.validate(ResourceValidatorImpl.java:124)
	at org.eclipse.xtext.validation.ResourceValidatorImpl.validate(ResourceValidatorImpl.java:90)
	at org.generator.Main.runValidator(Unknown Source)
	at org.generator.Main.main(Unknown Source)


As the "Couldn't resolve reference to... " error message is already being displayed, why does this have to show up? Can I disable this?
Re: How to disable error message from Composite EValidator [message #1754275 is a reply to message #1754273] Thu, 16 February 2017 06:47 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 10786
Registered: July 2009
Senior Member
Wouldn't or be interesting why the validator crashes?
You want to prevent it from crashing or disable certain validations

Do you have any hints on how to reproduce this


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: How to disable error message from Composite EValidator [message #1754290 is a reply to message #1754275] Thu, 16 February 2017 08:50 Go to previous messageGo to next message
chris yo is currently offline chris yoFriend
Messages: 146
Registered: February 2013
Senior Member
My xcore model is this:
class Model {
	contains EObject[] greetings
}

class Greeting {
	refers Test sample
	int age
	derived String sname get {
		sample.SName
	}
}

class Test {
	String sName
	String date
}


xtext:
Model:
	greetings+=(Greeting| Test)*;
	
Greeting:
	'Hello' sample=[Test] 'age' age=INT '!';
Test:
	'Bye' sName=ID '!' 'see' 'you' date=ID';'
;



My input is:
Hello a age 1!
Bye abc! see you today;

And I get the "Couldn't resolve reference" error which was expected but it also shows this NullPointerException which is already redundant.
I am running from a runnable jar.
Re: How to disable error message from Composite EValidator [message #1754301 is a reply to message #1754290] Thu, 16 February 2017 09:29 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 10786
Registered: July 2009
Senior Member
its actually not redundant, its redundant on how you implement your sname thingy right? by making it nullsafe?

but why dont you use a op instead of a derived in your xcore?

class Greeting {
	refers Test sample
	int age
	op String getSname() {
		sample.SName
	}
}



of course you can do disable the validation completely or partially

public class CustomCompositeEValidator extends CompositeEValidator {
	
	@Override
	protected void initDefaults() {
		if (isUseEObjectValidator()) {
			this.addValidator(new EObjectValidator() {
				@Override
				public boolean validate_EveryProxyResolves(EObject eObject, DiagnosticChain diagnostics,
						Map<Object, Object> context) {
					// don't check, we have our own implementation, which creates nicer messages
					return true;
				}

				@Override
				public boolean validate_NoCircularContainment(EObject eObject, DiagnosticChain diagnostics,
						Map<Object, Object> context) {
					// don't check
					return true;
				}

				@Override
				protected boolean validate_DataValueConforms(EObject eObject, EAttribute eAttribute,
						DiagnosticChain diagnostics, Map<Object, Object> context) {
					//maybe some custom logic, maybe always, depends on the cases where you want to disable the validation
					if (1==1) return true;
					return super.validate_DataValueConforms(eObject, eAttribute, diagnostics, context);
				}
			});
		}
	}

}


def Class<? extends org.eclipse.xtext.validation.CompositeEValidator> bindCompositeEValidator() {
		return Custom CompositeEValidator
	}




Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: How to disable error message from Composite EValidator [message #1754379 is a reply to message #1754301] Fri, 17 February 2017 06:10 Go to previous messageGo to next message
chris yo is currently offline chris yoFriend
Messages: 146
Registered: February 2013
Senior Member
What exactly is the difference between derived and op? I thought that you use op when you need to do some data manipulation, but simply getting the name should be a derived method, right? Or is it because I am using the cross-reference?
Re: How to disable error message from Composite EValidator [message #1754390 is a reply to message #1754379] Fri, 17 February 2017 08:05 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 10786
Registered: July 2009
Senior Member
it seems the validator validates derived (properties) different than operations

Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Previous Topic:See all feature accesses in Xtend files using Eclipse?
Next Topic:Error: Cyclic resolution of lazy links
Goto Forum:
  


Current Time: Sat Jun 24 12:34:54 GMT 2017

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

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