Changeset 17261 in josm for trunk/src


Ignore:
Timestamp:
2020-10-24T11:54:52+02:00 (4 years ago)
Author:
GerdP
Message:

see #19956 Double check if error still exists before executing autofix

  • revert r17252. There are more tests that don't work with this. Have to double check my patch first ;)
Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

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

    r17252 r17261  
    1111import java.util.List;
    1212import java.util.Locale;
    13 import java.util.Set;
    1413import java.util.TreeSet;
    1514import java.util.function.Supplier;
     
    2524import org.openstreetmap.josm.data.osm.Way;
    2625import org.openstreetmap.josm.data.osm.WaySegment;
    27 import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker;
    2826import org.openstreetmap.josm.data.validation.util.MultipleNameVisitor;
    29 import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    3027import org.openstreetmap.josm.tools.AlphanumComparator;
    3128import org.openstreetmap.josm.tools.CheckParameterUtil;
    3229import org.openstreetmap.josm.tools.I18n;
    33 import org.openstreetmap.josm.tools.Logging;
    3430
    3531/**
     
    549545    }
    550546
    551     /**
    552      * Test if the primitives still show the same error. Maybe data was already changed. See #19956
    553      * @return updated test or null if error cannot be reproduced.
    554      * @since 17252
    555      */
    556     public TestError doubleCheck() {
    557         // see #19956 check again
    558         if (getTester() instanceof MapCSSTagChecker)
    559             return this;
    560         Test tester2;
    561         try {
    562             tester2 = getTester().getClass().newInstance();
    563             Set<OsmPrimitive> toFix = primitives.stream()
    564                     .filter(tester2::isPrimitiveUsable)
    565                     .collect(Collectors.toSet());
    566             if (toFix.isEmpty())
    567                 return null;
    568 
    569             tester2.startTest(NullProgressMonitor.INSTANCE);
    570             tester2.visit(toFix);
    571             tester2.endTest();
    572             for (TestError e : tester2.getErrors()) {
    573                 if (e.getCode() == this.getCode()) {
    574                     return e;
    575                 }
    576             }
    577         } catch (InstantiationException | IllegalAccessException e1) {
    578             Logging.error(e1);
    579         }
    580         return null;
    581 
    582     }
    583 
    584547}
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java

    r17252 r17261  
    628628            if (error.isFixable()) {
    629629                if (error.getPrimitives().stream().noneMatch(p -> p.isDeleted() || p.getDataSet() == null)) {
    630                     TestError checked = error.doubleCheck();
    631                     if (checked != null) {
    632                         final Command fixCommand = checked.getFix();
    633                         if (fixCommand != null) {
    634                             SwingUtilities.invokeAndWait(fixCommand::executeCommand);
    635                             fixCommands.add(fixCommand);
    636                         }
     630                    final Command fixCommand = error.getFix();
     631                    if (fixCommand != null) {
     632                        SwingUtilities.invokeAndWait(fixCommand::executeCommand);
     633                        fixCommands.add(fixCommand);
    637634                    }
    638635                }
Note: See TracChangeset for help on using the changeset viewer.