From 2759e0dd37585ef45d9be92b1324d005239b21bd Mon Sep 17 00:00:00 2001
From: Taylor Smock <taylor.smock@kaartgroup.com>
Date: Fri, 16 Nov 2018 08:44:42 -0700
Subject: [PATCH] Initial work on getting get_parent_ids working

---
 .../mappaint/mapcss/ExpressionFactory.java    | 26 +++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java b/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java
index f49ac9390..fe98489e6 100644
--- a/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java
+++ b/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java
@@ -518,6 +518,32 @@ public final class ExpressionFactory {
             return env.parent == null ? null : env.parent.getUniqueId();
         }
 
+        /**
+         * Gets a list of all OSM id's of the object's parent(s).
+         *
+         * The values are sorted according to {@link AlphanumComparator}.
+         * @param env the environment
+         * @return a list of non-null values of the OSM id's from the object's parent(s)
+         */
+        public static List<Long> parent_osm_ids(final Environment env) { // NO_UCD (unused code)
+            if (env.parent == null) {
+                if (env.osm != null) {
+                    final Collection<Long> ids = new TreeSet<>();
+                    //final Collection<Long> ids = new Collection<>();
+                    // we don't have a matched parent, so just search all referrers
+                    for (IPrimitive parent : env.osm.getReferrers()) {
+                        Long value = parent.getUniqueId();
+                        if (value != null) {
+                            ids.add(value);
+                        }
+                    }
+                    return new ArrayList<>(ids);
+                }
+                return Collections.emptyList();
+            }
+            return Collections.singletonList(parent_osm_id(env));
+        }
+
         /**
          * Determines whether the object has a tag with the given key.
          * @param env the environment
-- 
2.17.2 (Apple Git-113)

