Ticket #9361: showBothOverlapping.patch

File showBothOverlapping.patch, 2.9 KB (added by akks, 12 years ago)
  • src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java

     
    77import java.io.IOException;
    88import java.io.Reader;
    99import java.util.ArrayList;
     10import java.util.Arrays;
    1011import java.util.Collection;
     12import java.util.Collections;
    1113import java.util.HashMap;
    1214import java.util.Iterator;
    1315import java.util.LinkedHashMap;
     
    359361         * @param p the primitive to construct the error for
    360362         * @return an instance of {@link TestError}, or returns null if the primitive does not give rise to an error.
    361363         */
    362         TestError getErrorForPrimitive(OsmPrimitive p) {
    363             return getErrorForPrimitive(p, whichSelectorMatchesPrimitive(p));
     364        TestError getErrorForPrimitive(OsmPrimitive p, Environment env) {
     365            return getErrorForPrimitive(p, whichSelectorMatchesPrimitive(p), env);
    364366        }
    365367
    366         TestError getErrorForPrimitive(OsmPrimitive p, Selector matchingSelector) {
     368        TestError getErrorForPrimitive(OsmPrimitive p, Selector matchingSelector, Environment env) {
    367369            if (matchingSelector != null && !errors.isEmpty()) {
    368370                final Command fix = fixPrimitive(p);
    369371                final String description = getDescriptionForMatchingSelector(p, matchingSelector);
     372                List<OsmPrimitive> prims;
     373                if (env.child != null) {
     374                    prims = Arrays.asList(p, env.child);
     375                } else {
     376                    prims = Collections.singletonList(p);
     377                }
    370378                if (fix != null) {
    371                     return new FixableTestError(null, getSeverity(), description, null, matchingSelector.toString(), 3000, p, fix);
     379                    return new FixableTestError(null, getSeverity(), description, null, matchingSelector.toString(), 3000, prims, fix);
    372380                } else {
    373                     return new TestError(null, getSeverity(), description, null, matchingSelector.toString(), 3000, p);
     381                    return new TestError(null, getSeverity(), description, null, matchingSelector.toString(), 3000, prims);
    374382                }
    375383            } else {
    376384                return null;
     
    406414            final Selector selector = check.whichSelectorMatchesEnvironment(env);
    407415            if (selector != null) {
    408416                check.rule.execute(env);
    409                 final TestError error = check.getErrorForPrimitive(p, selector);
     417                final TestError error = check.getErrorForPrimitive(p, selector, env);
    410418                if (error != null) {
    411419                    error.setTester(new MapCSSTagCheckerAndRule(check.rule));
    412420                    r.add(error);