Changeset 10780 in josm for trunk/src


Ignore:
Timestamp:
2016-08-11T15:26:17+02:00 (8 years ago)
Author:
simon04
Message:

MatchFactory: check for keyword collisions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java

    r10774 r10780  
    9797    public static void addMatchFactory(MatchFactory factory) {
    9898        for (String keyword : factory.getKeywords()) {
    99             // TODO: check for keyword collisions
     99            final MatchFactory existing;
    100100            if (factory instanceof SimpleMatchFactory) {
    101                 simpleMatchFactoryMap.put(keyword, (SimpleMatchFactory) factory);
     101                existing = simpleMatchFactoryMap.put(keyword, (SimpleMatchFactory) factory);
    102102            } else if (factory instanceof UnaryMatchFactory) {
    103                 unaryMatchFactoryMap.put(keyword, (UnaryMatchFactory) factory);
     103                existing = unaryMatchFactoryMap.put(keyword, (UnaryMatchFactory) factory);
    104104            } else if (factory instanceof BinaryMatchFactory) {
    105                 binaryMatchFactoryMap.put(keyword, (BinaryMatchFactory) factory);
     105                existing = binaryMatchFactoryMap.put(keyword, (BinaryMatchFactory) factory);
    106106            } else
    107107                throw new AssertionError("Unknown match factory");
     108            if (existing != null) {
     109                Main.warn("SearchCompiler: for key ''{0}'', overriding match factory ''{1}'' with ''{2}''", keyword, existing, factory);
     110            }
    108111        }
    109112    }
Note: See TracChangeset for help on using the changeset viewer.