Changeset 15980 in josm


Ignore:
Timestamp:
2020-03-01T23:35:49+01:00 (4 years ago)
Author:
simon04
Message:

see #18802 - MapCSSTagChecker: simplify throwError/throwWarning/throwOther parsing

File:
1 edited

Legend:

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

    r15979 r15980  
    1818import java.util.LinkedList;
    1919import java.util.List;
    20 import java.util.Locale;
    2120import java.util.Map;
    2221import java.util.Objects;
     
    302301        }
    303302
    304         private static final String POSSIBLE_THROWS = possibleThrows();
    305 
    306         static final String possibleThrows() {
    307             StringBuilder sb = new StringBuilder();
    308             for (Severity s : Severity.values()) {
    309                 if (sb.length() > 0) {
    310                     sb.append('/');
    311                 }
    312                 sb.append("throw")
    313                 .append(s.name().charAt(0))
    314                 .append(s.name().substring(1).toLowerCase(Locale.ENGLISH));
    315             }
    316             return sb.toString();
    317         }
     303        private static final String POSSIBLE_THROWS = "throwError/throwWarning/throwOther";
    318304
    319305        static TagCheck ofMapCSSRule(final GroupedMapCSSRule rule) throws IllegalDataException {
     
    335321                                ? ((Keyword) ai.val).val
    336322                                : null;
    337                         if (ai.key.startsWith("throw")) {
    338                             try {
    339                                 check.errors.put(ai, Severity.valueOf(ai.key.substring("throw".length()).toUpperCase(Locale.ENGLISH)));
    340                             } catch (IllegalArgumentException e) {
    341                                 Logging.log(Logging.LEVEL_WARN,
    342                                         "Unsupported "+ai.key+" instruction. Allowed instructions are "+POSSIBLE_THROWS+'.', e);
    343                             }
     323                        if ("throwError".equals(ai.key)) {
     324                            check.errors.put(ai, Severity.ERROR);
     325                        } else if ("throwWarning".equals(ai.key)) {
     326                            check.errors.put(ai, Severity.WARNING);
     327                        } else if ("throwOther".equals(ai.key)) {
     328                            check.errors.put(ai, Severity.OTHER);
     329                        } else if (ai.key.startsWith("throw")) {
     330                            Logging.log(Logging.LEVEL_WARN,
     331                                    "Unsupported " + ai.key + " instruction. Allowed instructions are " + POSSIBLE_THROWS + '.', null);
    344332                        } else if ("fixAdd".equals(ai.key)) {
    345333                            check.fixCommands.add(FixCommand.fixAdd(ai.val));
Note: See TracChangeset for help on using the changeset viewer.