Index: /trunk/src/org/openstreetmap/josm/actions/search/InView.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/search/InView.java	(revision 12662)
+++ /trunk/src/org/openstreetmap/josm/actions/search/InView.java	(revision 12662)
@@ -0,0 +1,34 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.actions.search;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import org.openstreetmap.josm.data.Bounds;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.data.osm.search.SearchCompiler.InArea;
+import org.openstreetmap.josm.gui.MainApplication;
+
+/**
+ * Matches objects within current map view.
+ * @since 12662 (extracted from {@code SearchCompiler})
+ */
+class InView extends InArea {
+
+    InView(boolean all) {
+        super(all);
+    }
+
+    @Override
+    protected Collection<Bounds> getBounds(OsmPrimitive primitive) {
+        if (!MainApplication.isDisplayingMapView()) {
+            return null;
+        }
+        return Collections.singleton(MainApplication.getMap().mapView.getRealBounds());
+    }
+
+    @Override
+    public String toString() {
+        return all ? "allinview" : "inview";
+    }
+}
Index: /trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java	(revision 12661)
+++ /trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java	(revision 12662)
@@ -47,8 +47,11 @@
 import org.openstreetmap.josm.data.osm.Filter;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.data.osm.search.PushbackTokenizer;
+import org.openstreetmap.josm.data.osm.search.SearchCompiler;
+import org.openstreetmap.josm.data.osm.search.SearchCompiler.Match;
+import org.openstreetmap.josm.data.osm.search.SearchCompiler.SimpleMatchFactory;
+import org.openstreetmap.josm.data.osm.search.SearchMode;
 import org.openstreetmap.josm.data.osm.search.SearchParseError;
 import org.openstreetmap.josm.data.osm.search.SearchSetting;
-import org.openstreetmap.josm.data.osm.search.SearchCompiler;
-import org.openstreetmap.josm.data.osm.search.SearchMode;
 import org.openstreetmap.josm.gui.ExtendedDialog;
 import org.openstreetmap.josm.gui.MainApplication;
@@ -89,4 +92,23 @@
     private static final LinkedList<SearchSetting> searchHistory = new LinkedList<>();
     static {
+        SearchCompiler.addMatchFactory(new SimpleMatchFactory() {
+            @Override
+            public Collection<String> getKeywords() {
+                return Arrays.asList("inview", "allinview");
+            }
+
+            @Override
+            public Match get(String keyword, PushbackTokenizer tokenizer) throws SearchParseError {
+                switch(keyword) {
+                case "inview":
+                    return new InView(false);
+                case "allinview":
+                    return new InView(true);
+                default:
+                    throw new IllegalStateException("Not expecting keyword " + keyword);
+                }
+            }
+        });
+
         for (String s: Main.pref.getCollection("search.history", Collections.<String>emptyList())) {
             SearchSetting ss = SearchSetting.readFromString(s);
Index: /trunk/src/org/openstreetmap/josm/data/osm/search/SearchCompiler.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/osm/search/SearchCompiler.java	(revision 12661)
+++ /trunk/src/org/openstreetmap/josm/data/osm/search/SearchCompiler.java	(revision 12662)
@@ -36,5 +36,4 @@
 import org.openstreetmap.josm.data.osm.search.PushbackTokenizer.Range;
 import org.openstreetmap.josm.data.osm.search.PushbackTokenizer.Token;
-import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.mappaint.Environment;
 import org.openstreetmap.josm.gui.mappaint.mapcss.Selector;
@@ -124,5 +123,5 @@
                 "changeset", "nodes", "ways", "tags", "areasize", "waylength", "modified", "deleted", "selected",
                 "incomplete", "untagged", "closed", "new", "indownloadedarea",
-                "allindownloadedarea", "inview", "allinview", "timestamp", "nth", "nth%", "hasRole", "preset");
+                "allindownloadedarea", "timestamp", "nth", "nth%", "hasRole", "preset");
 
         @Override
@@ -147,8 +146,4 @@
             case "allindownloadedarea":
                 return new InDataSourceArea(true);
-            case "inview":
-                return new InView(false);
-            case "allinview":
-                return new InView(true);
             default:
                 if (tokenizer != null) {
@@ -1461,5 +1456,5 @@
      * Matches objects within the given bounds.
      */
-    private abstract static class InArea extends Match {
+    public abstract static class InArea extends Match {
 
         protected final boolean all;
@@ -1468,5 +1463,5 @@
          * @param all if true, all way nodes or relation members have to be within source area;if false, one suffices.
          */
-        InArea(boolean all) {
+        protected InArea(boolean all) {
             this.all = all;
         }
@@ -1539,27 +1534,4 @@
         public String toString() {
             return "NotOutsideDataSourceArea";
-        }
-    }
-
-    /**
-     * Matches objects within current map view.
-     */
-    private static class InView extends InArea {
-
-        InView(boolean all) {
-            super(all);
-        }
-
-        @Override
-        protected Collection<Bounds> getBounds(OsmPrimitive primitive) {
-            if (!MainApplication.isDisplayingMapView()) {
-                return null;
-            }
-            return Collections.singleton(MainApplication.getMap().mapView.getRealBounds());
-        }
-
-        @Override
-        public String toString() {
-            return all ? "allinview" : "inview";
         }
     }
