Changeset 12656 in josm


Ignore:
Timestamp:
2017-08-26T00:40:19+02:00 (4 weeks ago)
Author:
Don-vip
Message:

see #15182 - move SearchCompiler from actions.search to data.osm.search

Location:
trunk
Files:
4 added
32 edited
4 moved

Legend:

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

    r12643 r12656  
    4646import org.openstreetmap.josm.actions.JosmAction;
    4747import org.openstreetmap.josm.actions.ParameterizedAction;
    48 import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError;
    4948import org.openstreetmap.josm.data.osm.DataSet;
    5049import org.openstreetmap.josm.data.osm.Filter;
    5150import org.openstreetmap.josm.data.osm.OsmPrimitive;
     51import org.openstreetmap.josm.data.osm.search.SearchParseError;
     52import org.openstreetmap.josm.data.osm.search.SearchCompiler;
    5253import org.openstreetmap.josm.gui.ExtendedDialog;
    5354import org.openstreetmap.josm.gui.MainApplication;
     
    380381                    SearchCompiler.compile(ss);
    381382                    return true;
    382                 } catch (ParseError | MapCSSException e) {
     383                } catch (SearchParseError | MapCSSException e) {
    383384                    return false;
    384385                }
     
    418419                        SearchCompiler.compile(ss);
    419420                        super.buttonAction(buttonIndex, evt);
    420                     } catch (ParseError e) {
     421                    } catch (SearchParseError e) {
    421422                        Logging.debug(e);
    422423                        JOptionPane.showMessageDialog(
     
    828829                }
    829830                subMonitor.finishTask();
    830             } catch (ParseError e) {
     831            } catch (SearchParseError e) {
    831832                Logging.debug(e);
    832833                JOptionPane.showMessageDialog(
  • trunk/src/org/openstreetmap/josm/data/gpx/WayPoint.java

    r12620 r12656  
    88import java.util.Objects;
    99
    10 import org.openstreetmap.josm.actions.search.SearchCompiler.Match;
    1110import org.openstreetmap.josm.data.coor.EastNorth;
    1211import org.openstreetmap.josm.data.coor.ILatLon;
    1312import org.openstreetmap.josm.data.coor.LatLon;
     13import org.openstreetmap.josm.data.osm.search.SearchCompiler.Match;
    1414import org.openstreetmap.josm.data.projection.Projecting;
    1515import org.openstreetmap.josm.tools.Logging;
  • trunk/src/org/openstreetmap/josm/data/osm/FilterMatcher.java

    r12630 r12656  
    77
    88import org.openstreetmap.josm.actions.search.SearchAction.SearchMode;
    9 import org.openstreetmap.josm.actions.search.SearchCompiler;
    10 import org.openstreetmap.josm.actions.search.SearchCompiler.Match;
    11 import org.openstreetmap.josm.actions.search.SearchCompiler.Not;
    12 import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError;
     9import org.openstreetmap.josm.data.osm.search.SearchParseError;
     10import org.openstreetmap.josm.data.osm.search.SearchCompiler;
     11import org.openstreetmap.josm.data.osm.search.SearchCompiler.Match;
     12import org.openstreetmap.josm.data.osm.search.SearchCompiler.Not;
    1313import org.openstreetmap.josm.gui.MainApplication;
    1414import org.openstreetmap.josm.gui.MapFrame;
     
    7979        private final boolean isInverted;
    8080
    81         FilterInfo(Filter filter) throws ParseError {
     81        FilterInfo(Filter filter) throws SearchParseError {
    8282            if (filter.mode == SearchMode.remove || filter.mode == SearchMode.in_selection) {
    8383                isDelete = true;
     
    9898     * Clears the current filters, and adds the given filters
    9999     * @param filters the filters to add
    100      * @throws ParseError if the search expression in one of the filters cannot be parsed
    101      */
    102     public void update(Collection<Filter> filters) throws ParseError {
     100     * @throws SearchParseError if the search expression in one of the filters cannot be parsed
     101     */
     102    public void update(Collection<Filter> filters) throws SearchParseError {
    103103        reset();
    104104        for (Filter filter : filters) {
     
    118118     * Adds a filter to the currently used filters
    119119     * @param filter the filter to add
    120      * @throws ParseError if the search expression in the filter cannot be parsed
    121      */
    122     public void add(final Filter filter) throws ParseError {
     120     * @throws SearchParseError if the search expression in the filter cannot be parsed
     121     */
     122    public void add(final Filter filter) throws SearchParseError {
    123123        if (!filter.enable) {
    124124            return;
     
    330330     * @param filters filters to add to the resulting filter matcher
    331331     * @return a new {@code FilterMatcher} containing the given filters
    332      * @throws ParseError if the search expression in a filter cannot be parsed
     332     * @throws SearchParseError if the search expression in a filter cannot be parsed
    333333     * @since 12383
    334334     */
    335     public static FilterMatcher of(Filter... filters) throws ParseError {
     335    public static FilterMatcher of(Filter... filters) throws SearchParseError {
    336336        FilterMatcher result = new FilterMatcher();
    337337        for (Filter filter : filters) {
  • trunk/src/org/openstreetmap/josm/data/osm/FilterModel.java

    r12636 r12656  
    1717
    1818import org.openstreetmap.josm.Main;
    19 import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError;
    2019import org.openstreetmap.josm.data.osm.Filter.FilterPreferenceEntry;
     20import org.openstreetmap.josm.data.osm.search.SearchParseError;
    2121import org.openstreetmap.josm.gui.MainApplication;
    2222import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     
    5252            try {
    5353                filterMatcher.add(filter);
    54             } catch (ParseError e) {
     54            } catch (SearchParseError e) {
    5555                Logging.error(e);
    5656                JOptionPane.showMessageDialog(
  • trunk/src/org/openstreetmap/josm/data/osm/FilterWorker.java

    r12388 r12656  
    55import java.util.Collections;
    66
    7 import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError;
    87import org.openstreetmap.josm.data.osm.FilterMatcher.FilterType;
     8import org.openstreetmap.josm.data.osm.search.SearchParseError;
    99import org.openstreetmap.josm.tools.SubclassFilteredCollection;
    1010
     
    2828     * @param filters the filters
    2929     * @return true, if the filter state (normal / disabled / hidden) of any primitive has changed in the process
    30      * @throws ParseError if the search expression in a filter cannot be parsed
     30     * @throws SearchParseError if the search expression in a filter cannot be parsed
    3131     * @since 12383
    3232     */
    33     public static boolean executeFilters(Collection<OsmPrimitive> all, Filter... filters) throws ParseError {
     33    public static boolean executeFilters(Collection<OsmPrimitive> all, Filter... filters) throws SearchParseError {
    3434        return executeFilters(all, FilterMatcher.of(filters));
    3535    }
  • trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

    r12620 r12656  
    2121
    2222import org.openstreetmap.josm.Main;
    23 import org.openstreetmap.josm.actions.search.SearchCompiler;
    24 import org.openstreetmap.josm.actions.search.SearchCompiler.Match;
    25 import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError;
     23import org.openstreetmap.josm.data.osm.search.SearchParseError;
     24import org.openstreetmap.josm.data.osm.search.SearchCompiler;
     25import org.openstreetmap.josm.data.osm.search.SearchCompiler.Match;
    2626import org.openstreetmap.josm.data.osm.visitor.Visitor;
    2727import org.openstreetmap.josm.gui.mappaint.StyleCache;
     
    761761        try {
    762762            return SearchCompiler.compile(Main.pref.get(prefName, defaultValue));
    763         } catch (ParseError e) {
     763        } catch (SearchParseError e) {
    764764            Logging.log(Logging.LEVEL_ERROR, "Unable to compile pattern for " + prefName + ", trying default pattern:", e);
    765765        }
     
    767767        try {
    768768            return SearchCompiler.compile(defaultValue);
    769         } catch (ParseError e2) {
     769        } catch (SearchParseError e2) {
    770770            throw new AssertionError("Unable to compile default pattern for direction keys: " + e2.getMessage(), e2);
    771771        }
  • trunk/src/org/openstreetmap/josm/data/osm/search/PushbackTokenizer.java

    r12651 r12656  
    11// License: GPL. For details, see LICENSE file.
    2 package org.openstreetmap.josm.actions.search;
     2package org.openstreetmap.josm.data.osm.search;
    33
    44import static org.openstreetmap.josm.tools.I18n.marktr;
     
    1111import java.util.Objects;
    1212
    13 import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError;
    1413import org.openstreetmap.josm.tools.JosmRuntimeException;
    1514
     
    1716 * This class is used to parse a search string and split it into tokens.
    1817 * It provides methods to parse numbers and extract strings.
     18 * @since 12656 (moved from actions.search package)
    1919 */
    2020public class PushbackTokenizer {
     
    300300     * @param errorMessage The error if the number cannot be read
    301301     * @return The number that was found
    302      * @throws ParseError if there is no number
    303      */
    304     public long readNumber(String errorMessage) throws ParseError {
     302     * @throws SearchParseError if there is no number
     303     */
     304    public long readNumber(String errorMessage) throws SearchParseError {
    305305        if ((nextToken() == Token.KEY) && (currentNumber != null))
    306306            return currentNumber;
    307307        else
    308             throw new ParseError(errorMessage);
     308            throw new SearchParseError(errorMessage);
    309309    }
    310310
     
    321321     * @param errorMessage The error if the input is malformed
    322322     * @return The range that was found
    323      * @throws ParseError If the input is not as expected for a range
    324      */
    325     public Range readRange(String errorMessage) throws ParseError {
     323     * @throws SearchParseError If the input is not as expected for a range
     324     */
     325    public Range readRange(String errorMessage) throws SearchParseError {
    326326        if (nextToken() != Token.KEY || (currentNumber == null && currentRange == null)) {
    327             throw new ParseError(errorMessage);
     327            throw new SearchParseError(errorMessage);
    328328        } else if (!isRange && currentNumber != null) {
    329329            if (currentNumber >= 0) {
     
    337337            return new Range(currentNumber, currentRange);
    338338        } else {
    339             throw new ParseError(errorMessage);
     339            throw new SearchParseError(errorMessage);
    340340        }
    341341    }
  • trunk/src/org/openstreetmap/josm/data/osm/search/SearchCompiler.java

    r12651 r12656  
    11// License: GPL. For details, see LICENSE file.
    2 package org.openstreetmap.josm.actions.search;
     2package org.openstreetmap.josm.data.osm.search;
    33
    44import static org.openstreetmap.josm.tools.I18n.marktr;
     
    2424
    2525import org.openstreetmap.josm.Main;
    26 import org.openstreetmap.josm.actions.search.PushbackTokenizer.Range;
    27 import org.openstreetmap.josm.actions.search.PushbackTokenizer.Token;
     26import org.openstreetmap.josm.actions.search.SearchAction;
    2827import org.openstreetmap.josm.data.Bounds;
    2928import org.openstreetmap.josm.data.coor.LatLon;
     
    3635import org.openstreetmap.josm.data.osm.Tagged;
    3736import org.openstreetmap.josm.data.osm.Way;
     37import org.openstreetmap.josm.data.osm.search.PushbackTokenizer.Range;
     38import org.openstreetmap.josm.data.osm.search.PushbackTokenizer.Token;
    3839import org.openstreetmap.josm.gui.MainApplication;
    3940import org.openstreetmap.josm.gui.mappaint.Environment;
     
    5354
    5455/**
    55  Implements a google-like search.
    56  <br>
    57  Grammar:
    58 <pre>
    59 expression =
    60   fact | expression
    61   fact expression
    62   fact
    63 
    64 fact =
    65  ( expression )
    66  -fact
    67  term?
    68  term=term
    69  term:term
    70  term
    71  </pre>
    72 
    73  @author Imi
     56 * Implements a google-like search.
     57 * <br>
     58 * Grammar:
     59 * <pre>
     60 * expression =
     61 *   fact | expression
     62 *   fact expression
     63 *   fact
     64 *
     65 * fact =
     66 *  ( expression )
     67 *  -fact
     68 *  term?
     69 *  term=term
     70 *  term:term
     71 *  term
     72 *  </pre>
     73 *
     74 * @author Imi
     75 * @since 12656 (moved from actions.search package)
    7476 */
    7577public class SearchCompiler {
     
    126128
    127129        @Override
    128         public Match get(String keyword, PushbackTokenizer tokenizer) throws ParseError {
     130        public Match get(String keyword, PushbackTokenizer tokenizer) throws SearchParseError {
    129131            switch(keyword) {
    130132            case "modified":
     
    198200                                minDate = DateUtils.fromString(rangeA1.isEmpty() ? "1980" : rangeA1).getTime();
    199201                            } catch (UncheckedParseException ex) {
    200                                 throw new ParseError(tr("Cannot parse timestamp ''{0}''", rangeA1), ex);
     202                                throw new SearchParseError(tr("Cannot parse timestamp ''{0}''", rangeA1), ex);
    201203                            }
    202204                            try {
     
    204206                                maxDate = rangeA2.isEmpty() ? System.currentTimeMillis() : DateUtils.fromString(rangeA2).getTime();
    205207                            } catch (UncheckedParseException ex) {
    206                                 throw new ParseError(tr("Cannot parse timestamp ''{0}''", rangeA2), ex);
     208                                throw new SearchParseError(tr("Cannot parse timestamp ''{0}''", rangeA2), ex);
    207209                            }
    208210                            return new TimestampRange(minDate, maxDate);
    209211                        } else {
    210                             throw new ParseError("<html>" + tr("Expecting {0} after {1}", "<i>min</i>/<i>max</i>", "<i>timestamp</i>"));
     212                            throw new SearchParseError("<html>" + tr("Expecting {0} after {1}", "<i>min</i>/<i>max</i>", "<i>timestamp</i>"));
    211213                        }
    212214                    }
    213215                } else {
    214                     throw new ParseError("<html>" + tr("Expecting {0} after {1}", "<code>:</code>", "<i>" + keyword + "</i>"));
     216                    throw new SearchParseError("<html>" + tr("Expecting {0} after {1}", "<code>:</code>", "<i>" + keyword + "</i>"));
    215217                }
    216218            }
     
    252254
    253255    public interface SimpleMatchFactory extends MatchFactory {
    254         Match get(String keyword, PushbackTokenizer tokenizer) throws ParseError;
     256        Match get(String keyword, PushbackTokenizer tokenizer) throws SearchParseError;
    255257    }
    256258
    257259    public interface UnaryMatchFactory extends MatchFactory {
    258         UnaryMatch get(String keyword, Match matchOperand, PushbackTokenizer tokenizer) throws ParseError;
     260        UnaryMatch get(String keyword, Match matchOperand, PushbackTokenizer tokenizer) throws SearchParseError;
    259261    }
    260262
    261263    public interface BinaryMatchFactory extends MatchFactory {
    262         AbstractBinaryMatch get(String keyword, Match lhs, Match rhs, PushbackTokenizer tokenizer) throws ParseError;
     264        AbstractBinaryMatch get(String keyword, Match lhs, Match rhs, PushbackTokenizer tokenizer) throws SearchParseError;
    263265    }
    264266
    265267    /**
    266268     * Base class for all search criteria. If the criterion only depends on an object's tags,
    267      * inherit from {@link org.openstreetmap.josm.actions.search.SearchCompiler.TaggedMatch}.
     269     * inherit from {@link org.openstreetmap.josm.data.osm.search.SearchCompiler.TaggedMatch}.
    268270     */
    269271    public abstract static class Match implements Predicate<OsmPrimitive> {
     
    536538        }
    537539
    538         Id(PushbackTokenizer tokenizer) throws ParseError {
     540        Id(PushbackTokenizer tokenizer) throws SearchParseError {
    539541            this(tokenizer.readRange(tr("Range of primitive ids expected")));
    540542        }
     
    559561        }
    560562
    561         ChangesetId(PushbackTokenizer tokenizer) throws ParseError {
     563        ChangesetId(PushbackTokenizer tokenizer) throws SearchParseError {
    562564            this(tokenizer.readRange(tr("Range of changeset ids expected")));
    563565        }
     
    582584        }
    583585
    584         Version(PushbackTokenizer tokenizer) throws ParseError {
     586        Version(PushbackTokenizer tokenizer) throws SearchParseError {
    585587            this(tokenizer.readRange(tr("Range of versions expected")));
    586588        }
     
    607609        private final boolean caseSensitive;
    608610
    609         KeyValue(String key, String value, boolean regexSearch, boolean caseSensitive) throws ParseError {
     611        KeyValue(String key, String value, boolean regexSearch, boolean caseSensitive) throws SearchParseError {
    610612            this.caseSensitive = caseSensitive;
    611613            if (regexSearch) {
     
    615617                    this.keyPattern = Pattern.compile(key, searchFlags);
    616618                } catch (PatternSyntaxException e) {
    617                     throw new ParseError(tr(rxErrorMsg, e.getPattern(), e.getIndex(), e.getMessage()), e);
     619                    throw new SearchParseError(tr(rxErrorMsg, e.getPattern(), e.getIndex(), e.getMessage()), e);
    618620                } catch (IllegalArgumentException e) {
    619                     throw new ParseError(tr(rxErrorMsgNoPos, key, e.getMessage()), e);
     621                    throw new SearchParseError(tr(rxErrorMsgNoPos, key, e.getMessage()), e);
    620622                }
    621623                try {
    622624                    this.valuePattern = Pattern.compile(value, searchFlags);
    623625                } catch (PatternSyntaxException e) {
    624                     throw new ParseError(tr(rxErrorMsg, e.getPattern(), e.getIndex(), e.getMessage()), e);
     626                    throw new SearchParseError(tr(rxErrorMsg, e.getPattern(), e.getIndex(), e.getMessage()), e);
    625627                } catch (IllegalArgumentException | StringIndexOutOfBoundsException e) {
    626                     throw new ParseError(tr(rxErrorMsgNoPos, value, e.getMessage()), e);
     628                    throw new SearchParseError(tr(rxErrorMsgNoPos, value, e.getMessage()), e);
    627629                }
    628630                this.key = key;
     
    771773         * @param key key
    772774         * @param value value
    773          * @throws ParseError if a parse error occurs
     775         * @throws SearchParseError if a parse error occurs
    774776         */
    775         public ExactKeyValue(boolean regexp, String key, String value) throws ParseError {
     777        public ExactKeyValue(boolean regexp, String key, String value) throws SearchParseError {
    776778            if ("".equals(key))
    777                 throw new ParseError(tr("Key cannot be empty when tag operator is used. Sample use: key=value"));
     779                throw new SearchParseError(tr("Key cannot be empty when tag operator is used. Sample use: key=value"));
    778780            this.key = key;
    779781            this.value = value == null ? "" : value;
     
    812814                    keyPattern = Pattern.compile(key, regexFlags(false));
    813815                } catch (PatternSyntaxException e) {
    814                     throw new ParseError(tr(rxErrorMsg, e.getPattern(), e.getIndex(), e.getMessage()), e);
     816                    throw new SearchParseError(tr(rxErrorMsg, e.getPattern(), e.getIndex(), e.getMessage()), e);
    815817                } catch (IllegalArgumentException e) {
    816                     throw new ParseError(tr(rxErrorMsgNoPos, key, e.getMessage()), e);
     818                    throw new SearchParseError(tr(rxErrorMsgNoPos, key, e.getMessage()), e);
    817819                }
    818820            } else {
     
    823825                    valuePattern = Pattern.compile(this.value, regexFlags(false));
    824826                } catch (PatternSyntaxException e) {
    825                     throw new ParseError(tr(rxErrorMsg, e.getPattern(), e.getIndex(), e.getMessage()), e);
     827                    throw new SearchParseError(tr(rxErrorMsg, e.getPattern(), e.getIndex(), e.getMessage()), e);
    826828                } catch (IllegalArgumentException e) {
    827                     throw new ParseError(tr(rxErrorMsgNoPos, value, e.getMessage()), e);
     829                    throw new SearchParseError(tr(rxErrorMsgNoPos, value, e.getMessage()), e);
    828830                }
    829831            } else {
     
    893895        private final boolean caseSensitive;
    894896
    895         Any(String s, boolean regexSearch, boolean caseSensitive) throws ParseError {
     897        Any(String s, boolean regexSearch, boolean caseSensitive) throws SearchParseError {
    896898            s = Normalizer.normalize(s, Normalizer.Form.NFC);
    897899            this.caseSensitive = caseSensitive;
     
    900902                    this.searchRegex = Pattern.compile(s, regexFlags(caseSensitive));
    901903                } catch (PatternSyntaxException e) {
    902                     throw new ParseError(tr(rxErrorMsg, e.getPattern(), e.getIndex(), e.getMessage()), e);
     904                    throw new SearchParseError(tr(rxErrorMsg, e.getPattern(), e.getIndex(), e.getMessage()), e);
    903905                } catch (IllegalArgumentException | StringIndexOutOfBoundsException e) {
    904906                    // StringIndexOutOfBoundsException catched because of https://bugs.openjdk.java.net/browse/JI-9044959
    905907                    // See #13870: To remove after we switch to a version of Java which resolves this bug
    906                     throw new ParseError(tr(rxErrorMsgNoPos, s, e.getMessage()), e);
     908                    throw new SearchParseError(tr(rxErrorMsgNoPos, s, e.getMessage()), e);
    907909                }
    908910                this.search = s;
     
    959961        private final OsmPrimitiveType type;
    960962
    961         ExactType(String type) throws ParseError {
     963        ExactType(String type) throws SearchParseError {
    962964            this.type = OsmPrimitiveType.from(type);
    963965            if (this.type == null)
    964                 throw new ParseError(tr("Unknown primitive type: {0}. Allowed values are node, way or relation", type));
     966                throw new SearchParseError(tr("Unknown primitive type: {0}. Allowed values are node, way or relation", type));
    965967        }
    966968
     
    10481050        private final boolean modulo;
    10491051
    1050         Nth(PushbackTokenizer tokenizer, boolean modulo) throws ParseError {
     1052        Nth(PushbackTokenizer tokenizer, boolean modulo) throws SearchParseError {
    10511053            this((int) tokenizer.readNumber(tr("Positive integer expected")), modulo);
    10521054        }
     
    11311133        }
    11321134
    1133         NodeCountRange(PushbackTokenizer tokenizer) throws ParseError {
     1135        NodeCountRange(PushbackTokenizer tokenizer) throws SearchParseError {
    11341136            this(tokenizer.readRange(tr("Range of numbers expected")));
    11351137        }
     
    11601162        }
    11611163
    1162         WayCountRange(PushbackTokenizer tokenizer) throws ParseError {
     1164        WayCountRange(PushbackTokenizer tokenizer) throws SearchParseError {
    11631165            this(tokenizer.readRange(tr("Range of numbers expected")));
    11641166        }
     
    11891191        }
    11901192
    1191         TagCountRange(PushbackTokenizer tokenizer) throws ParseError {
     1193        TagCountRange(PushbackTokenizer tokenizer) throws SearchParseError {
    11921194            this(tokenizer.readRange(tr("Range of numbers expected")));
    11931195        }
     
    14141416        }
    14151417
    1416         AreaSize(PushbackTokenizer tokenizer) throws ParseError {
     1418        AreaSize(PushbackTokenizer tokenizer) throws SearchParseError {
    14171419            this(tokenizer.readRange(tr("Range of numbers expected")));
    14181420        }
     
    14391441        }
    14401442
    1441         WayLength(PushbackTokenizer tokenizer) throws ParseError {
     1443        WayLength(PushbackTokenizer tokenizer) throws SearchParseError {
    14421444            this(tokenizer.readRange(tr("Range of numbers expected")));
    14431445        }
     
    15711573        private final List<TaggingPreset> presets;
    15721574
    1573         Preset(String presetName) throws ParseError {
     1575        Preset(String presetName) throws SearchParseError {
    15741576
    15751577            if (presetName == null || presetName.isEmpty()) {
    1576                 throw new ParseError("The name of the preset is required");
     1578                throw new SearchParseError("The name of the preset is required");
    15771579            }
    15781580
     
    15931595
    15941596            if (this.presets.isEmpty()) {
    1595                 throw new ParseError(tr("Unknown preset name: ") + presetName);
     1597                throw new SearchParseError(tr("Unknown preset name: ") + presetName);
    15961598            }
    15971599        }
     
    16241626    }
    16251627
    1626     public static class ParseError extends Exception {
    1627         public ParseError(String msg) {
    1628             super(msg);
    1629         }
    1630 
    1631         public ParseError(String msg, Throwable cause) {
    1632             super(msg, cause);
    1633         }
    1634 
    1635         public ParseError(Token expected, Token found) {
    1636             this(tr("Unexpected token. Expected {0}, found {1}", expected, found));
    1637         }
    1638     }
    1639 
    16401628    /**
    16411629     * Compiles the search expression.
    16421630     * @param searchStr the search expression
    16431631     * @return a {@link Match} object for the expression
    1644      * @throws ParseError if an error has been encountered while compiling
     1632     * @throws SearchParseError if an error has been encountered while compiling
    16451633     * @see #compile(org.openstreetmap.josm.actions.search.SearchAction.SearchSetting)
    16461634     */
    1647     public static Match compile(String searchStr) throws ParseError {
     1635    public static Match compile(String searchStr) throws SearchParseError {
    16481636        return new SearchCompiler(false, false,
    16491637                new PushbackTokenizer(
     
    16561644     * @param setting the settings to use
    16571645     * @return a {@link Match} object for the expression
    1658      * @throws ParseError if an error has been encountered while compiling
     1646     * @throws SearchParseError if an error has been encountered while compiling
    16591647     * @see #compile(String)
    16601648     */
    1661     public static Match compile(SearchAction.SearchSetting setting) throws ParseError {
     1649    public static Match compile(SearchAction.SearchSetting setting) throws SearchParseError {
    16621650        if (setting.mapCSSSearch) {
    16631651            return compileMapCSS(setting.text);
     
    16691657    }
    16701658
    1671     static Match compileMapCSS(String mapCSS) throws ParseError {
     1659    static Match compileMapCSS(String mapCSS) throws SearchParseError {
    16721660        try {
    16731661            final List<Selector> selectors = new MapCSSParser(new StringReader(mapCSS)).selectors();
     
    16841672            };
    16851673        } catch (ParseException e) {
    1686             throw new ParseError(tr("Failed to parse MapCSS selector"), e);
     1674            throw new SearchParseError(tr("Failed to parse MapCSS selector"), e);
    16871675        }
    16881676    }
     
    16921680     *
    16931681     * @return match determined by search string
    1694      * @throws org.openstreetmap.josm.actions.search.SearchCompiler.ParseError if search expression cannot be parsed
    1695      */
    1696     public Match parse() throws ParseError {
     1682     * @throws org.openstreetmap.josm.data.osm.search.SearchParseError if search expression cannot be parsed
     1683     */
     1684    public Match parse() throws SearchParseError {
    16971685        Match m = Optional.ofNullable(parseExpression()).orElse(Always.INSTANCE);
    16981686        if (!tokenizer.readIfEqual(Token.EOF))
    1699             throw new ParseError(tr("Unexpected token: {0}", tokenizer.nextToken()));
     1687            throw new SearchParseError(tr("Unexpected token: {0}", tokenizer.nextToken()));
    17001688        Logging.debug("Parsed search expression is {0}", m);
    17011689        return m;
     
    17061694     *
    17071695     * @return match determined by parsing expression
    1708      * @throws ParseError if search expression cannot be parsed
    1709      */
    1710     private Match parseExpression() throws ParseError {
     1696     * @throws SearchParseError if search expression cannot be parsed
     1697     */
     1698    private Match parseExpression() throws SearchParseError {
    17111699        // Step 1: parse the whole expression and build a list of factors and logical tokens
    17121700        List<Object> list = parseExpressionStep1();
     
    17161704    }
    17171705
    1718     private List<Object> parseExpressionStep1() throws ParseError {
     1706    private List<Object> parseExpressionStep1() throws SearchParseError {
    17191707        Match factor;
    17201708        String token = null;
     
    17391727                }
    17401728            } else if (errorMessage != null) {
    1741                 throw new ParseError(errorMessage);
     1729                throw new SearchParseError(errorMessage);
    17421730            }
    17431731        } while (factor != null);
     
    17771765     *
    17781766     * @return match determined by parsing factor string
    1779      * @throws ParseError if search expression cannot be parsed
    1780      */
    1781     private Match parseFactor() throws ParseError {
     1767     * @throws SearchParseError if search expression cannot be parsed
     1768     */
     1769    private Match parseFactor() throws SearchParseError {
    17821770        if (tokenizer.readIfEqual(Token.LEFT_PARENT)) {
    17831771            Match expression = parseExpression();
    17841772            if (!tokenizer.readIfEqual(Token.RIGHT_PARENT))
    1785                 throw new ParseError(Token.RIGHT_PARENT, tokenizer.nextToken());
     1773                throw new SearchParseError(Token.RIGHT_PARENT, tokenizer.nextToken());
    17861774            return expression;
    17871775        } else if (tokenizer.readIfEqual(Token.NOT)) {
     
    18271815    }
    18281816
    1829     private Match parseFactor(String errorMessage) throws ParseError {
    1830         return Optional.ofNullable(parseFactor()).orElseThrow(() -> new ParseError(errorMessage));
     1817    private Match parseFactor(String errorMessage) throws SearchParseError {
     1818        return Optional.ofNullable(parseFactor()).orElseThrow(() -> new SearchParseError(errorMessage));
    18311819    }
    18321820
     
    18741862    }
    18751863}
    1876 
  • trunk/src/org/openstreetmap/josm/data/validation/Test.java

    r12636 r12656  
    1515import javax.swing.JPanel;
    1616
    17 import org.openstreetmap.josm.actions.search.SearchCompiler.NotOutsideDataSourceArea;
    1817import org.openstreetmap.josm.command.Command;
    1918import org.openstreetmap.josm.command.DeleteCommand;
     
    2221import org.openstreetmap.josm.data.osm.Relation;
    2322import org.openstreetmap.josm.data.osm.Way;
     23import org.openstreetmap.josm.data.osm.search.SearchCompiler.NotOutsideDataSourceArea;
    2424import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor;
    2525import org.openstreetmap.josm.gui.MainApplication;
  • trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java

    r12643 r12656  
    4141import org.openstreetmap.josm.actions.relation.SelectMembersAction;
    4242import org.openstreetmap.josm.actions.relation.SelectRelationAction;
    43 import org.openstreetmap.josm.actions.search.SearchCompiler;
    4443import org.openstreetmap.josm.data.osm.DataSet;
    4544import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    5049import org.openstreetmap.josm.data.osm.event.DatasetEventManager;
    5150import org.openstreetmap.josm.data.osm.event.DatasetEventManager.FireMode;
     51import org.openstreetmap.josm.data.osm.search.SearchCompiler;
    5252import org.openstreetmap.josm.data.osm.event.NodeMovedEvent;
    5353import org.openstreetmap.josm.data.osm.event.PrimitivesAddedEvent;
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r12641 r12656  
    6161import org.openstreetmap.josm.actions.relation.SelectRelationAction;
    6262import org.openstreetmap.josm.actions.search.SearchAction.SearchSetting;
    63 import org.openstreetmap.josm.actions.search.SearchCompiler;
    6463import org.openstreetmap.josm.command.ChangeCommand;
    6564import org.openstreetmap.josm.command.ChangePropertyCommand;
     
    7877import org.openstreetmap.josm.data.osm.event.DatasetEventManager;
    7978import org.openstreetmap.josm.data.osm.event.DatasetEventManager.FireMode;
     79import org.openstreetmap.josm.data.osm.search.SearchCompiler;
    8080import org.openstreetmap.josm.data.osm.event.SelectionEventManager;
    8181import org.openstreetmap.josm.data.preferences.StringProperty;
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/RecentTagCollection.java

    r12615 r12656  
    99
    1010import org.openstreetmap.josm.actions.search.SearchAction;
    11 import org.openstreetmap.josm.actions.search.SearchCompiler;
    1211import org.openstreetmap.josm.data.osm.Tag;
     12import org.openstreetmap.josm.data.osm.search.SearchParseError;
     13import org.openstreetmap.josm.data.osm.search.SearchCompiler;
    1314import org.openstreetmap.josm.data.preferences.CollectionProperty;
    1415
     
    8182    }
    8283
    83     public void setTagsToIgnore(SearchAction.SearchSetting tagsToIgnore) throws SearchCompiler.ParseError {
     84    public void setTagsToIgnore(SearchAction.SearchSetting tagsToIgnore) throws SearchParseError {
    8485        setTagsToIgnore(tagsToIgnore.text.isEmpty() ? SearchCompiler.Never.INSTANCE : SearchCompiler.compile(tagsToIgnore));
    8586    }
    8687
    87     public SearchAction.SearchSetting ignoreTag(Tag tagToIgnore, SearchAction.SearchSetting settingToUpdate) throws SearchCompiler.ParseError {
     88    public SearchAction.SearchSetting ignoreTag(Tag tagToIgnore, SearchAction.SearchSetting settingToUpdate) throws SearchParseError {
    8889        final String forTag = SearchCompiler.buildSearchStringForTag(tagToIgnore.getKey(), tagToIgnore.getValue());
    8990        settingToUpdate.text = settingToUpdate.text.isEmpty()
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/SearchBasedRowFilter.java

    r9536 r12656  
    55import javax.swing.table.TableModel;
    66
    7 import org.openstreetmap.josm.actions.search.SearchCompiler;
    87import org.openstreetmap.josm.data.osm.Tag;
     8import org.openstreetmap.josm.data.osm.search.SearchCompiler;
    99
    1010/**
    1111 * A {@link RowFilter} implementation which matches tags w.r.t. the specified filter's
    12  * {@link org.openstreetmap.josm.actions.search.SearchCompiler.Match#match(org.openstreetmap.josm.data.osm.Tagged)} method.
     12 * {@link org.openstreetmap.josm.data.osm.search.SearchCompiler.Match#match(org.openstreetmap.josm.data.osm.Tagged)} method.
    1313 *
    1414 * <p>An {@link javax.swing.RowFilter.Entry}'s column 0 is considered as key, and column 1 is considered as value.</p>
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java

    r12641 r12656  
    6464import org.openstreetmap.josm.actions.JosmAction;
    6565import org.openstreetmap.josm.actions.search.SearchAction;
    66 import org.openstreetmap.josm.actions.search.SearchCompiler;
    6766import org.openstreetmap.josm.command.ChangePropertyCommand;
    6867import org.openstreetmap.josm.command.Command;
     
    7069import org.openstreetmap.josm.data.osm.OsmPrimitive;
    7170import org.openstreetmap.josm.data.osm.Tag;
     71import org.openstreetmap.josm.data.osm.search.SearchParseError;
     72import org.openstreetmap.josm.data.osm.search.SearchCompiler;
    7273import org.openstreetmap.josm.data.preferences.BooleanProperty;
    7374import org.openstreetmap.josm.data.preferences.CollectionProperty;
     
    335336                tagsToIgnore = searchSetting;
    336337                recentTags.setTagsToIgnore(tagsToIgnore);
    337             } catch (SearchCompiler.ParseError parseError) {
     338            } catch (SearchParseError parseError) {
    338339                warnAboutParseError(parseError);
    339340                tagsToIgnore = new SearchAction.SearchSetting();
     
    343344    }
    344345
    345     private static void warnAboutParseError(SearchCompiler.ParseError parseError) {
     346    private static void warnAboutParseError(SearchParseError parseError) {
    346347        Logging.warn(parseError);
    347348        JOptionPane.showMessageDialog(
     
    10091010                        PROPERTY_TAGS_TO_IGNORE.put(tagsToIgnore.writeToString());
    10101011                    }
    1011                 } catch (SearchCompiler.ParseError parseError) {
     1012                } catch (SearchParseError parseError) {
    10121013                    throw new IllegalStateException(parseError);
    10131014                }
     
    10311032                    recentTags.setTagsToIgnore(tagsToIgnore);
    10321033                    PROPERTY_TAGS_TO_IGNORE.put(tagsToIgnore.writeToString());
    1033                 } catch (SearchCompiler.ParseError parseError) {
     1034                } catch (SearchParseError parseError) {
    10341035                    warnAboutParseError(parseError);
    10351036                }
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/Marker.java

    r12620 r12656  
    2323import javax.swing.ImageIcon;
    2424
    25 import org.openstreetmap.josm.actions.search.SearchCompiler.Match;
    2625import org.openstreetmap.josm.data.Preferences.PreferenceChangeEvent;
    2726import org.openstreetmap.josm.data.coor.CachedLatLon;
     
    3029import org.openstreetmap.josm.data.gpx.GpxConstants;
    3130import org.openstreetmap.josm.data.gpx.WayPoint;
     31import org.openstreetmap.josm.data.osm.search.SearchCompiler.Match;
    3232import org.openstreetmap.josm.data.preferences.CachedProperty;
    3333import org.openstreetmap.josm.data.preferences.IntegerProperty;
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ConditionFactory.java

    r12218 r12656  
    1515import java.util.regex.PatternSyntaxException;
    1616
    17 import org.openstreetmap.josm.actions.search.SearchCompiler.InDataSourceArea;
    1817import org.openstreetmap.josm.data.osm.Node;
    1918import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    2221import org.openstreetmap.josm.data.osm.Tag;
    2322import org.openstreetmap.josm.data.osm.Way;
     23import org.openstreetmap.josm.data.osm.search.SearchCompiler.InDataSourceArea;
    2424import org.openstreetmap.josm.data.osm.visitor.paint.relations.MultipolygonCache;
    2525import org.openstreetmap.josm.gui.mappaint.Cascade;
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java

    r12620 r12656  
    2424import java.util.zip.CRC32;
    2525
    26 import org.openstreetmap.josm.actions.search.SearchCompiler;
    27 import org.openstreetmap.josm.actions.search.SearchCompiler.Match;
    28 import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError;
    2926import org.openstreetmap.josm.data.coor.LatLon;
    3027import org.openstreetmap.josm.data.osm.Node;
    3128import org.openstreetmap.josm.data.osm.OsmPrimitive;
    3229import org.openstreetmap.josm.data.osm.Way;
     30import org.openstreetmap.josm.data.osm.search.SearchParseError;
     31import org.openstreetmap.josm.data.osm.search.SearchCompiler;
     32import org.openstreetmap.josm.data.osm.search.SearchCompiler.Match;
    3333import org.openstreetmap.josm.gui.mappaint.Cascade;
    3434import org.openstreetmap.josm.gui.mappaint.Environment;
     
    676676            try {
    677677                m = SearchCompiler.compile(searchStr);
    678             } catch (ParseError ex) {
     678            } catch (SearchParseError ex) {
    679679                Logging.trace(ex);
    680680                return null;
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java

    r12641 r12656  
    3434import org.openstreetmap.josm.Main;
    3535import org.openstreetmap.josm.actions.AdaptableAction;
    36 import org.openstreetmap.josm.actions.search.SearchCompiler;
    37 import org.openstreetmap.josm.actions.search.SearchCompiler.Match;
    3836import org.openstreetmap.josm.command.ChangePropertyCommand;
    3937import org.openstreetmap.josm.command.Command;
     
    4442import org.openstreetmap.josm.data.osm.RelationMember;
    4543import org.openstreetmap.josm.data.osm.Tag;
     44import org.openstreetmap.josm.data.osm.search.SearchCompiler;
     45import org.openstreetmap.josm.data.osm.search.SearchCompiler.Match;
     46import org.openstreetmap.josm.data.osm.search.SearchParseError;
    4647import org.openstreetmap.josm.gui.ExtendedDialog;
    4748import org.openstreetmap.josm.gui.MainApplication;
     
    246247        try {
    247248            this.nameTemplateFilter = SearchCompiler.compile(filter);
    248         } catch (SearchCompiler.ParseError e) {
     249        } catch (SearchParseError e) {
    249250            Logging.error("Error while parsing" + filter + ": " + e.getMessage());
    250251            throw new SAXException(e);
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Roles.java

    r12615 r12656  
    1414
    1515import org.openstreetmap.josm.actions.search.SearchAction;
    16 import org.openstreetmap.josm.actions.search.SearchCompiler;
    1716import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1817import org.openstreetmap.josm.data.osm.Tag;
     18import org.openstreetmap.josm.data.osm.search.SearchParseError;
     19import org.openstreetmap.josm.data.osm.search.SearchCompiler;
    1920import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItem;
    2021import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetType;
     
    8283                searchSetting.regexSearch = true;
    8384                this.memberExpression = SearchCompiler.compile(searchSetting);
    84             } catch (SearchCompiler.ParseError ex) {
     85            } catch (SearchParseError ex) {
    8586                throw new SAXException(tr("Illegal member expression: {0}", ex.getMessage()), ex);
    8687            }
  • trunk/src/org/openstreetmap/josm/gui/widgets/CompileSearchTextDecorator.java

    r12620 r12656  
    99import javax.swing.text.JTextComponent;
    1010
    11 import org.openstreetmap.josm.actions.search.SearchCompiler;
     11import org.openstreetmap.josm.data.osm.search.SearchParseError;
     12import org.openstreetmap.josm.data.osm.search.SearchCompiler;
    1213import org.openstreetmap.josm.tools.Logging;
    1314
     
    4344            textComponent.setToolTipText(originalToolTipText);
    4445            filter = SearchCompiler.compile(textComponent.getText());
    45         } catch (SearchCompiler.ParseError ex) {
     46        } catch (SearchParseError ex) {
    4647            textComponent.setBackground(new Color(255, 224, 224));
    4748            textComponent.setToolTipText(ex.getMessage());
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java

    r12636 r12656  
    1616import org.openstreetmap.josm.actions.downloadtasks.DownloadTask;
    1717import org.openstreetmap.josm.actions.downloadtasks.PostDownloadHandler;
    18 import org.openstreetmap.josm.actions.search.SearchCompiler;
    1918import org.openstreetmap.josm.data.Bounds;
    2019import org.openstreetmap.josm.data.coor.LatLon;
     
    2423import org.openstreetmap.josm.data.osm.Relation;
    2524import org.openstreetmap.josm.data.osm.SimplePrimitiveId;
     25import org.openstreetmap.josm.data.osm.search.SearchParseError;
     26import org.openstreetmap.josm.data.osm.search.SearchCompiler;
    2627import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
    2728import org.openstreetmap.josm.gui.MainApplication;
     
    202203                    zoom(filteredPrimitives, bbox);
    203204                });
    204             } catch (SearchCompiler.ParseError ex) {
     205            } catch (SearchParseError ex) {
    205206                Logging.error(ex);
    206207                throw new RequestHandlerErrorException(ex);
  • trunk/src/org/openstreetmap/josm/tools/template_engine/ContextSwitchTemplate.java

    r11974 r12656  
    99import java.util.List;
    1010
    11 import org.openstreetmap.josm.actions.search.SearchCompiler.And;
    12 import org.openstreetmap.josm.actions.search.SearchCompiler.Child;
    13 import org.openstreetmap.josm.actions.search.SearchCompiler.Match;
    14 import org.openstreetmap.josm.actions.search.SearchCompiler.Not;
    15 import org.openstreetmap.josm.actions.search.SearchCompiler.Or;
    16 import org.openstreetmap.josm.actions.search.SearchCompiler.Parent;
    1711import org.openstreetmap.josm.data.osm.Node;
    1812import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    2014import org.openstreetmap.josm.data.osm.RelationMember;
    2115import org.openstreetmap.josm.data.osm.Way;
     16import org.openstreetmap.josm.data.osm.search.SearchCompiler.And;
     17import org.openstreetmap.josm.data.osm.search.SearchCompiler.Child;
     18import org.openstreetmap.josm.data.osm.search.SearchCompiler.Match;
     19import org.openstreetmap.josm.data.osm.search.SearchCompiler.Not;
     20import org.openstreetmap.josm.data.osm.search.SearchCompiler.Or;
     21import org.openstreetmap.josm.data.osm.search.SearchCompiler.Parent;
    2222
    2323/**
  • trunk/src/org/openstreetmap/josm/tools/template_engine/ParseError.java

    r8540 r12656  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import org.openstreetmap.josm.data.osm.search.SearchParseError;
    67import org.openstreetmap.josm.tools.template_engine.Tokenizer.Token;
    78import org.openstreetmap.josm.tools.template_engine.Tokenizer.TokenType;
     
    2223    }
    2324
    24     public ParseError(int position, org.openstreetmap.josm.actions.search.SearchCompiler.ParseError e) {
     25    public ParseError(int position, SearchParseError e) {
    2526        super(tr("Error while parsing search expression on position {0}", position), e);
    2627        unexpectedToken = null;
  • trunk/src/org/openstreetmap/josm/tools/template_engine/SearchExpressionCondition.java

    r10305 r12656  
    22package org.openstreetmap.josm.tools.template_engine;
    33
    4 import org.openstreetmap.josm.actions.search.SearchCompiler.Match;
     4import org.openstreetmap.josm.data.osm.search.SearchCompiler.Match;
    55
    66public class SearchExpressionCondition implements TemplateEntry {
  • trunk/src/org/openstreetmap/josm/tools/template_engine/TemplateEngineDataProvider.java

    r8510 r12656  
    44import java.util.Collection;
    55
    6 import org.openstreetmap.josm.actions.search.SearchCompiler.Match;
     6import org.openstreetmap.josm.data.osm.search.SearchCompiler.Match;
    77
    88public interface TemplateEngineDataProvider {
  • trunk/src/org/openstreetmap/josm/tools/template_engine/TemplateParser.java

    r11929 r12656  
    99import java.util.List;
    1010
    11 import org.openstreetmap.josm.actions.search.SearchCompiler;
    12 import org.openstreetmap.josm.actions.search.SearchCompiler.Match;
     11import org.openstreetmap.josm.data.osm.search.SearchCompiler;
     12import org.openstreetmap.josm.data.osm.search.SearchCompiler.Match;
     13import org.openstreetmap.josm.data.osm.search.SearchParseError;
    1314import org.openstreetmap.josm.tools.template_engine.Tokenizer.Token;
    1415import org.openstreetmap.josm.tools.template_engine.Tokenizer.TokenType;
     
    102103                    result.getEntries().add(new SearchExpressionCondition(
    103104                            SearchCompiler.compile(searchText), condition));
    104                 } catch (SearchCompiler.ParseError e) {
     105                } catch (SearchParseError e) {
    105106                    throw new ParseError(searchExpression.getPosition(), e);
    106107                }
     
    133134                Match match = SearchCompiler.compile(searchText);
    134135                result = new ContextSwitchTemplate(match, template, searchExpression.getPosition());
    135             } catch (SearchCompiler.ParseError e) {
     136            } catch (SearchParseError e) {
    136137                throw new ParseError(searchExpression.getPosition(), e);
    137138            }
  • trunk/test/functional/org/openstreetmap/josm/data/BoundariesTestIT.java

    r11247 r12656  
    1212
    1313import org.junit.Test;
    14 import org.openstreetmap.josm.actions.search.SearchCompiler;
    1514import org.openstreetmap.josm.data.osm.DataSet;
    1615import org.openstreetmap.josm.data.osm.OsmPrimitive;
     16import org.openstreetmap.josm.data.osm.search.SearchCompiler;
    1717import org.openstreetmap.josm.io.OsmReader;
    1818
  • trunk/test/unit/org/openstreetmap/josm/actions/CreateMultipolygonActionTest.java

    r11104 r12656  
    1313import org.openstreetmap.josm.TestUtils;
    1414import org.openstreetmap.josm.actions.search.SearchAction.SearchSetting;
    15 import org.openstreetmap.josm.actions.search.SearchCompiler;
    16 import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError;
    1715import org.openstreetmap.josm.command.SequenceCommand;
    1816import org.openstreetmap.josm.data.osm.DataSet;
     
    2018import org.openstreetmap.josm.data.osm.RelationMember;
    2119import org.openstreetmap.josm.data.osm.Way;
     20import org.openstreetmap.josm.data.osm.search.SearchParseError;
     21import org.openstreetmap.josm.data.osm.search.SearchCompiler;
    2222import org.openstreetmap.josm.io.OsmReader;
    2323import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    5656    @SuppressWarnings("unchecked")
    5757    private static Pair<SequenceCommand, Relation> createMultipolygonCommand(Collection<Way> ways, String pattern, Relation r)
    58             throws ParseError {
     58            throws SearchParseError {
    5959        return CreateMultipolygonAction.createMultipolygonCommand(
    6060            (Collection<Way>) (Collection<?>) SubclassFilteredCollection.filter(ways, SearchCompiler.compile(regexpSearch(pattern))), r);
  • trunk/test/unit/org/openstreetmap/josm/actions/OrthogonalizeActionTest.java

    r12636 r12656  
    1212import org.openstreetmap.josm.TestUtils;
    1313import org.openstreetmap.josm.actions.OrthogonalizeAction.Direction;
    14 import org.openstreetmap.josm.actions.search.SearchCompiler;
    1514import org.openstreetmap.josm.data.coor.LatLon;
    1615import org.openstreetmap.josm.data.osm.DataSet;
    1716import org.openstreetmap.josm.data.osm.Node;
    1817import org.openstreetmap.josm.data.osm.Way;
     18import org.openstreetmap.josm.data.osm.search.SearchCompiler;
    1919import org.openstreetmap.josm.gui.MainApplication;
    2020import org.openstreetmap.josm.gui.layer.OsmDataLayer;
  • trunk/test/unit/org/openstreetmap/josm/actions/search/SearchActionTest.java

    r11978 r12656  
    66import org.openstreetmap.josm.TestUtils;
    77import org.openstreetmap.josm.actions.search.SearchAction.SearchMode;
     8import org.openstreetmap.josm.data.osm.search.SearchCompiler;
    89import org.openstreetmap.josm.testutils.JOSMTestRules;
    910
  • trunk/test/unit/org/openstreetmap/josm/data/osm/FilterTest.java

    r11973 r12656  
    1717import org.junit.Test;
    1818import org.openstreetmap.josm.actions.search.SearchAction.SearchMode;
    19 import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError;
    2019import org.openstreetmap.josm.data.coor.LatLon;
    2120import org.openstreetmap.josm.data.osm.Filter.FilterPreferenceEntry;
     21import org.openstreetmap.josm.data.osm.search.SearchParseError;
    2222import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    2323import org.openstreetmap.josm.io.OsmReader;
     
    4141
    4242    @Test
    43     public void testBasic() throws ParseError {
     43    public void testBasic() throws SearchParseError {
    4444        DataSet ds = new DataSet();
    4545        Node n1 = new Node(LatLon.ZERO);
  • trunk/test/unit/org/openstreetmap/josm/data/osm/search/PushbackTokenizerTest.java

    r12651 r12656  
    11// License: GPL. For details, see LICENSE file.
    2 package org.openstreetmap.josm.actions.search;
     2package org.openstreetmap.josm.data.osm.search;
    33
    44import org.junit.Rule;
    55import org.junit.Test;
    66import org.openstreetmap.josm.TestUtils;
    7 import org.openstreetmap.josm.actions.search.PushbackTokenizer.Token;
     7import org.openstreetmap.josm.data.osm.search.PushbackTokenizer.Token;
    88import org.openstreetmap.josm.testutils.JOSMTestRules;
    99
  • trunk/test/unit/org/openstreetmap/josm/data/osm/search/SearchCompilerTest.java

    r12651 r12656  
    11// License: GPL. For details, see LICENSE file.
    2 package org.openstreetmap.josm.actions.search;
     2package org.openstreetmap.josm.data.osm.search;
    33
    44import static org.junit.Assert.assertEquals;
     
    2020import org.openstreetmap.josm.TestUtils;
    2121import org.openstreetmap.josm.actions.search.SearchAction.SearchSetting;
    22 import org.openstreetmap.josm.actions.search.SearchCompiler.ExactKeyValue;
    23 import org.openstreetmap.josm.actions.search.SearchCompiler.Match;
    24 import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError;
    2522import org.openstreetmap.josm.data.coor.LatLon;
    2623import org.openstreetmap.josm.data.osm.DataSet;
     
    3532import org.openstreetmap.josm.data.osm.Way;
    3633import org.openstreetmap.josm.data.osm.WayData;
     34import org.openstreetmap.josm.data.osm.search.SearchCompiler.ExactKeyValue;
     35import org.openstreetmap.josm.data.osm.search.SearchCompiler.Match;
    3736import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset;
    3837import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetMenu;
     
    6968        private final Match n;
    7069
    71         private SearchContext(String state) throws ParseError {
     70        private SearchContext(String state) throws SearchParseError {
    7271            m = SearchCompiler.compile(state);
    7372            n = SearchCompiler.compile('-' + state);
     
    107106    /**
    108107     * Search anything.
    109      * @throws ParseError if an error has been encountered while compiling
    110      */
    111     @Test
    112     public void testAny() throws ParseError {
     108     * @throws SearchParseError if an error has been encountered while compiling
     109     */
     110    @Test
     111    public void testAny() throws SearchParseError {
    113112        final SearchCompiler.Match c = SearchCompiler.compile("foo");
    114113        assertTrue(c.match(newPrimitive("foobar", "true")));
     
    120119    /**
    121120     * Search by equality key=value.
    122      * @throws ParseError if an error has been encountered while compiling
    123      */
    124     @Test
    125     public void testEquals() throws ParseError {
     121     * @throws SearchParseError if an error has been encountered while compiling
     122     */
     123    @Test
     124    public void testEquals() throws SearchParseError {
    126125        final SearchCompiler.Match c = SearchCompiler.compile("foo=bar");
    127126        assertFalse(c.match(newPrimitive("foobar", "true")));
     
    134133    /**
    135134     * Search by comparison.
    136      * @throws ParseError if an error has been encountered while compiling
    137      */
    138     @Test
    139     public void testCompare() throws ParseError {
     135     * @throws SearchParseError if an error has been encountered while compiling
     136     */
     137    @Test
     138    public void testCompare() throws SearchParseError {
    140139        final SearchCompiler.Match c1 = SearchCompiler.compile("start_date>1950");
    141140        assertTrue(c1.match(newPrimitive("start_date", "1950-01-01")));
     
    174173    /**
    175174     * Search by nth.
    176      * @throws ParseError if an error has been encountered while compiling
    177      */
    178     @Test
    179     public void testNth() throws ParseError {
     175     * @throws SearchParseError if an error has been encountered while compiling
     176     */
     177    @Test
     178    public void testNth() throws SearchParseError {
    180179        final DataSet dataSet = new DataSet();
    181180        final Way way = new Way();
     
    202201    /**
    203202     * Search by negative nth.
    204      * @throws ParseError if an error has been encountered while compiling
    205      */
    206     @Test
    207     public void testNthParseNegative() throws ParseError {
     203     * @throws SearchParseError if an error has been encountered while compiling
     204     */
     205    @Test
     206    public void testNthParseNegative() throws SearchParseError {
    208207        assertEquals("Nth{nth=-1, modulo=false}", SearchCompiler.compile("nth:-1").toString());
    209208    }
     
    211210    /**
    212211     * Search by modified status.
    213      * @throws ParseError if an error has been encountered while compiling
    214      */
    215     @Test
    216     public void testModified() throws ParseError {
     212     * @throws SearchParseError if an error has been encountered while compiling
     213     */
     214    @Test
     215    public void testModified() throws SearchParseError {
    217216        SearchContext sc = new SearchContext("modified");
    218217        // Not modified but new
     
    247246    /**
    248247     * Search by selected status.
    249      * @throws ParseError if an error has been encountered while compiling
    250      */
    251     @Test
    252     public void testSelected() throws ParseError {
     248     * @throws SearchParseError if an error has been encountered while compiling
     249     */
     250    @Test
     251    public void testSelected() throws SearchParseError {
    253252        SearchContext sc = new SearchContext("selected");
    254253        // Not selected
     
    267266    /**
    268267     * Search by incomplete status.
    269      * @throws ParseError if an error has been encountered while compiling
    270      */
    271     @Test
    272     public void testIncomplete() throws ParseError {
     268     * @throws SearchParseError if an error has been encountered while compiling
     269     */
     270    @Test
     271    public void testIncomplete() throws SearchParseError {
    273272        SearchContext sc = new SearchContext("incomplete");
    274273        // Not incomplete
     
    293292    /**
    294293     * Search by untagged status.
    295      * @throws ParseError if an error has been encountered while compiling
    296      */
    297     @Test
    298     public void testUntagged() throws ParseError {
     294     * @throws SearchParseError if an error has been encountered while compiling
     295     */
     296    @Test
     297    public void testUntagged() throws SearchParseError {
    299298        SearchContext sc = new SearchContext("untagged");
    300299        // Untagged
     
    313312    /**
    314313     * Search by closed status.
    315      * @throws ParseError if an error has been encountered while compiling
    316      */
    317     @Test
    318     public void testClosed() throws ParseError {
     314     * @throws SearchParseError if an error has been encountered while compiling
     315     */
     316    @Test
     317    public void testClosed() throws SearchParseError {
    319318        SearchContext sc = new SearchContext("closed");
    320319        // Closed
     
    332331    /**
    333332     * Search by new status.
    334      * @throws ParseError if an error has been encountered while compiling
    335      */
    336     @Test
    337     public void testNew() throws ParseError {
     333     * @throws SearchParseError if an error has been encountered while compiling
     334     */
     335    @Test
     336    public void testNew() throws SearchParseError {
    338337        SearchContext sc = new SearchContext("new");
    339338        // New
     
    352351    /**
    353352     * Search for node objects.
    354      * @throws ParseError if an error has been encountered while compiling
    355      */
    356     @Test
    357     public void testTypeNode() throws ParseError {
     353     * @throws SearchParseError if an error has been encountered while compiling
     354     */
     355    @Test
     356    public void testTypeNode() throws SearchParseError {
    358357        final SearchContext sc = new SearchContext("type:node");
    359358        for (OsmPrimitive p : new OsmPrimitive[]{sc.n1, sc.n2, sc.w1, sc.w2, sc.r1, sc.r2}) {
     
    364363    /**
    365364     * Search for way objects.
    366      * @throws ParseError if an error has been encountered while compiling
    367      */
    368     @Test
    369     public void testTypeWay() throws ParseError {
     365     * @throws SearchParseError if an error has been encountered while compiling
     366     */
     367    @Test
     368    public void testTypeWay() throws SearchParseError {
    370369        final SearchContext sc = new SearchContext("type:way");
    371370        for (OsmPrimitive p : new OsmPrimitive[]{sc.n1, sc.n2, sc.w1, sc.w2, sc.r1, sc.r2}) {
     
    376375    /**
    377376     * Search for relation objects.
    378      * @throws ParseError if an error has been encountered while compiling
    379      */
    380     @Test
    381     public void testTypeRelation() throws ParseError {
     377     * @throws SearchParseError if an error has been encountered while compiling
     378     */
     379    @Test
     380    public void testTypeRelation() throws SearchParseError {
    382381        final SearchContext sc = new SearchContext("type:relation");
    383382        for (OsmPrimitive p : new OsmPrimitive[]{sc.n1, sc.n2, sc.w1, sc.w2, sc.r1, sc.r2}) {
     
    388387    /**
    389388     * Search for users.
    390      * @throws ParseError if an error has been encountered while compiling
    391      */
    392     @Test
    393     public void testUser() throws ParseError {
     389     * @throws SearchParseError if an error has been encountered while compiling
     390     */
     391    @Test
     392    public void testUser() throws SearchParseError {
    394393        final SearchContext foobar = new SearchContext("user:foobar");
    395394        foobar.n1.setUser(User.createLocalUser("foobar"));
     
    410409            SearchCompiler.compile("foo type bar");
    411410            fail();
    412         } catch (ParseError parseError) {
     411        } catch (SearchParseError parseError) {
    413412            assertEquals("<html>Expecting <code>:</code> after <i>type</i>", parseError.getMessage());
    414413        }
     
    417416    /**
    418417     * Search for primitive timestamps.
    419      * @throws ParseError if an error has been encountered while compiling
    420      */
    421     @Test
    422     public void testTimestamp() throws ParseError {
     418     * @throws SearchParseError if an error has been encountered while compiling
     419     */
     420    @Test
     421    public void testTimestamp() throws SearchParseError {
    423422        final Match search = SearchCompiler.compile("timestamp:2010/2011");
    424423        final Node n1 = new Node();
     
    431430    /**
    432431     * Tests the implementation of the Boolean logic.
    433      * @throws ParseError if an error has been encountered while compiling
    434      */
    435     @Test
    436     public void testBooleanLogic() throws ParseError {
     432     * @throws SearchParseError if an error has been encountered while compiling
     433     */
     434    @Test
     435    public void testBooleanLogic() throws SearchParseError {
    437436        final SearchCompiler.Match c1 = SearchCompiler.compile("foo AND bar AND baz");
    438437        assertTrue(c1.match(newPrimitive("foobar", "baz")));
     
    454453    /**
    455454     * Tests {@code buildSearchStringForTag}.
    456      * @throws ParseError if an error has been encountered while compiling
    457      */
    458     @Test
    459     public void testBuildSearchStringForTag() throws ParseError {
     455     * @throws SearchParseError if an error has been encountered while compiling
     456     */
     457    @Test
     458    public void testBuildSearchStringForTag() throws SearchParseError {
    460459        final Tag tag1 = new Tag("foo=", "bar\"");
    461460        final Tag tag2 = new Tag("foo=", "=bar");
     
    472471    /**
    473472     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/13870">Bug #13870</a>.
    474      * @throws ParseError always
    475      */
    476     @Test(expected = ParseError.class)
    477     public void testPattern13870() throws ParseError {
     473     * @throws SearchParseError always
     474     */
     475    @Test(expected = SearchParseError.class)
     476    public void testPattern13870() throws SearchParseError {
    478477        // https://bugs.openjdk.java.net/browse/JI-9044959
    479478        SearchSetting setting = new SearchSetting();
     
    503502    /**
    504503     * Robustness test for preset searching. Ensures that the query 'preset:' is not accepted.
    505      * @throws ParseError always
     504     * @throws SearchParseError always
    506505     * @since 12464
    507506     */
    508     @Test(expected = ParseError.class)
    509     public void testPresetSearchMissingValue() throws ParseError {
     507    @Test(expected = SearchParseError.class)
     508    public void testPresetSearchMissingValue() throws SearchParseError {
    510509        SearchSetting settings = new SearchSetting();
    511510        settings.text = "preset:";
     
    520519     * Robustness test for preset searching. Validates that it is not possible to search for
    521520     * non existing presets.
    522      * @throws ParseError always
     521     * @throws SearchParseError always
    523522     * @since 12464
    524523     */
    525     @Test(expected = ParseError.class)
    526     public void testPresetNotExist() throws ParseError {
     524    @Test(expected = SearchParseError.class)
     525    public void testPresetNotExist() throws SearchParseError {
    527526        String testPresetName = "groupnamethatshouldnotexist/namethatshouldnotexist";
    528527        SearchSetting settings = new SearchSetting();
     
    539538     * Robustness tests for preset searching. Ensures that combined preset names (having more than
    540539     * 1 word) must be enclosed with " .
    541      * @throws ParseError always
     540     * @throws SearchParseError always
    542541     * @since 12464
    543542     */
    544     @Test(expected = ParseError.class)
    545     public void testPresetMultipleWords() throws ParseError {
     543    @Test(expected = SearchParseError.class)
     544    public void testPresetMultipleWords() throws SearchParseError {
    546545        TaggingPreset testPreset = new TaggingPreset();
    547546        testPreset.name = "Test Combined Preset Name";
     
    562561
    563562    /**
    564      * Ensures that correct presets are stored in the {@link org.openstreetmap.josm.actions.search.SearchCompiler.Preset}
     563     * Ensures that correct presets are stored in the {@link org.openstreetmap.josm.data.osm.search.SearchCompiler.Preset}
    565564     * class against which the osm primitives are tested.
    566      * @throws ParseError if an error has been encountered while compiling
     565     * @throws SearchParseError if an error has been encountered while compiling
    567566     * @throws NoSuchFieldException if there is no field called 'presets'
    568567     * @throws IllegalAccessException if cannot access the field where all matching presets are stored
     
    570569     */
    571570    @Test
    572     public void testPresetLookup() throws ParseError, NoSuchFieldException, IllegalAccessException {
     571    public void testPresetLookup() throws SearchParseError, NoSuchFieldException, IllegalAccessException {
    573572        TaggingPreset testPreset = new TaggingPreset();
    574573        testPreset.name = "Test Preset Name";
     
    601600    /**
    602601     * Ensures that the wildcard search works and that correct presets are stored in
    603      * the {@link org.openstreetmap.josm.actions.search.SearchCompiler.Preset} class against which
     602     * the {@link org.openstreetmap.josm.data.osm.search.SearchCompiler.Preset} class against which
    604603     * the osm primitives are tested.
    605      * @throws ParseError if an error has been encountered while compiling
     604     * @throws SearchParseError if an error has been encountered while compiling
    606605     * @throws NoSuchFieldException if there is no field called 'presets'
    607606     * @throws IllegalAccessException if cannot access the field where all matching presets are stored
     
    609608     */
    610609    @Test
    611     public void testPresetLookupWildcard() throws ParseError, NoSuchFieldException, IllegalAccessException {
     610    public void testPresetLookupWildcard() throws SearchParseError, NoSuchFieldException, IllegalAccessException {
    612611        TaggingPresetMenu group = new TaggingPresetMenu();
    613612        group.name = "TestPresetGroup";
     
    650649    /**
    651650     * Ensures that correct primitives are matched against the specified preset.
    652      * @throws ParseError if an error has been encountered while compiling
     651     * @throws SearchParseError if an error has been encountered while compiling
    653652     * @since 12464
    654653     */
    655654    @Test
    656     public void testPreset() throws ParseError {
     655    public void testPreset() throws SearchParseError {
    657656        final String presetName = "Test Preset Name";
    658657        final String presetGroupName = "Test Preset Group";
     
    689688    }
    690689}
    691 
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/properties/RecentTagCollectionTest.java

    r10962 r12656  
    1212import org.junit.Test;
    1313import org.openstreetmap.josm.actions.search.SearchAction;
    14 import org.openstreetmap.josm.actions.search.SearchCompiler;
    1514import org.openstreetmap.josm.data.osm.Tag;
     15import org.openstreetmap.josm.data.osm.search.SearchParseError;
    1616import org.openstreetmap.josm.data.preferences.CollectionProperty;
    1717import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    3434     * Performs various tests on a {@link RecentTagCollection}.
    3535     *
    36      * @throws SearchCompiler.ParseError if an error has been encountered while compiling
     36     * @throws SearchParseError if an error has been encountered while compiling
    3737     */
    3838    @Test
    39     public void testVarious() throws SearchCompiler.ParseError {
     39    public void testVarious() throws SearchParseError {
    4040        final RecentTagCollection recentTags = new RecentTagCollection(2);
    4141        assertTrue(recentTags.isEmpty());
  • trunk/test/unit/org/openstreetmap/josm/tools/GeometryTest.java

    r10657 r12656  
    99import org.junit.Test;
    1010import org.openstreetmap.josm.TestUtils;
    11 import org.openstreetmap.josm.actions.search.SearchCompiler;
    1211import org.openstreetmap.josm.data.coor.EastNorth;
    1312import org.openstreetmap.josm.data.osm.DataSet;
    1413import org.openstreetmap.josm.data.osm.Relation;
    1514import org.openstreetmap.josm.data.osm.Way;
     15import org.openstreetmap.josm.data.osm.search.SearchCompiler;
    1616import org.openstreetmap.josm.io.OsmReader;
    1717import org.openstreetmap.josm.testutils.JOSMTestRules;
  • trunk/test/unit/org/openstreetmap/josm/tools/template_engine/TemplateParserTest.java

    r12548 r12656  
    99import org.junit.Test;
    1010import org.openstreetmap.josm.JOSMFixture;
    11 import org.openstreetmap.josm.actions.search.SearchCompiler;
    12 import org.openstreetmap.josm.actions.search.SearchCompiler.Match;
    1311import org.openstreetmap.josm.data.osm.Node;
    1412import org.openstreetmap.josm.data.osm.Relation;
    1513import org.openstreetmap.josm.data.osm.RelationMember;
     14import org.openstreetmap.josm.data.osm.search.SearchCompiler;
     15import org.openstreetmap.josm.data.osm.search.SearchCompiler.Match;
     16import org.openstreetmap.josm.data.osm.search.SearchParseError;
    1617import org.openstreetmap.josm.testutils.DatasetFactory;
    1718import org.unitils.reflectionassert.ReflectionAssert;
     
    7980    }
    8081
    81     private static Match compile(String expression) throws SearchCompiler.ParseError {
     82    private static Match compile(String expression) throws SearchParseError {
    8283        return SearchCompiler.compile(expression);
    8384    }
     
    8687     * Test to parse a search expression condition.
    8788     * @throws ParseError if the template cannot be parsed
    88      * @throws SearchCompiler.ParseError if an error has been encountered while compiling
    89      */
    90     @Test
    91     public void testConditionSearchExpression() throws ParseError, SearchCompiler.ParseError {
     89     * @throws SearchParseError if an error has been encountered while compiling
     90     */
     91    @Test
     92    public void testConditionSearchExpression() throws ParseError, SearchParseError {
    9293        TemplateParser parser = new TemplateParser("?{ admin_level = 2 'NUTS 1' | admin_level = 4 'NUTS 2' |  '{admin_level}'}");
    9394        Condition condition = new Condition();
Note: See TracChangeset for help on using the changeset viewer.