Changeset 12666 in josm


Ignore:
Timestamp:
2017-08-26T15:29:22+02:00 (3 months ago)
Author:
Don-vip
Message:

see #15182 - fix #15193 - fix SearchCompiler

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

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

    r12662 r12666  
    9999
    100100            @Override
    101             public Match get(String keyword, PushbackTokenizer tokenizer) throws SearchParseError {
     101            public Match get(String keyword, boolean caseSensitive, boolean regexSearch, PushbackTokenizer tokenizer) throws SearchParseError {
    102102                switch(keyword) {
    103103                case "inview":
  • trunk/src/org/openstreetmap/josm/data/osm/search/SearchCompiler.java

    r12664 r12666  
    8484    private static Map<String, BinaryMatchFactory> binaryMatchFactoryMap = new HashMap<>();
    8585
     86    static {
     87        addMatchFactory(new CoreSimpleMatchFactory());
     88        addMatchFactory(new CoreUnaryMatchFactory());
     89    }
     90
    8691    public SearchCompiler(boolean caseSensitive, boolean regexSearch, PushbackTokenizer tokenizer) {
    8792        this.caseSensitive = caseSensitive;
    8893        this.regexSearch = regexSearch;
    8994        this.tokenizer = tokenizer;
    90 
    91         // register core match factories at first instance, so plugins should never be able to generate a NPE
    92         if (simpleMatchFactoryMap.isEmpty()) {
    93             addMatchFactory(new CoreSimpleMatchFactory());
    94         }
    95         if (unaryMatchFactoryMap.isEmpty()) {
    96             addMatchFactory(new CoreUnaryMatchFactory());
    97         }
    9895    }
    9996
     
    119116    }
    120117
    121     public class CoreSimpleMatchFactory implements SimpleMatchFactory {
     118    public static class CoreSimpleMatchFactory implements SimpleMatchFactory {
    122119        private final Collection<String> keywords = Arrays.asList("id", "version", "type", "user", "role",
    123120                "changeset", "nodes", "ways", "tags", "areasize", "waylength", "modified", "deleted", "selected",
     
    126123
    127124        @Override
    128         public Match get(String keyword, PushbackTokenizer tokenizer) throws SearchParseError {
     125        public Match get(String keyword, boolean caseSensitive, boolean regexSearch, PushbackTokenizer tokenizer) throws SearchParseError {
    129126            switch(keyword) {
    130127            case "modified":
     
    248245
    249246    public interface SimpleMatchFactory extends MatchFactory {
    250         Match get(String keyword, PushbackTokenizer tokenizer) throws SearchParseError;
     247        Match get(String keyword, boolean caseSensitive, boolean regexSearch, PushbackTokenizer tokenizer) throws SearchParseError;
    251248    }
    252249
     
    17591756                SimpleMatchFactory factory = simpleMatchFactoryMap.get(key);
    17601757                if (factory != null)
    1761                     return factory.get(key, tokenizer);
     1758                    return factory.get(key, caseSensitive, regexSearch, tokenizer);
    17621759
    17631760                UnaryMatchFactory unaryFactory = unaryMatchFactoryMap.get(key);
     
    17731770                SimpleMatchFactory factory = simpleMatchFactoryMap.get(key);
    17741771                if (factory != null)
    1775                     return factory.get(key, null);
     1772                    return factory.get(key, caseSensitive, regexSearch, null);
    17761773
    17771774                UnaryMatchFactory unaryFactory = unaryMatchFactoryMap.get(key);
Note: See TracChangeset for help on using the changeset viewer.