Changeset 16358 in josm
- Timestamp:
- 2020-04-19T14:54:59+02:00 (5 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MainInitialization.java
r16321 r16358 8 8 import java.util.Arrays; 9 9 import java.util.Collection; 10 import java.util.Collections; 10 11 import java.util.List; 11 12 import java.util.Objects; … … 37 38 import org.openstreetmap.josm.tools.Logging; 38 39 import org.openstreetmap.josm.tools.OpenBrowser; 39 import org.openstreetmap.josm.tools.OverpassTurboQueryWizard;40 40 import org.openstreetmap.josm.tools.PlatformManager; 41 41 import org.openstreetmap.josm.tools.Shortcut; … … 127 127 @Override 128 128 public List<Callable<?>> asynchronousCallableTasks() { 129 return Arrays.asList( 130 OverpassTurboQueryWizard::getInstance 131 ); 129 return Collections.emptyList(); 132 130 } 133 131 -
trunk/src/org/openstreetmap/josm/gui/download/OverpassQueryWizardDialog.java
r16355 r16358 16 16 import org.openstreetmap.josm.gui.download.overpass.OverpassWizardRegistration.OverpassWizardCallbacks; 17 17 import org.openstreetmap.josm.tools.Logging; 18 import org.openstreetmap.josm.tools. OverpassTurboQueryWizard;18 import org.openstreetmap.josm.tools.SearchCompilerQueryWizard; 19 19 import org.openstreetmap.josm.tools.UncheckedParseException; 20 20 import org.openstreetmap.josm.tools.Utils; … … 82 82 83 83 /** 84 * Tries to process a search term using {@link OverpassTurboQueryWizard}. If the term cannot84 * Tries to process a search term using {@link SearchCompilerQueryWizard}. If the term cannot 85 85 * be parsed, the the corresponding dialog is shown. 86 86 * @param searchTerm The search term to parse. … … 91 91 private Optional<String> tryParseSearchTerm(String searchTerm) { 92 92 try { 93 return Optional.of( OverpassTurboQueryWizard.getInstance().constructQuery(searchTerm));93 return Optional.of(SearchCompilerQueryWizard.getInstance().constructQuery(searchTerm)); 94 94 } catch (UncheckedParseException | IllegalStateException ex) { 95 95 Logging.error(ex); -
trunk/src/org/openstreetmap/josm/tools/SearchCompilerQueryWizard.java
r16357 r16358 24 24 * @since 8744 (using tyrasd/overpass-wizard), 16262 (standalone) 25 25 */ 26 public final class OverpassTurboQueryWizard {27 28 private static final OverpassTurboQueryWizard instance = newOverpassTurboQueryWizard();26 public final class SearchCompilerQueryWizard { 27 28 private static final SearchCompilerQueryWizard instance = new SearchCompilerQueryWizard(); 29 29 30 30 /** … … 33 33 * @return the unique instance of this class 34 34 */ 35 public static OverpassTurboQueryWizard getInstance() {35 public static SearchCompilerQueryWizard getInstance() { 36 36 return instance; 37 37 } 38 38 39 private OverpassTurboQueryWizard() {39 private SearchCompilerQueryWizard() { 40 40 // private constructor for utility class 41 41 } … … 182 182 private static List<Match> normalizeToDNF(final Match match) { 183 183 if (match instanceof SearchCompiler.And) { 184 return ((SearchCompiler.And) match).map( OverpassTurboQueryWizard::normalizeToDNF, (lhs, rhs) -> lhs.stream()184 return ((SearchCompiler.And) match).map(SearchCompilerQueryWizard::normalizeToDNF, (lhs, rhs) -> lhs.stream() 185 185 .flatMap(l -> rhs.stream().map(r -> new SearchCompiler.And(l, r))) 186 186 .collect(Collectors.toList())); 187 187 } else if (match instanceof SearchCompiler.Or) { 188 return ((SearchCompiler.Or) match).map( OverpassTurboQueryWizard::normalizeToDNF, CompositeList::new);188 return ((SearchCompiler.Or) match).map(SearchCompilerQueryWizard::normalizeToDNF, CompositeList::new); 189 189 } else if (match instanceof SearchCompiler.Xor) { 190 190 throw new UnsupportedOperationException(match.toString()); -
trunk/test/unit/org/openstreetmap/josm/io/OverpassDownloadReaderTest.java
r15821 r16358 22 22 import org.openstreetmap.josm.io.OverpassDownloadReader.OverpassOutpoutFormat; 23 23 import org.openstreetmap.josm.testutils.JOSMTestRules; 24 import org.openstreetmap.josm.tools. OverpassTurboQueryWizard;24 import org.openstreetmap.josm.tools.SearchCompilerQueryWizard; 25 25 import org.openstreetmap.josm.tools.Utils; 26 26 import org.openstreetmap.josm.tools.date.DateUtils; … … 59 59 60 60 private String getExpandedQuery(String search) { 61 final String query = OverpassTurboQueryWizard.getInstance().constructQuery(search);61 final String query = SearchCompilerQueryWizard.getInstance().constructQuery(search); 62 62 final String request = new OverpassDownloadReader(new Bounds(1, 2, 3, 4), null, query) 63 63 .getRequestForBbox(1, 2, 3, 4) -
trunk/test/unit/org/openstreetmap/josm/tools/SearchCompilerQueryWizardTest.java
r16357 r16358 12 12 13 13 /** 14 * Unit tests of {@link OverpassTurboQueryWizard} class.14 * Unit tests of {@link SearchCompilerQueryWizard} class. 15 15 */ 16 public class OverpassTurboQueryWizardTest {16 public class SearchCompilerQueryWizardTest { 17 17 /** 18 18 * Base test environment is enough … … 22 22 public JOSMTestRules test = new JOSMTestRules().i18n("de"); 23 23 24 private static String constructQuery(String s) { 25 return SearchCompilerQueryWizard.getInstance().constructQuery(s); 26 } 27 24 28 private void assertQueryEquals(String expectedQueryPart, String input) { 25 final String query = OverpassTurboQueryWizard.getInstance().constructQuery(input);29 final String query = constructQuery(input); 26 30 assertEquals("" + 27 31 "[out:xml][timeout:90][bbox:{{bbox}}];\n" + … … 139 143 @Test 140 144 public void testInArea() { 141 String query = OverpassTurboQueryWizard.getInstance().constructQuery("foo=bar | foo=baz in Innsbruck");145 String query = constructQuery("foo=bar | foo=baz in Innsbruck"); 142 146 assertEquals("" + 143 147 "[out:xml][timeout:90];\n" + … … 149 153 "(._;>;);\n" + 150 154 "out meta;", query); 151 query = OverpassTurboQueryWizard.getInstance().constructQuery("foo=bar | foo=baz in \"Sankt Sigmund im Sellrain\"");155 query = constructQuery("foo=bar | foo=baz in \"Sankt Sigmund im Sellrain\""); 152 156 assertEquals("" + 153 157 "[out:xml][timeout:90];\n" + … … 159 163 "(._;>;);\n" + 160 164 "out meta;", query); 161 query = OverpassTurboQueryWizard.getInstance().constructQuery("foo=bar | foo=baz in \"Новосибирск\"");165 query = constructQuery("foo=bar | foo=baz in \"Новосибирск\""); 162 166 assertEquals("" + 163 167 "[out:xml][timeout:90];\n" + … … 176 180 @Test 177 181 public void testAroundArea() { 178 final String query = OverpassTurboQueryWizard.getInstance().constructQuery("foo=bar | foo=baz around \"Sankt Sigmund im Sellrain\"");182 final String query = constructQuery("foo=bar | foo=baz around \"Sankt Sigmund im Sellrain\""); 179 183 assertEquals("" + 180 184 "[out:xml][timeout:90];\n" + … … 193 197 @Test 194 198 public void testGlobal() { 195 final String query = OverpassTurboQueryWizard.getInstance().constructQuery("foo=bar global");199 final String query = constructQuery("foo=bar global"); 196 200 assertEquals("" + 197 201 "[out:xml][timeout:90];\n" + … … 225 229 @Test(expected = UncheckedParseException.class) 226 230 public void testErroneous() { 227 OverpassTurboQueryWizard.getInstance().constructQuery("-(foo or bar)");231 constructQuery("-(foo or bar)"); 228 232 } 229 233 }
Note:
See TracChangeset
for help on using the changeset viewer.