Changeset 14481 in josm for trunk


Ignore:
Timestamp:
2018-12-01T22:33:38+01:00 (7 months ago)
Author:
Don-vip
Message:

fix #17053 - ignore MapCSS declarations starting with "-" to allow external extensions (used by osmose)

Location:
trunk
Files:
3 edited

Legend:

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

    r14469 r14481  
    22package org.openstreetmap.josm.data.validation.tests;
    33
    4 import static org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.FixCommand.evaluateObject;
    54import static org.openstreetmap.josm.tools.I18n.tr;
    65
     
    491490                        } else if (val != null && "group".equals(ai.key)) {
    492491                            check.group = val;
     492                        } else if (ai.key.startsWith("-")) {
     493                            Logging.debug("Ignoring extension instruction: " + ai.key + ": " + ai.val);
    493494                        } else {
    494495                            throw new IllegalDataException("Cannot add instruction " + ai.key + ": " + ai.val + '!');
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParser.jj

    r12987 r14481  
    166166{
    167167    < IDENT: ["a"-"z","A"-"Z","_"] ( ["a"-"z","A"-"Z","_","-","0"-"9"] )* >
     168|   < EXTIDENT: <MINUS> <IDENT> >
    168169|   < UINT: ( ["0"-"9"] )+ >
    169170|   < STRING: "\"" ( [" ","!","#"-"[","]"-"~","\u0080"-"\uFFFF"] | "\\\"" | "\\\\" )*  "\"" >
     
    283284{
    284285    (
    285         (t=<PP_AND> | t=<PP_OR> | t=<PP_NOT> | t=<UINT> | t=<STRING> | t=<REGEX> | t=<LPAR> | t=<RPAR> | t=<COMMA> | t=<COLON> | t=<IDENT> | t=<PP_SOMETHING_ELSE>) { if (write) sb.append(t.image); }
     286        (t=<PP_AND> | t=<PP_OR> | t=<PP_NOT> | t=<UINT> | t=<STRING> | t=<REGEX> | t=<LPAR> | t=<RPAR> | t=<COMMA> | t=<COLON> | t=<IDENT> | t=<EXTIDENT> | t=<PP_SOMETHING_ELSE>) { if (write) sb.append(t.image); }
    286287        |
    287288            pp_w1()
     
    906907        )
    907908    |
     909        <EXTIDENT> w() <COLON> w() expression() <SEMICOLON> w()
     910    |
    908911        key=<IDENT> w() <COLON> w()
    909912        (
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java

    r14138 r14481  
    220220    }
    221221
     222    /**
     223     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/17053">Bug #17053</a>.
     224     * @throws ParseException if a parsing error occurs
     225     */
     226    @Test
     227    public void testTicket17053() throws ParseException {
     228        final MapCSSTagChecker test = buildTagChecker(
     229                "way[highway=cycleway][cycleway=track] {\n" +
     230                "   throwWarning: tr(\"{0} with {1}\", \"{0.tag}\", \"{1.tag}\");\n" +
     231                "   -osmoseItemClassLevel: \"3032/30328/2\";\n" +
     232                "   -osmoseTags: list(\"tag\", \"highway\", \"cycleway\");\n" +
     233                "   fixRemove: \"cycleway\";\n" +
     234                "}");
     235        assertEquals(1, test.checks.size());
     236        TagCheck check = test.checks.get("test").iterator().next();
     237        assertEquals(1, check.fixCommands.size());
     238        assertEquals(2, check.rule.declaration.instructions.size());
     239    }
     240
    222241    private void doTestNaturalWood(int ticket, String filename, int errorsCount, int setsCount) throws Exception {
    223242        final MapCSSTagChecker test = buildTagChecker(
Note: See TracChangeset for help on using the changeset viewer.