feat: add data container context hints to DESCRIBE PAGE#168
feat: add data container context hints to DESCRIBE PAGE#168ako merged 1 commit intomendixlabs:mainfrom
Conversation
…etion Show available variables ($currentObject, $widgetName selection) as -- Context: comments inside data containers (DataView, DataGrid2, ListView, Gallery) in DESCRIBE PAGE output. Add LSP completion for $ variable references including $currentObject and page parameters. Closes mendixlabs#123
AI Code ReviewWhat Looks Good
Minor Issues
RecommendationApprove. The PR delivers the requested feature with solid test coverage, follows existing patterns, and doesn't violate any checklist requirements (no new MDL syntax was added, so syntax design and full-stack consistency for new MDL features don't apply). The minor LSP trigger condition issue doesn't block approval as it's a usability refinement rather than a correctness problem. Automated review via OpenRouter (Nemotron Super 120B) — workflow source |
ako
left a comment
There was a problem hiding this comment.
Two related quality-of-life improvements that work well together — DESCRIBE output makes context explicit, LSP completion helps users discover what to type.
What's good
- Context comments are safe to roundtrip —
--is a regular comment, parser ignores them - Per-level context correctly shows what
$currentObjectresolves to at each nesting depth - List containers add
$widgetName (selection)correctly $currentObjectalways suggested by LSP, with partial-prefix filtering- Skips DECLARE lines to avoid suggesting microflow variables as page params
Concerns
extractPageParamNames is fragile. Line-by-line text scanning will:
- Pick up
$currentObjectreferences inside data containers as suggestion items (harmless but noisy) - Miss parameters split awkwardly across lines
For LSP completion this is acceptable (extra noise items, not wrong errors), but a // best-effort extraction comment would help maintainers. Even better: reuse the parser since the LSP server has parsed documents available.
EntityContext only set when DataSource != nil. Data containers using inherited context (e.g., nested DataView via association) won't get a context comment. Should fall back to the parent's context. Not blocking.
LSP completion is scope-naive. Suggests page params even inside microflow bodies where they're out of scope. Acceptable noise for an LSP enhancement.
LGTM.
…abs#168 review) Address 3 review comments from PR mendixlabs#168: 1. extractPageParamNames: switch from full-document $Name scanning to $Name: Type declaration pattern matching, eliminating false positives from $currentObject references, body $var usage, and comment lines. 2. EntityContext propagation: add parentEntityContext parameter to parseRawWidget() so nested containers without own DataSource inherit parent context. Propagate through all child-parsing functions. 3. LSP $ completion: add scanEnclosingDataContainer() that scans upward from cursor with brace matching to find nearest data container. Shows $currentObject with entity type and $widgetName selection variables.
Summary
-- Context:comments inside data containers (DataView, DataGrid2, ListView, Gallery) in DESCRIBE PAGE output showing available variables ($currentObjectwith entity type,$widgetNameselection for list containers)$variable references ($currentObject, page parameters) when editing MDL$currentObjectresolves to at any position in the widget treeExample output
DATAVIEW dataView1 (DataSource: $Prompt) { -- Context: $currentObject (Prompt) LISTVIEW listView3 (DataSource: DATABASE FROM ConversationalUI.TestCase ...) { -- Context: $currentObject (ConversationalUI.TestCase), $listView3 (selection) ... } }Test plan
outputDataContainerContext(4 cases: DataView, list container, empty entity, unnamed widget)outputWidgetMDLV3with EntityContext (DataView, ListView)extractPageParamNamesandvariableCompletionItemsmake buildandmake testpassCloses #123