Community
Participate
Working Groups
In some cases, it is effective to be able to set more than one validation/check issue from a method. Right now Sphinx only supports setting the issue from the annotation. This code would go in AbstractCheckValidator and then it would be possible for the programmer to set any constraint issue. (This is e.g. advisable, if you have complex check that should better be written for the container than for the parameter values). It is basically the same code, only with passing constraint as 1st argument. def void issue(String constraint, Object object, EStructuralFeature feature, Object... messageArguments) { if (object instanceof IWrapper<?>) { val eObject = ( object as IWrapper<?>).getTarget(); issue(constraint, eObject, feature, -1, messageArguments); } else if (object instanceof EObject) { issue(constraint, object as EObject, feature, -1, messageArguments); } else { throw new UnsupportedOperationException("Could not recognize type of " + object.toString()); //$NON-NLS-1$ } } def void issue(String constraint, EObject object, EStructuralFeature feature, int index, Object... messageArguments) { val checkCatalog = getCheckCatalog(); if (checkCatalog == null) { return; } val message = MessageFormat.format(checkCatalog.getMessage(constraint), messageArguments); val severity = checkCatalog.getSeverity(constraint); switch (severity) { case ERROR: error(message, object, feature, index) case Severity.WARNING: warning(message, object, feature, index) case INFO: info(message, object, feature, index) default: throw new IllegalArgumentException("Unknow severity " + severity) //$NON-NLS-1$ } }
Closed stale issue before migration