Ticket #11498: patch2.diff
| File patch2.diff, 1.8 KB (added by , 11 years ago) |
|---|
-
josm/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java
420 420 } else if (!tagInPresets) { 421 421 // try to fix common typos and check again if value is still unknown 422 422 String fixedValue = prettifyValue(prop.getValue()); 423 if (values != null && values.contains(fixedValue)) { 423 HashMap<String, String> possibleValues = getPossibleValues(values); 424 if (possibleValues.containsKey(fixedValue)) { 425 fixedValue = possibleValues.get(fixedValue); 424 426 // misspelled preset value 425 427 String i = marktr("Value ''{0}'' for key ''{1}'' looks like ''{2}}."); 426 428 errors.add(new FixableTestError(this, Severity.WARNING, tr("Misspelled property value"), … … 450 452 } 451 453 } 452 454 455 private HashMap<String, String> getPossibleValues(Set<String> values) { 456 // generate a map with common typos 457 HashMap<String, String> map = new HashMap<>(); 458 if (values != null) { 459 for (String value : values) { 460 map.put(value, value); 461 if (value.contains("_")) { 462 map.put(value.replace("_", ""), value); 463 } 464 } 465 } 466 return map; 467 } 468 453 469 private static String prettifyValue(String value) { 454 470 // convert to lower case, replace ' ' or '-' with '_' 455 471 value = value.toLowerCase(Locale.ENGLISH).replace('-', '_').replace(' ', '_');
