Changeset 10710 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/data/validator/geometry.mapcss
r10530 r10710 152 152 node[tag("amenity") = parent_tag("amenity")] ∈ *[amenity][amenity != parking] { 153 153 throwWarning: tr("{0} inside {1}", concat("amenity=", tag("amenity")), concat("amenity=", tag("amenity"))); 154 group: tr("{0} inside {1}", "amenity", "amenity"); 154 155 } 155 156 node[tag("leisure") = parent_tag("leisure")] ∈ *[leisure] { 156 157 throwWarning: tr("{0} inside {1}", concat("leisure=", tag("leisure")), concat("leisure=", tag("leisure"))); 158 group: tr("{0} inside {1}", "leisure", "leisure"); 157 159 } 158 160 node[tag("tourism") = parent_tag("tourism")] ∈ *[tourism] { 159 161 throwWarning: tr("{0} inside {1}", concat("tourism=", tag("tourism")), concat("tourism=", tag("tourism"))); 162 group: tr("{0} inside {1}", "tourism", "tourism"); 160 163 } 161 164 node[tag("shop") = parent_tag("shop")] ∈ *[shop] { 162 165 throwWarning: tr("{0} inside {1}", concat("shop=", tag("shop")), concat("shop=", tag("shop"))); 166 group: tr("{0} inside {1}", "shop", "shop"); 163 167 } 164 168 node[tag("power") = parent_tag("power")] ∈ *[power] { 165 169 throwWarning: tr("{0} inside {1}", concat("power=", tag("power")), concat("power=", tag("power"))); 170 group: tr("{0} inside {1}", "power", "power"); 166 171 } 167 172 -
trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java
r10674 r10710 255 255 256 256 public static class TagCheck implements Predicate<OsmPrimitive> { 257 /** The selector of this {@code TagCheck} */ 257 258 protected final GroupedMapCSSRule rule; 259 /** Commands to apply in order to fix a matching primitive */ 258 260 protected final List<FixCommand> fixCommands = new ArrayList<>(); 261 /** Tags (or arbitraty strings) of alternatives to be presented to the user */ 259 262 protected final List<String> alternatives = new ArrayList<>(); 263 /** An {@link Instruction.AssignmentInstruction}-{@link Severity} pair. 264 * Is evaluated on the matching primitive to give the error message. Map is checked to contain exactly one element. */ 260 265 protected final Map<Instruction.AssignmentInstruction, Severity> errors = new HashMap<>(); 266 /** Unit tests */ 261 267 protected final Map<String, Boolean> assertions = new HashMap<>(); 268 /** MapCSS Classes to set on matching primitives */ 262 269 protected final Set<String> setClassExpressions = new HashSet<>(); 270 /** Denotes whether the object should be deleted for fixing it */ 263 271 protected boolean deletion; 272 /** A string used to group similar tests */ 273 protected String group; 264 274 265 275 TagCheck(GroupedMapCSSRule rule) { … … 324 334 } else if ("assertNoMatch".equals(ai.key) && val != null) { 325 335 check.assertions.put(val, Boolean.FALSE); 336 } else if ("group".equals(ai.key) && val != null) { 337 check.group = val; 326 338 } else { 327 339 throw new IllegalDataException("Cannot add instruction " + ai.key + ": " + ai.val + '!'); … … 563 575 final Command fix = fixPrimitive(p); 564 576 final String description = getDescriptionForMatchingSelector(p, matchingSelector); 577 final String description1 = group == null ? description : group; 578 final String description2 = group == null ? null : description; 565 579 final List<OsmPrimitive> primitives; 566 580 if (env.child != null) { … … 570 584 } 571 585 if (fix != null) { 572 return new FixableTestError(null, getSeverity(), description , null, matchingSelector.toString(), 3000, primitives, fix);586 return new FixableTestError(null, getSeverity(), description1, description2, matchingSelector.toString(), 3000, primitives, fix); 573 587 } else { 574 return new TestError(null, getSeverity(), description , null, matchingSelector.toString(), 3000, primitives);588 return new TestError(null, getSeverity(), description1, description2, matchingSelector.toString(), 3000, primitives); 575 589 } 576 590 } else { -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java
r10657 r10710 55 55 ParseResult result = MapCSSTagChecker.TagCheck.readMapCSS(new StringReader("" + 56 56 "*[natural=marsh] {\n" + 57 " group: tr(\"deprecated\");\n" + 57 58 " throwWarning: tr(\"{0}={1} is deprecated\", \"{0.key}\", tag(\"natural\"));\n" + 58 59 " fixRemove: \"{0.key}\";\n" + … … 72 73 n1.put("natural", "marsh"); 73 74 assertTrue(check.test(n1)); 74 assertEquals("natural=marsh is deprecated", check.getErrorForPrimitive(n1).getMessage()); 75 assertEquals("deprecated", check.getErrorForPrimitive(n1).getMessage()); 76 assertEquals("natural=marsh is deprecated", check.getErrorForPrimitive(n1).getDescription()); 75 77 assertEquals(Severity.WARNING, check.getErrorForPrimitive(n1).getSeverity()); 76 78 assertEquals("Sequence: Fix of natural=marsh is deprecated", check.fixPrimitive(n1).getDescriptionText());
Note:
See TracChangeset
for help on using the changeset viewer.