Changeset 15984 in josm


Ignore:
Timestamp:
2020-03-01T23:35:58+01:00 (3 months ago)
Author:
simon04
Message:

see #18802 - Add MapCSSRule.matches

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/scripts/TagInfoExtract.java

    r15692 r15984  
    394394                for (MapCSSRule r : styleSource.rules) {
    395395                    env.clearSelectorMatchingInformation();
    396                     if (r.selector.matches(env)) {
     396                    if (r.matches(env)) {
    397397                        // ignore selector range
    398398                        if (env.layer == null) {
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java

    r15983 r15984  
    702702            MapCSSRule r = candidates.next();
    703703            env.clearSelectorMatchingInformation();
    704             if (r.selector.matches(env)) { // as side effect env.parent will be set (if s is a child selector)
     704            if (r.matches(env)) { // as side effect env.parent will be set (if s is a child selector)
    705705                TagCheck check = indexData.getCheck(r);
    706706                if (check != null) {
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSRule.java

    r15983 r15984  
    3535
    3636    /**
     37     * Test whether the selector of this rule applies to the primitive.
     38     *
     39     * @param env the Environment. env.mc and env.layer are read-only when matching a selector.
     40     * env.source is not needed. This method will set the matchingReferrers field of env as
     41     * a side effect! Make sure to clear it before invoking this method.
     42     * @return true, if the selector applies
     43     * @see Selector#matches
     44     */
     45    public boolean matches(Environment env) {
     46        return selector.matches(env);
     47    }
     48
     49    /**
    3750     * <p>Executes the instructions against the environment {@code env}</p>
    3851     *
    3952     * @param env the environment
     53     * @see Declaration#execute
    4054     */
    4155    public void execute(Environment env) {
  • trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.java

    r15935 r15984  
    452452        assertEquals(1, source.rules.size());
    453453        Environment e = new Environment(n, new MultiCascade(), Environment.DEFAULT_LAYER, null);
    454         assertTrue(source.rules.get(0).selector.matches(e));
     454        assertTrue(source.rules.get(0).matches(e));
    455455        source.rules.get(0).declaration.execute(e);
    456456        assertEquals("x2;x10", e.getCascade(Environment.DEFAULT_LAYER).get("refs", null, String.class));
     
    467467        assertEquals(1, source.rules.size());
    468468        Environment e = new Environment(way1, new MultiCascade(), Environment.DEFAULT_LAYER, null);
    469         assertTrue(source.rules.get(0).selector.matches(e));
     469        assertTrue(source.rules.get(0).matches(e));
    470470        source.rules.get(0).declaration.execute(e);
    471471        assertEquals(Functions.join(",", "Alpha", "Beta"), e.getCascade(Environment.DEFAULT_LAYER).get("sorted", null, String.class));
     
    474474        source.loadStyleSource();
    475475        e = new Environment(way1, new MultiCascade(), Environment.DEFAULT_LAYER, null);
    476         assertTrue(source.rules.get(0).selector.matches(e));
     476        assertTrue(source.rules.get(0).matches(e));
    477477        source.rules.get(0).declaration.execute(e);
    478478        assertEquals(Functions.join(",", "A8", "A9"), e.getCascade(Environment.DEFAULT_LAYER).get("sorted", null, String.class));
     
    532532        assertEquals(1, source.rules.size());
    533533        e = new Environment(rel1, new MultiCascade(), Environment.DEFAULT_LAYER, null);
    534         assertTrue(source.rules.get(0).selector.matches(e));
     534        assertTrue(source.rules.get(0).matches(e));
    535535        source.rules.get(0).declaration.execute(e);
    536536        assertEquals((Integer) 1, e.getCascade(Environment.DEFAULT_LAYER).get("roles", null, Integer.class));
Note: See TracChangeset for help on using the changeset viewer.