Context::getSnakGroup will need some refactorings to split up the statements by their separators. No idea yet what that’s going to look like.
|Resolved||Lydia_Pintscher||T173594 Add support for “separators” parameter of “single value” and “single best value” constraint types|
|Resolved||Lucas_Werkmeister_WMDE||T193634 Refactor Context::getSnakGroup|
Okay, I think the new interface could be:
- getSnakGroup is renamed to getSnakGroups.
- It gains an additional parameter, a list of property IDs (possibly empty): the separators.
- It returns not a list of snaks, but a list of SnakGroup objects. SnakGroup is a new class holding two lists of snaks: the group itself (sibling statement main snaks, other qualifiers, etc.), and the separators (the qualifiers in case of statement contexts, empty everywhere else).
The checkers can then check the cardinality of each SnakGroup returned and report an error for any group with incorrect cardinality, using the properties of the separators in the error message.
Technically, I don’t think the checkers actually need all of this information: it would probably be enough to return a list of snak lists (Snak) from getSnakGroups. But I think this will be easier to understand, test and debug if we introduce a dedicated class for the results.
Well, wait a second. Not only do the checkers not need the separating snaks… I don’t think they really need the other snak groups (other than the one that the current snak is in) either. So really – do we need to change the return type at all? Can’t we just keep it at returning the current snak group as an array? (That probably also simplifies the implementation a lot.)