Index: src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java
===================================================================
--- src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java	(revision 15193)
+++ src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java	(working copy)
@@ -28,6 +28,8 @@
 import org.openstreetmap.josm.data.osm.IPrimitive;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.data.osm.Relation;
+import org.openstreetmap.josm.data.osm.RelationMember;
 import org.openstreetmap.josm.data.osm.Way;
 import org.openstreetmap.josm.data.osm.search.SearchCompiler;
 import org.openstreetmap.josm.data.osm.search.SearchCompiler.Match;
@@ -570,6 +572,24 @@
         }

         /**
+         * Returns true if role is in relation. Returns false if not a relation or it does not have the role.
+         * @param env the environment
+         * @param role The roles to count in the relation
+         * @return The number of relation members with the specified role
+         * @since xxx
+         */
+        public static int count_role(final Environment env, String role) { // NO_UCD (unused code)
+            int rValue = 0;
+            if (env.osm instanceof Relation) {
+                Relation rel = (Relation) env.osm;
+                for (RelationMember member : rel.getMembers()) {
+                    if (role.equals(member.getRole())) rValue++;
+                }
+            }
+            return rValue;
+        }
+
+        /**
          * Returns the area of a closed way or multipolygon in square meters or {@code null}.
          * @param env the environment
          * @return the area of a closed way or multipolygon in square meters or {@code null}
