Changeset 6677 in josm for trunk/src/org
- Timestamp:
- 2014-01-12T23:04:43+01:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java
r6675 r6677 74 74 protected final Map<String, String> keyChange = new LinkedHashMap<String, String>(); 75 75 protected final List<String> alternatives = new ArrayList<String>(); 76 protected final Map< String, Severity> errors = new HashMap<String, Severity>();76 protected final Map<Instruction.AssignmentInstruction, Severity> errors = new HashMap<Instruction.AssignmentInstruction, Severity>(); 77 77 protected final Map<String, Boolean> assertions = new HashMap<String, Boolean>(); 78 78 … … 131 131 if (ai.key.startsWith("throw")) { 132 132 final Severity severity = Severity.valueOf(ai.key.substring("throw".length()).toUpperCase()); 133 check.errors.put( val, severity);133 check.errors.put(ai, severity); 134 134 } else if ("fixAdd".equals(ai.key)) { 135 135 final PrimitiveToTag toTag = PrimitiveToTag.ofMapCSSObject(ai.val, false); … … 296 296 cmds.add(new ChangePropertyKeyCommand(p, oldKey, newKey)); 297 297 } 298 return new SequenceCommand(tr("Fix of {0}", getDescriptionForMatchingSelector( matchingSelector)), cmds);298 return new SequenceCommand(tr("Fix of {0}", getDescriptionForMatchingSelector(p, matchingSelector)), cmds); 299 299 } 300 300 … … 304 304 * @return a message 305 305 */ 306 String getMessage() { 307 return errors.isEmpty() ? null : errors.keySet().iterator().next(); 306 String getMessage(OsmPrimitive p) { 307 if (errors.isEmpty()) { 308 return null; 309 } else { 310 final Object val = errors.keySet().iterator().next().val; 311 return String.valueOf( 312 val instanceof Expression 313 ? ((Expression) val).evaluate(new Environment().withPrimitive(p)) 314 : val 315 ); 316 } 308 317 } 309 318 … … 312 321 * 313 322 * @return a description (possibly with alternative suggestions) 314 * @see #getDescriptionForMatchingSelector (Selector)315 */ 316 String getDescription( ) {323 * @see #getDescriptionForMatchingSelector 324 */ 325 String getDescription(OsmPrimitive p) { 317 326 if (alternatives.isEmpty()) { 318 return getMessage( );327 return getMessage(p); 319 328 } else { 320 329 /* I18N: {0} is the test error message and {1} is an alternative */ 321 return tr("{0}, use {1} instead", getMessage( ), Utils.join(tr(" or "), alternatives));330 return tr("{0}, use {1} instead", getMessage(p), Utils.join(tr(" or "), alternatives)); 322 331 } 323 332 } … … 329 338 * @return a description (possibly with alternative suggestions) 330 339 */ 331 String getDescriptionForMatchingSelector( Selector matchingSelector) {332 return insertArguments(matchingSelector, getDescription( ));340 String getDescriptionForMatchingSelector(OsmPrimitive p, Selector matchingSelector) { 341 return insertArguments(matchingSelector, getDescription(p)); 333 342 } 334 343 … … 339 348 @Override 340 349 public String toString() { 341 return getDescription( );350 return getDescription(null); 342 351 } 343 352 … … 355 364 if (matchingSelector != null && !errors.isEmpty()) { 356 365 final Command fix = fixPrimitive(p); 357 final String description = getDescriptionForMatchingSelector( matchingSelector);366 final String description = getDescriptionForMatchingSelector(p, matchingSelector); 358 367 if (fix != null) { 359 368 return new FixableTestError(null, getSeverity(), description, null, matchingSelector.toString(), 3000, p, fix); -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java
r6615 r6677 468 468 * and the subsequent arguments are parameters for the string indicated by {@code {0}}, {@code {1}}, … 469 469 */ 470 @NullableArguments 470 471 public static String tr(String... args) { 471 472 final String text = args[0];
Note:
See TracChangeset
for help on using the changeset viewer.