Skip to content

Commit ee8f8d8

Browse files
Copilotshai-almog
andauthored
fix: dedupe generated material icon constants (#4765)
Agent-Logs-Url: https://github.com/codenameone/CodenameOne/sessions/3593e9e8-7f99-4e92-b224-3a3ed76e99cd Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: shai-almog <67850168+shai-almog@users.noreply.github.com>
1 parent 8760054 commit ee8f8d8

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

.github/scripts/update_material_icons.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,20 @@ def parse_codepoints(codepoints_text: str) -> list[tuple[str, str]]:
6262
return out
6363

6464

65+
def dedupe_entries(
66+
entries: list[tuple[str, str]]
67+
) -> tuple[list[tuple[str, str]], list[tuple[str, str, str]]]:
68+
deduped: dict[str, tuple[str, str]] = {}
69+
duplicates: list[tuple[str, str, str]] = []
70+
for icon_name, codepoint in entries:
71+
const_name = material_constant_name(icon_name)
72+
previous = deduped.get(const_name)
73+
if previous is not None:
74+
duplicates.append((const_name, previous[1].upper(), codepoint.upper()))
75+
deduped[const_name] = (icon_name, codepoint)
76+
return list(deduped.values()), duplicates
77+
78+
6579
def java_char_literal(codepoint: str) -> str | None:
6680
value = int(codepoint, 16)
6781
if value > MAX_JAVA_CHAR_CODEPOINT:
@@ -142,7 +156,17 @@ def main() -> int:
142156
remote_font = download_bytes(MATERIAL_FONT_URL)
143157
codepoints = download_text(MATERIAL_CODEPOINTS_URL)
144158
entries = parse_codepoints(codepoints)
159+
entries, duplicates = dedupe_entries(entries)
145160
constants_block, skipped = generate_constants_block(entries)
161+
if duplicates:
162+
duplicate_names = ", ".join(
163+
f"{const_name} (U+{old_codepoint} -> U+{new_codepoint})"
164+
for const_name, old_codepoint, new_codepoint in duplicates
165+
)
166+
print(
167+
"Deduplicating repeated Material icon constant names by keeping the last "
168+
f"codepoint: {duplicate_names}"
169+
)
146170
if skipped:
147171
skipped_names = ", ".join(
148172
f"{const_name} (U+{codepoint})" for const_name, codepoint in skipped

0 commit comments

Comments
 (0)