Community
Participate
Working Groups
It seems that org.eclipse.xtext.validation.DiagnosticConverterImpl.getLocationData(Diagnostic) doesn't respect the specification of 'index' in org.eclipse.xtext.validation.ValidationMessageAcceptor.acceptError(String, EObject, EStructuralFeature, int, String, String...), where it says: * @param index the index of the erroneous value or <code>-1</code> if all values are considered to be invalid. The index is ignored if * the feature is null or the feature is a single value feature. I was trying to use a value of -1 to mark all elements in a list as erroneous (in my case: for a validation saying that the number of elements is wrong). The logic in getLocationData(), however, converts this -1 back into 0 and then just uses the first node in the list. We already have the list of nodes in hands, so one only needs to extract the range from first to last, in order to get the desired IssueLocation.
can be reproduced
I guess that's more a multiplicity problem here. If your grammar is like Foo: bars+=Bar 'lots' 'of' 'other' 'Stuff' bars+=Bar; it may not be acceptable to mark everything between the first and the last Bar as erroneous. Shouldn't we rather create a diagnostic for each element in the list?
(In reply to Jan Koehnlein from comment #2) > I guess that's more a multiplicity problem here. > > If your grammar is like > > Foo: > bars+=Bar 'lots' 'of' 'other' 'Stuff' bars+=Bar; > > it may not be acceptable to mark everything between the first and the last > Bar as erroneous. Shouldn't we rather create a diagnostic for each element > in the list? Technically you're correct, but I'd argue that your example is a corner case and in the majority of cases lists are contiguous and it would be much preferable to issue just one diagnostic from start to end. Just think of a dozen of bars on the same source line and how the hover on the error annotation in the rule would repeat the same information a dozen times. When checking if a list is contiguous I actually wouldn't consider unassigned keywords as interruption to avoid that already a separator (',' or such) forces splitting. Only assignments should count IMHO.