Changeset 7073 in josm for trunk/src


Ignore:
Timestamp:
2014-05-07T23:21:47+02:00 (11 years ago)
Author:
bastiK
Message:

see #9691 - really fix broken MapCSSTagChecker unit test

Location:
trunk/src/org/openstreetmap/josm/data
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/DataSet.java

    r7013 r7073  
    5555 * Dataset is threadsafe - accessing Dataset simultaneously from different threads should never
    5656 * lead to data corruption or ConccurentModificationException. However when for example one thread
    57  * removes primitive and other thread try to add another primitive reffering to the removed primitive,
     57 * removes primitive and other thread try to add another primitive referring to the removed primitive,
    5858 * DataIntegrityException will occur.
    5959 *
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java

    r7069 r7073  
    4848import org.openstreetmap.josm.io.UTFInputStreamReader;
    4949import org.openstreetmap.josm.tools.CheckParameterUtil;
    50 import org.openstreetmap.josm.tools.MultiMap;
    5150import org.openstreetmap.josm.tools.Predicate;
    5251import org.openstreetmap.josm.tools.Utils;
     
    192191            removeMetaRules(source);
    193192            // group rules with common declaration block
    194             MultiMap<MapCSSRule.Declaration, MapCSSRule> rules = new MultiMap<>();
     193            Map<Declaration, List<Selector>> g = new LinkedHashMap<>();
    195194            for (MapCSSRule rule : source.rules) {
    196                 rules.put(rule.declaration, rule);
     195                if (!g.containsKey(rule.declaration)) {
     196                    List<Selector> sels = new ArrayList<>();
     197                    sels.add(rule.selector);
     198                    g.put(rule.declaration, sels);
     199                } else {
     200                    g.get(rule.declaration).add(rule.selector);
     201                }
    197202            }
    198203            List<TagCheck> result = new ArrayList<>();
    199             for (Collection<MapCSSRule> rulesCommonDecl : rules.values()) {
    200                 List<Selector> selectors = new ArrayList<>();
    201                 for (MapCSSRule rule : rulesCommonDecl) {
    202                     selectors.add(rule.selector);
    203                 }
    204                 if (!rulesCommonDecl.isEmpty()) {
    205                     result.add(TagCheck.ofMapCSSRule(
    206                             new GroupedMapCSSRule(selectors, rulesCommonDecl.iterator().next().declaration)));
    207                 }
     204            for (Map.Entry<Declaration, List<Selector>> map : g.entrySet()) {
     205                result.add(TagCheck.ofMapCSSRule(
     206                        new GroupedMapCSSRule(map.getValue(), map.getKey())));
    208207            }
    209208            return result;
Note: See TracChangeset for help on using the changeset viewer.