Changeset 6773 in josm


Ignore:
Timestamp:
2014-01-29T21:30:14+01:00 (8 years ago)
Author:
simon04
Message:

see ticket:9361#comment:13 - MapCSS validator: highlight both primitives for spatial tests - patch by akks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java

    r6762 r6773  
    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;
     
    361363         */
    362364        TestError getErrorForPrimitive(OsmPrimitive p) {
    363             return getErrorForPrimitive(p, whichSelectorMatchesPrimitive(p));
    364         }
    365 
    366         TestError getErrorForPrimitive(OsmPrimitive p, Selector matchingSelector) {
     365            final Environment env = new Environment().withPrimitive(p);
     366            return getErrorForPrimitive(p, whichSelectorMatchesEnvironment(env), env);
     367        }
     368
     369        TestError getErrorForPrimitive(OsmPrimitive p, Selector matchingSelector, Environment env) {
    367370            if (matchingSelector != null && !errors.isEmpty()) {
    368371                final Command fix = fixPrimitive(p);
    369372                final String description = getDescriptionForMatchingSelector(p, matchingSelector);
     373                final List<OsmPrimitive> primitives;
     374                if (env.child != null) {
     375                    primitives = Arrays.asList(p, env.child);
     376                } else {
     377                    primitives = Collections.singletonList(p);
     378                }
    370379                if (fix != null) {
    371                     return new FixableTestError(null, getSeverity(), description, null, matchingSelector.toString(), 3000, p, fix);
     380                    return new FixableTestError(null, getSeverity(), description, null, matchingSelector.toString(), 3000, primitives, fix);
    372381                } else {
    373                     return new TestError(null, getSeverity(), description, null, matchingSelector.toString(), 3000, p);
     382                    return new TestError(null, getSeverity(), description, null, matchingSelector.toString(), 3000, primitives);
    374383                }
    375384            } else {
     
    407416            if (selector != null) {
    408417                check.rule.execute(env);
    409                 final TestError error = check.getErrorForPrimitive(p, selector);
     418                final TestError error = check.getErrorForPrimitive(p, selector, env);
    410419                if (error != null) {
    411420                    error.setTester(new MapCSSTagCheckerAndRule(check.rule));
Note: See TracChangeset for help on using the changeset viewer.