viatra / EMF-IncQuery

This repository is only kept for historic reasons. All development happens on eclipse.org
http://eclipse.org/viatra
13 stars 4 forks source link

Some patterns with certain validator warnings cannot be activated #383

Closed istvanrath closed 11 years ago

istvanrath commented 11 years ago

While playing with patterns that have a warning due to the cartesian product validator, I discovered that some of them cannot be activated on instance models due to an NPE:

!ENTRY org.eclipse.incquery.tooling.ui 4 0 2013-01-13 10:44:38.688
!MESSAGE Cannot initialize pattern matcher for pattern network.PersonPair
!STACK 0
java.lang.NullPointerException
    at org.eclipse.xtext.validation.DiagnosticConverterImpl.getCauser(DiagnosticConverterImpl.java:103)
    at org.eclipse.xtext.validation.DiagnosticConverterImpl.getLocationData(DiagnosticConverterImpl.java:118)
    at org.eclipse.xtext.validation.DiagnosticConverterImpl.convertValidatorDiagnostic(DiagnosticConverterImpl.java:75)
    at org.eclipse.incquery.patternlanguage.emf.validation.PatternSetValidator.validate(PatternSetValidator.java:70)
    at org.eclipse.incquery.runtime.internal.PatternSanitizer.admit(PatternSanitizer.java:119)
    at org.eclipse.incquery.runtime.internal.PatternSanitizer.admit(PatternSanitizer.java:74)
    at org.eclipse.incquery.runtime.api.impl.BaseMatcher.checkPattern(BaseMatcher.java:70)

After some investigation, I found the following problems that might lead to the root cause:

Note: this is a very serious problem as currently 0.7.0 is entirely unusable with such patterns.

istvanrath commented 11 years ago

perhaps @ujhelyiz 's latest changes about validation mechanisms have something to do with this issue too.

ujhelyiz commented 11 years ago

The validation changes I did should not change the cartesian validators... Passing null should not cause this issue, as in this case it is assumed, the entire EObject is faulty instead of a specified feature.

This is almost certainly not a dependency injection issue - the contents of the Diagnostics are not selected via DI; on the other hand, there are two different diagnostics at work here (one for parse errors and one for validations).

@istvanrath Questions for clarification:

istvanrath commented 11 years ago

@ujhelyiz The issue can be reproduced deterministically with Janos Bali's example on his instance models (uncomment the pattern defs and try with PersonPair and NotFriends:

pattern PersonPair(person1: Person, person2: Person) = {
    person1 != person2; 
}
pattern NotFriends(person: Person, friend: Person) = {
    neg find PersonFriends(person, friend);
}
ujhelyiz commented 11 years ago

Ok, that was a stupid mistake. The cause of the issue was that at one place I mistakenly used the DiagnosticsChain of EValidators instead of a single Diagnostics (the child elements of the chain). There was no compile issue, as the Chain implements the Diagnostics interface.

Should be fixed now.

istvanrath commented 11 years ago

Fixed.