Changeset 14990 in josm for trunk/src


Ignore:
Timestamp:
2019-04-14T17:29:33+02:00 (6 years ago)
Author:
GerdP
Message:

see #17567: improve messages created by RelationChecker

  • new error code 1709 for " Type {0} of relation member with role {1} does not match accepted types {2} in preset {3}"
  • role type -> role
  • replace template by preset where appropriate
  • adapt unit test and improve speed
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/RelationChecker.java

    r14968 r14990  
    4040
    4141    // CHECKSTYLE.OFF: SingleSpaceSeparator
    42     /** Role {0} unknown in templates {1} */
     42    /** Role ''{0}'' is not in templates ''{1}'' */
    4343    public static final int ROLE_UNKNOWN     = 1701;
    44     /** Empty role type found when expecting one of {0} */
     44    /** Empty role found when expecting one of ''{0}'' */
    4545    public static final int ROLE_EMPTY       = 1702;
    46     /** Role member does not match expression {0} in template {1} */
    47     public static final int WRONG_TYPE       = 1703;
    48     /** Number of {0} roles too high ({1}) */
     46    /** Role of relation member does not match template expression ''{0}'' in preset {1} */
     47    public static final int WRONG_ROLE       = 1708;
     48    /** Number of ''{0}'' roles too high ({1}) */
    4949    public static final int HIGH_COUNT       = 1704;
    50     /** Number of {0} roles too low ({1}) */
     50    /** Number of ''{0}'' roles too low ({1}) */
    5151    public static final int LOW_COUNT        = 1705;
    52     /** Role {0} missing */
     52    /** Role ''{0}'' missing */
    5353    public static final int ROLE_MISSING     = 1706;
    5454    /** Relation type is unknown */
     
    5656    /** Relation is empty */
    5757    public static final int RELATION_EMPTY   = 1708;
     58    /** Type ''{0}'' of relation member with role ''{1}'' does not match accepted types ''{2}'' in preset {3} */
     59    public static final int WRONG_TYPE       = 1709;
    5860    // CHECKSTYLE.ON: SingleSpaceSeparator
    5961
     
    211213        String role = member.getRole();
    212214        String name = null;
    213         // Set of all accepted types in template
     215        // Set of all accepted types in preset
    214216        Collection<TaggingPresetType> types = EnumSet.noneOf(TaggingPresetType.class);
    215217        TestError possibleMatchError = null;
     
    242244                            // possible match error
    243245                            // we still need to iterate further, as we might have
    244                             // different present, for which memberExpression will match
     246                            // different preset, for which memberExpression will match
    245247                            // but stash the error in case no better reason will be found later
    246                             possibleMatchError = TestError.builder(this, Severity.WARNING, WRONG_TYPE)
     248                            possibleMatchError = TestError.builder(this, Severity.WARNING, WRONG_ROLE)
    247249                                    .message(ROLE_VERIF_PROBLEM_MSG,
    248                                             marktr("Role of relation member does not match expression ''{0}'' in template {1}"),
     250                                            marktr("Role of relation member does not match template expression ''{0}'' in preset {1}"),
    249251                                            r.memberExpression, name)
    250252                                    .primitives(member.getMember().isUsable() ? member.getMember() : n)
     
    280282                errors.add(TestError.builder(this, Severity.WARNING, WRONG_TYPE)
    281283                        .message(ROLE_VERIF_PROBLEM_MSG,
    282                             marktr("Type ''{0}'' of relation member with role ''{1}'' does not match accepted types ''{2}'' in template {3}"),
     284                            marktr("Type ''{0}'' of relation member with role ''{1}'' does not match accepted types ''{2}'' in preset {3}"),
    283285                            member.getType(), member.getRole(), typesStr, name)
    284286                        .primitives(member.getMember().isUsable() ? member.getMember() : n)
     
    293295     * @param n relation to validate
    294296     * @param allroles contains presets for specified relation
    295      * @param map contains statistics of occurrences of specified role types in relation
     297     * @param map contains statistics of occurrences of specified role in relation
    296298     */
    297299    private void checkRoles(Relation n, Map<Role, String> allroles, Map<String, RoleInfo> map) {
     
    333335                } else {
    334336                    errors.add(TestError.builder(this, Severity.WARNING, ROLE_EMPTY)
    335                             .message(ROLE_VERIF_PROBLEM_MSG, marktr("Empty role type found when expecting one of ''{0}''"), templates)
     337                            .message(ROLE_VERIF_PROBLEM_MSG, marktr("Empty role found when expecting one of ''{0}''"), templates)
    336338                            .primitives(n)
    337339                            .build());
Note: See TracChangeset for help on using the changeset viewer.