Skip to content

ADFA-3871 | Improve dropdown entries parsing and metadata detection#1261

Merged
jatezzz merged 3 commits intostagefrom
fix/ADFA-3871-improve-parser-logic-experimental
Apr 28, 2026
Merged

ADFA-3871 | Improve dropdown entries parsing and metadata detection#1261
jatezzz merged 3 commits intostagefrom
fix/ADFA-3871-improve-parser-logic-experimental

Conversation

@jatezzz
Copy link
Copy Markdown
Collaborator

@jatezzz jatezzz commented Apr 28, 2026

Description

This PR refines the parsing logic within the cv-image-to-xml module to improve accuracy:

  • AndroidWidget: Improved dropdown/spinner entries parsing. It now gracefully falls back to text attributes or box text, safely removes trailing dropdown glyphs (e.g., ▼, ⌄), and standardizes string arrays.
  • MarginAnnotationParser: Updated logic to process explicit blocks even when the canvasTags list is empty.
  • MetadataDetector: Removed the broad assignmentRegex check to prevent false positives when detecting canvas metadata.

Details

Logic-related updates:

  • Added toSpinnerEntries(), removeTrailingDropdownGlyph(), and isMeaningfulDropdownText() extension functions in AndroidWidget.kt to clean up text values.
  • Adjusted the boolean evaluation in MarginAnnotationParser.kt to include canvasTags.isEmpty().
  • Removed assignmentRegex from MetadataDetector.kt.
document_5154784628711625137.mp4

Ticket

ADFA-3871

Observation

The removal of the assignment-based metadata detection in MetadataDetector is intended to reduce false positives where standard text with colons or equals signs was being incorrectly flagged as canvas metadata.

Add trailing glyph removal for spinner entries, allow empty canvas tags, and remove broad assignment regex.
@jatezzz jatezzz requested review from a team, Daniel-ADFA and avestaadfa April 28, 2026 18:45
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c2d36c9d-b830-484c-90c8-32042ce6f43c

📥 Commits

Reviewing files that changed from the base of the PR and between 0ba7a54 and de74011.

📒 Files selected for processing (1)
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/xml/AndroidWidget.kt

📝 Walkthrough

Release Notes - ADFA-3871: Improve dropdown entries parsing and metadata detection

Features & Improvements

  • Enhanced Dropdown Entry Parsing: SpinnerWidget.processAttributes now intelligently sources spinner entries from multiple fallback locations (@entries attribute → @text attribute → box.text), with improved handling of dropdown glyphs and standardized string array storage

    • Parses inline entries by splitting on multiple delimiters (commas, semicolons, pipes, slashes, newlines)
    • Stores parsed entries in context.stringArrays using the pattern "{id}_array"
    • Properly handles both reference-style (@array/...) and inline entry definitions
  • Reduced False Positives in Canvas Metadata Detection: Removed generic assignment pattern matching (assignmentRegex) from MetadataDetector.isCanvasMetadata() to prevent incorrectly flagging ordinary text containing colons or equals signs as canvas metadata

  • Improved Annotation Processing: MarginAnnotationParser now processes explicit blocks even when canvasTags is empty, ensuring annotations are captured in scenarios with no canvas tag references

Risks & Considerations

  • Fallback Parsing Risk: The fallback to box.text for spinner entries may inadvertently parse unrelated text content if both @entries and @text attributes are missing. Recommend validating that fallback text matches expected dropdown patterns in integration testing

  • Metadata Detection Regression: Removing assignmentRegex may miss legitimate canvas metadata represented as simple key=value patterns. Monitor for any legitimate metadata that relies on this pattern and isn't caught by XML snippet or keyword checks

  • Glyph Removal Scope: The new removeTrailingDropdownGlyph() function removes trailing Unicode dropdown symbols globally. Verify that no legitimate text values end with these glyphs (▼, ⌄, etc.) in target UI components

Walkthrough

The PR updates explicit-tag annotation assignment in MarginAnnotationParser, refactors SpinnerWidget to derive and normalize spinner entries (including storing inline lists as string arrays), and removes generic key/value inference from MetadataDetector's canvas-metadata detection.

Changes

Cohort / File(s) Summary
Margin Annotation Processing
cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/MarginAnnotationParser.kt
When parsing explicit blocks, always set annotationMap[tag] = block.annotationText if canvasTags is empty (previously assigned only when tag existed in canvasTags).
Spinner Widget Entries Management
cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/xml/AndroidWidget.kt
SpinnerWidget.processAttributes now sources entries from attrs[entries], then attrs[text], then box.text (excluding literal "dropdown" markers). If source starts with @ it is copied (escaped); otherwise inline content is split/normalized into a string array stored in context.stringArrays and entries is set to an @array/{id}_array reference. XML-escaping is skipped for entries and text.
Metadata Detection Simplification
cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/utils/MetadataDetector.kt
Removed the generic key/value assignmentRegex inference and related counting logic; isCanvasMetadata no longer treats generic assignments as canvas metadata and returns false when no XML/attribute/keyword matches are found.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • avestaadfa
  • Daniel-ADFA

"I nibble tags and strings with glee,
margins fed when canvases flee,
spinners learn lists that once were terse,
metadata pruned from verbose verse —
hop, parse, and ship with rabbit mirth!" 🐇✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main changes: improving dropdown entries parsing and metadata detection, which aligns with the primary objectives of the PR.
Description check ✅ Passed The description is well-related to the changeset, providing clear details about all three main modifications and linking to the associated ticket.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ADFA-3871-improve-parser-logic-experimental

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/xml/AndroidWidget.kt`:
- Around line 97-100: The check using rawEntries.startsWith("@") should ignore
leading whitespace so values like "  `@array/options`" are treated as resource
references; in the block handling AttributeKey.ENTRIES.xmlName, first compute a
trimmedLeading = rawEntries.trimStart() (or similar) and use
trimmedLeading.startsWith("@") for the branch decision, and when storing into
processed[AttributeKey.ENTRIES.xmlName] call escapeXmlAttr() on the
trimmedLeading value so the resource reference is preserved and escaped
correctly (update the condition and the value passed to escapeXmlAttr() in the
rawEntries -> processed handling).
- Around line 126-129: The current removeTrailingDropdownGlyph extension on
String uses a regex that removes ASCII 'v' and 'V' and therefore strips valid
trailing characters (function: String.removeTrailingDropdownGlyph); update the
regex to only target actual dropdown glyphs (use their Unicode code points or
named characters) and remove 'v' and 'V' from the character class—e.g., replace
Regex("\\s*[▼▽▾▿⌄˅∨vV]$") with one that omits ASCII v/V (for example
Regex("\\s*[▼▽▾▿⌄˅∨]$") or explicitly list Unicode escapes like
"\\s*[\\u25BC\\u25BD\\u25BE...]$") so legitimate trailing 'v'/'V' in values
(e.g., "SUV") are preserved.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cd07db65-f17d-4adf-b7af-c001ab5ab9a3

📥 Commits

Reviewing files that changed from the base of the PR and between 14898ac and 0ba7a54.

📒 Files selected for processing (3)
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/MarginAnnotationParser.kt
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/xml/AndroidWidget.kt
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/utils/MetadataDetector.kt

@jatezzz jatezzz merged commit 50e4477 into stage Apr 28, 2026
2 checks passed
@jatezzz jatezzz deleted the fix/ADFA-3871-improve-parser-logic-experimental branch April 28, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants