Changeset 18281 in josm for trunk/src/org


Ignore:
Timestamp:
2021-10-17T12:00:02+02:00 (3 years ago)
Author:
GerdP
Message:

fix #21438: NPE in AutoCompletionManager.getAllForKeys()

  • fix regression introduced with r18277
Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java

    r18277 r18281  
    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();
     
    559559     * @return {@code true} if the given key is in internal presets
    560560     * @since 9023
    561      */
     561     * @deprecated Use {@link TaggingPresets#isKeyInPresets(String)} instead
     562     */
     563    @Deprecated
    562564    public static boolean isKeyInPresets(String key) {
    563         return !Utils.isEmpty(TaggingPresets.getPresetValues(key));
     565        return TaggingPresets.isKeyInPresets(key);
    564566    }
    565567
     
    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)) {
     
    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))) {
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresets.java

    r18277 r18281  
    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     *
Note: See TracChangeset for help on using the changeset viewer.