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

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

Location:
trunk/src/org/openstreetmap/josm/data
Files:
3 added
6 edited
2 moved

Legend:

Unmodified
Added
Removed
  • 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;
Note: See TracChangeset for help on using the changeset viewer.