Changeset 12042 in josm for trunk/src/org/openstreetmap/josm/data
- Timestamp:
- 2017-05-03T11:19:04+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java
r11942 r12042 69 69 /** Normalized keys: the key should be substituted by the value if the key was not found in presets */ 70 70 private static final Map<String, String> harmonizedKeys = new HashMap<>(); 71 /** The spell check preset values */72 private static volatile MultiMap<String, String> presetsValueData;71 /** The spell check preset values which are not stored in TaggingPresets */ 72 private static volatile MultiMap<String, String> additionalPresetsValueData; 73 73 /** The TagChecker data */ 74 74 private static final List<CheckerData> checkerData = new ArrayList<>(); … … 259 259 Collection<TaggingPreset> presets = TaggingPresets.getTaggingPresets(); 260 260 if (!presets.isEmpty()) { 261 presetsValueData = new MultiMap<>();261 additionalPresetsValueData = new MultiMap<>(); 262 262 for (String a : OsmPrimitive.getUninterestingKeys()) { 263 presetsValueData.putVoid(a);263 additionalPresetsValueData.putVoid(a); 264 264 } 265 265 // TODO directionKeys are no longer in OsmPrimitive (search pattern is used instead) 266 266 for (String a : Main.pref.getCollection(ValidatorPreference.PREFIX + ".knownkeys", 267 267 Arrays.asList(new String[]{"is_in", "int_ref", "fixme", "population"}))) { 268 presetsValueData.putVoid(a);268 additionalPresetsValueData.putVoid(a); 269 269 } 270 270 for (TaggingPreset p : presets) { … … 285 285 Collection<String> values = ky.getValues(); 286 286 if (ky.key != null && values != null) { 287 presetsValueData.putAll(ky.key, values);288 287 harmonizedKeys.put(harmonizeKey(ky.key), ky.key); 289 288 } … … 305 304 } 306 305 306 private static Set<String> getPresetValues(String key) { 307 Set<String> res = TaggingPresets.getPresetValues(key); 308 if (res != null) 309 return res; 310 return additionalPresetsValueData.get(key); 311 } 312 307 313 /** 308 314 * Determines if the given key is in internal presets. … … 312 318 */ 313 319 public static boolean isKeyInPresets(String key) { 314 return presetsValueData.get(key) != null;320 return getPresetValues(key) != null; 315 321 } 316 322 … … 323 329 */ 324 330 public static boolean isTagInPresets(String key, String value) { 325 final Set<String> values = presetsValueData.get(key);331 final Set<String> values = getPresetValues(key); 326 332 return values != null && (values.isEmpty() || values.contains(value)); 327 333 } … … 462 468 withErrors.put(p, "HTML"); 463 469 } 464 if (checkValues && key != null && value != null && !value.isEmpty() && presetsValueData != null && !isTagIgnored(key, value)) { 470 if (checkValues && key != null && value != null && !value.isEmpty() && additionalPresetsValueData != null 471 && !isTagIgnored(key, value)) { 465 472 if (!isKeyInPresets(key)) { 466 473 String prettifiedKey = harmonizeKey(key); … … 487 494 // try to fix common typos and check again if value is still unknown 488 495 String fixedValue = harmonizeValue(prop.getValue()); 489 Map<String, String> possibleValues = getPossibleValues( presetsValueData.get(key));496 Map<String, String> possibleValues = getPossibleValues(getPresetValues(key)); 490 497 if (possibleValues.containsKey(fixedValue)) { 491 498 final String newKey = possibleValues.get(fixedValue);
Note:
See TracChangeset
for help on using the changeset viewer.