Ticket #21438: 21438-TagChecker-2.patch

File 21438-TagChecker-2.patch, 3.0 KB (added by GerdP, 5 years ago)
  • src/org/openstreetmap/josm/data/validation/tests/TagChecker.java

     
    544544     *  else a set which might be empty.
    545545     */
    546546    private static Set<String> getPresetValues(String key) {
    547         Set<String> res = TaggingPresets.getPresetValues(key);
    548         if (!Utils.isEmpty(res))
    549             return res;
     547        if (TaggingPresets.isKeyInPresets(key)) {
     548            return TaggingPresets.getPresetValues(key);
     549        }
    550550        if (additionalPresetsValueData.contains(key))
    551551            return Collections.emptySet();
    552552        // null means key is not known
     
    558558     * @param key key
    559559     * @return {@code true} if the given key is in internal presets
    560560     * @since 9023
     561     * @deprecated Use {@link TaggingPresets#isKeyInPresets(String)} instead
    561562     */
     563    @Deprecated
    562564    public static boolean isKeyInPresets(String key) {
    563         return !Utils.isEmpty(TaggingPresets.getPresetValues(key));
     565        return TaggingPresets.isKeyInPresets(key);
    564566    }
    565567
    566568    /**
     
    882884        if (!checkValues || key == null || Utils.isEmpty(value))
    883885            return;
    884886        if (additionalPresetsValueData != null && !isTagIgnored(key, value)) {
    885             if (!isKeyInPresets(key)) {
     887            if (!TaggingPresets.isKeyInPresets(key)) {
    886888                spellCheckKey(withErrors, p, key);
    887889            } else if (!isTagInPresets(key, value)) {
    888890                if (oftenUsedTags.contains(key, value)) {
     
    906908        if (ignoreDataEquals.contains(prettifiedKey)) {
    907909            fixedKey = prettifiedKey;
    908910        } else {
    909             fixedKey = isKeyInPresets(prettifiedKey) ? prettifiedKey : harmonizedKeys.get(prettifiedKey);
     911            fixedKey = TaggingPresets.isKeyInPresets(prettifiedKey) ? prettifiedKey : harmonizedKeys.get(prettifiedKey);
    910912        }
    911913        if (fixedKey == null && ignoreDataTag.stream().anyMatch(a -> a.getKey().equals(prettifiedKey))) {
    912914            fixedKey = prettifiedKey;
  • src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresets.java

     
    214214    }
    215215
    216216    /**
     217     * Determines if the given key is in the loaded presets.
     218     * @param key key
     219     * @return {@code true} if the given key in the loaded presets
     220     * @since xxx
     221     */
     222    public static boolean isKeyInPresets(String key) {
     223        return PRESET_TAG_CACHE.get(key) != null;
     224    }
     225
     226    /**
    217227     * Replies a new collection of all presets matching the parameters.
    218228     *
    219229     * @param t the preset types to include