Skip to content

feat: add data container context hints to DESCRIBE PAGE#168

Merged
ako merged 1 commit intomendixlabs:mainfrom
engalar:fix/data-container-hints
Apr 10, 2026
Merged

feat: add data container context hints to DESCRIBE PAGE#168
ako merged 1 commit intomendixlabs:mainfrom
engalar:fix/data-container-hints

Conversation

@engalar
Copy link
Copy Markdown
Contributor

@engalar engalar commented Apr 10, 2026

Summary

  • Add -- Context: comments inside data containers (DataView, DataGrid2, ListView, Gallery) in DESCRIBE PAGE output showing available variables ($currentObject with entity type, $widgetName selection for list containers)
  • Add LSP completion for $ variable references ($currentObject, page parameters) when editing MDL
  • Each nesting level shows its own context, so users know exactly what $currentObject resolves to at any position in the widget tree

Example output

DATAVIEW dataView1 (DataSource: $Prompt) {
    -- Context: $currentObject (Prompt)
    LISTVIEW listView3 (DataSource: DATABASE FROM ConversationalUI.TestCase ...) {
      -- Context: $currentObject (ConversationalUI.TestCase), $listView3 (selection)
      ...
    }
}

Test plan

  • Unit tests for outputDataContainerContext (4 cases: DataView, list container, empty entity, unnamed widget)
  • Unit tests for outputWidgetMDLV3 with EntityContext (DataView, ListView)
  • Unit tests for LSP extractPageParamNames and variableCompletionItems
  • Manual verification with baseline project (DESCRIBE PAGE shows context comments)
  • make build and make test pass

Closes #123

…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
@github-actions
Copy link
Copy Markdown

AI Code Review

What Looks Good

  • Feature implementation: The PR successfully adds data container context hints to DESCRIBE PAGE output (showing $currentObject entity type and $widgetName selection for list containers) and LSP completion for $ variable references ($currentObject, page parameters).
  • Test coverage: Includes comprehensive unit tests for:
    • outputDataContainerContext (4 cases: DataView, list container, empty entity, unnamed widget)
    • LSP extractPageParamNames and variableCompletionItems
    • Widget output with context (DataView and ListView examples)
  • Code quality:
    • Clean, focused helper function (outputDataContainerContext)
    • Consistent with existing MDL output patterns
    • Proper handling of edge cases (empty entity names, unnamed widgets)
    • Follows Go conventions and project structure
  • Documentation: Matches the example output shown in the PR description exactly
  • LSP integration: Completion items include proper labels, kinds, and helpful detail text

Minor Issues

  • LSP trigger condition: In lsp_completion.go, the completion triggers on any $ in the line prefix (if strings.Contains(linePrefix, "$")). This could potentially show completions in inappropriate contexts (e.g., inside string literals or comments). While harmless (just shows irrelevant suggestions), it could be refined to only trigger in MDL code contexts. However, this is a common LSP pattern and doesn't cause functional issues.

Recommendation

Approve. 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

Copy link
Copy Markdown
Collaborator

@ako ako left a comment

Choose a reason for hiding this comment

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

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 $currentObject resolves to at each nesting depth
  • List containers add $widgetName (selection) correctly
  • $currentObject always 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 $currentObject references 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.

@ako ako merged commit 73f6683 into mendixlabs:main Apr 10, 2026
1 of 2 checks passed
engalar added a commit to engalar/mxcli that referenced this pull request Apr 10, 2026
…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.
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.

hint for data container

2 participants