- Timestamp:
- 2021-04-19T19:03:29+02:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerAsserts.java
r17758 r17792 2 2 package org.openstreetmap.josm.data.validation.tests; 3 3 4 import java.lang.reflect.Method;5 4 import java.text.MessageFormat; 6 5 import java.util.ArrayList; … … 22 21 import org.openstreetmap.josm.data.osm.Way; 23 22 import org.openstreetmap.josm.data.validation.TestError; 24 import org.openstreetmap.josm.gui.mappaint.Environment;25 23 import org.openstreetmap.josm.gui.mappaint.mapcss.ConditionFactory; 26 24 import org.openstreetmap.josm.gui.mappaint.mapcss.ExpressionFactory; 27 import org.openstreetmap.josm.gui.mappaint.mapcss.Functions;28 25 import org.openstreetmap.josm.gui.mappaint.mapcss.LiteralExpression; 29 26 import org.openstreetmap.josm.gui.mappaint.mapcss.Selector; … … 53 50 static void checkAsserts(final MapCSSTagCheckerRule check, final Map<String, Boolean> assertions, 54 51 final MapCSSTagChecker.AssertionConsumer assertionConsumer) { 55 final Method insideMethod = getFunctionMethod("inside");56 52 final DataSet ds = new DataSet(); 57 53 Logging.debug("Check: {0}", check); 58 54 for (final Map.Entry<String, Boolean> i : assertions.entrySet()) { 59 55 Logging.debug("- Assertion: {0}", i); 60 final OsmPrimitive p = OsmUtils.createPrimitive(i.getKey(), getLocation(check , insideMethod), true);56 final OsmPrimitive p = OsmUtils.createPrimitive(i.getKey(), getLocation(check), true); 61 57 // Build minimal ordered list of checks to run to test the assertion 62 58 List<Set<MapCSSTagCheckerRule>> checksToRun = new ArrayList<>(); … … 94 90 } 95 91 96 private static Method getFunctionMethod(String method) {97 try {98 return Functions.class.getDeclaredMethod(method, Environment.class, String.class);99 } catch (NoSuchMethodException | SecurityException e) {100 Logging.error(e);101 return null;102 }103 }104 105 92 private static void addPrimitive(DataSet ds, OsmPrimitive p) { 106 93 if (p instanceof Way) { … … 112 99 } 113 100 114 private static LatLon getLocation(MapCSSTagCheckerRule check , Method insideMethod) {115 Optional<String> inside = getFirstInsideCountry(check , insideMethod);101 private static LatLon getLocation(MapCSSTagCheckerRule check) { 102 Optional<String> inside = getFirstInsideCountry(check); 116 103 if (inside.isPresent()) { 117 104 GeoPropertyIndex<Boolean> index = Territories.getGeoPropertyIndex(inside.get()); … … 126 113 } 127 114 128 private static Optional<String> getFirstInsideCountry(MapCSSTagCheckerRule check , Method insideMethod) {115 private static Optional<String> getFirstInsideCountry(MapCSSTagCheckerRule check) { 129 116 return check.rule.selectors.stream() 130 117 .filter(s -> s instanceof Selector.GeneralSelector)
Note:
See TracChangeset
for help on using the changeset viewer.