Skip to content

Implement catalog binding support with async entry selection (requires LemMinx 0.40.0) - #2306

Open
angelozerr wants to merge 1 commit into
eclipse-wildwebdeveloper:masterfrom
angelozerr:associate_catalog_entry
Open

angelozerr wants to merge 1 commit into
eclipse-wildwebdeveloper:masterfrom
angelozerr:associate_catalog_entry

Conversation

@angelozerr

@angelozerr angelozerr commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Here a demo:

AssociateGrammarCatalogDemo
  • Add CatalogEntrySelectionDialog: quick-open style dialog for selecting bindable
    catalog entries, populated asynchronously via CompletableFuture
  • Add CatalogEntryLabelProvider: styled display of entries with entry type, identifier,
    and gray-colored catalog filename (disambiguated by path segments when needed)
  • Implement AssociateGrammarDialog with Catalog mode: radio button to switch between
    Local/Remote and Catalog modes, Browse button that fetches entries asynchronously
    with progress indicator
  • Modify AssociateGrammarHandler: fetch catalog entries only when user opens dialog,
    no blocking server calls in handler, fresh fetch each dialog open to reflect
    catalog changes
  • Add webURL support in XMLCatalogs: for WTP catalog contributions with webURL
    attributes on public entries, generate additional system entries pointing to web URLs

@merks

merks commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

@angelozerr

Note that we are finalizing the release of SimRel 2026-12 next Wednesday and will need to produce a release of WWD to contribute toward that. So the runway for getting changes in is very short and any changes now will effectively be untested by consumers. I can't judge the riskiness of the changes.

@angelozerr

Copy link
Copy Markdown
Contributor Author

@merks I am aware about that and there is a major problem with pom.xml where formatting is not enabled.

I did the fix in LemMinx 0.40.0 but before doing the release (hope today), I wanted to check that LemMinx 0.40.0 will not break WWD because there are so many changes.

So my idea is to implement all features in WWD that we have in vscode-xml to check that nothing is broken and new features works in WWD.

This PR has no risk since it is a new feature. I need to clean it few but I think it should be soon ready, but without 0.40.0 you cannot play with it.

I am integrating all features provided by 0.40.0 like:

@merks

merks commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

That all sounds good! I was aware of the formatting problem.

@merks

merks commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

@angelozerr

I just merged the change to update the target platform to LemMinX 0.40.0.

#2308

@angelozerr

angelozerr commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

@angelozerr

I just merged the change to update the target platform to LemMinX 0.40.0.

#2308

Thanks!

I have several pending PRs and I will create again another PRs.

Could you tell me what you think it will be super nice to have, just to know the priority.

I will try to do my best to implement the most LemMinx 0.40.0 features, but I will need your review :)

@merks

merks commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Could you tell me what you think it will be super nice to have, just to know the priority

I expect your judgement is likely better informed than mine. 🤓 Do what you believe will be of value to the most people!

@angelozerr
angelozerr marked this pull request as ready for review November 28, 2026 08:19
@angelozerr

Copy link
Copy Markdown
Contributor Author

@akurtakov please review this PR

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The pinned LemMinX version cannot support Catalog mode, unescaped contributed URLs can invalidate the catalog, and asynchronous callbacks can fail after dialogs close.

4 open issues
What changed in this PR

Adds catalog-based grammar binding to the XML association workflow, alongside local files and remote URLs. The feature requires LemMinX 0.40.0.

Changes:

  • Adds an asynchronous catalog picker with filtering, progress feedback, and disambiguated labels.
  • Reorganizes grammar-association classes and removes blocking server discovery.
  • Generates system catalog entries from WTP public entries with webURL attributes.
File Description
org.eclipse.wildwebdeveloper.xml/​src/​org/​eclipse/​wildwebdeveloper/​xml/​internal/​ui/​preferences/​XMLPreferenceInitializer.java Updates the dialog import after relocation.
org.eclipse.wildwebdeveloper.xml/​src/​org/​eclipse/​wildwebdeveloper/​xml/​internal/​ui/​preferences/​XMLCatalogs.java Generates system entries for contributed web URLs.
org.eclipse.wildwebdeveloper.xml/​src/​org/​eclipse/​wildwebdeveloper/​xml/​internal/​ui/​messages.properties Adds catalog selection and validation messages.
org.eclipse.wildwebdeveloper.xml/​src/​org/​eclipse/​wildwebdeveloper/​xml/​internal/​ui/​Messages.java Exposes the new localized messages.
org.eclipse.wildwebdeveloper.xml/​src/​org/​eclipse/​wildwebdeveloper/​xml/​internal/​commands/​AssociateGrammarHandler.java Removes the handler from its former package.
org.eclipse.wildwebdeveloper.xml/​src/​org/​eclipse/​wildwebdeveloper/​xml/​internal/​commands/​associate/​GrammarFileSelectionDialog.java Extracts the workspace grammar picker.
org.eclipse.wildwebdeveloper.xml/​src/​org/​eclipse/​wildwebdeveloper/​xml/​internal/​commands/​associate/​CatalogEntrySelectionDialog.java Adds asynchronous catalog loading and selection.
org.eclipse.wildwebdeveloper.xml/​src/​org/​eclipse/​wildwebdeveloper/​xml/​internal/​commands/​associate/​CatalogEntryLabelProvider.java Styles entries and disambiguates catalog filenames.
org.eclipse.wildwebdeveloper.xml/​src/​org/​eclipse/​wildwebdeveloper/​xml/​internal/​commands/​associate/​BindableCatalogEntry.java Defines the catalog entry data model.
org.eclipse.wildwebdeveloper.xml/​src/​org/​eclipse/​wildwebdeveloper/​xml/​internal/​commands/​associate/​AssociateGrammarHandler.java Fetches entries and submits catalog binding commands asynchronously.
org.eclipse.wildwebdeveloper.xml/​src/​org/​eclipse/​wildwebdeveloper/​xml/​internal/​commands/​associate/​AssociateGrammarDialog.java Adds Catalog mode, browsing, and selection validation.
org.eclipse.wildwebdeveloper.xml/​plugin.xml Registers the relocated command handler.

Review effort: Balanced

Comment on lines +105 to +107
entriesFuture.whenComplete((loadedEntries, ex) -> {
getShell().getDisplay().asyncExec(() -> handleCompletion(loadedEntries, ex));
});
@angelozerr
angelozerr force-pushed the associate_catalog_entry branch 2 times, most recently from 129b8c8 to 1c4dc68 Compare November 30, 2026 14:39
@merks
merks requested a balanced review from Copilot December 1, 2026 10:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

A direct argument cast can crash grammar-association commands, while unescaped URLs can make the generated XML catalog malformed and prevent unrelated mappings from loading.

4 open issues
1 resolved since last review

Review effort: Balanced

@akurtakov
akurtakov force-pushed the associate_catalog_entry branch from 1c4dc68 to d615386 Compare December 3, 2026 08:55

@akurtakov akurtakov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @angelozerr, Catalog mode is a nice addition, and loading the entries only when Browse is pressed keeps the dialog responsive. I rebased the PR on master; the only conflicts were from the switch to _ for unused lambda parameters, which I carried over into the moved files (together with the 2026 copyright year that change set).

Two things I'd like fixed before merging, since they affect the existing Local/Remote modes:

1. Command argument parsing. The handler now does (String) command.getArguments().get(0), while the previous handler used ArgumentsUtils.getArgAt(command, 0, String.class). LSP4J can deliver the argument as a JsonPrimitive, in which case the cast throws ClassCastException and no binding mode works. Please keep using ArgumentsUtils.

2. URI of local grammar files. saveInput() now uses grammarFile.getLocationURI().toString() instead of LSPEclipseUtils.toUri(grammarFile.getLocation()).toASCIIString(). That gives file:/home/... without escaping non-ASCII characters, while LSP4E sends document URIs as file:///home/..., ASCII-escaped. If LemMinX compares the two or makes the grammar path relative to the document, they may no longer match. Unless the change is intentional, could you restore the previous line?

Suggestions, fine as a follow-up:

3. Callbacks after the dialogs close. In CatalogEntrySelectionDialog.create(), the whenComplete callback calls getShell().getDisplay(). If the user cancels while the entries are still loading, getShell() is null, and the resulting NPE is swallowed by the future. Capturing the Display when the dialog is created avoids it. In AssociateGrammarDialog, the catalogEntriesFuture.thenAccept(...) after a selection isn't needed: the entries have already loaded by then, so the text can be set directly.

4. Retry after a failed load. If the first fetch fails, every later Browse click in the same dialog reuses the failed future and shows the error again. Resetting catalogEntriesFuture on failure would let the user retry.

5. Escaping in XMLCatalogs. webURL is inserted into the generated catalog without XML escaping, so a URL containing & makes the whole catalog invalid, including all other contributed entries. The existing publicId and uri attributes have the same issue; escaping all three would fix it.

6. Tests. The webURL → system entry generation is easy to unit-test. A test of xml.catalog.entries.bindable against LemMinX 0.40.0 would catch protocol changes.

Nits:

  • Messages.java and XMLPreferenceInitializer need the 2026 copyright year.
  • The new Messages fields are inserted between download_prompt_title and download_prompt_message.
  • There's a stray </p> in the CatalogEntrySelectionDialog javadoc.

Copilot's comment about LemMinX 0.40.0 not being in the target platform is outdated: #2308 updated it, and the manifest requires [0.40.0,1.0.0).

This review was prepared with Claude Code (Anthropic).

@angelozerr
angelozerr force-pushed the associate_catalog_entry branch 3 times, most recently from ffba09f to dcc86b1 Compare December 3, 2026 12:01
- Add CatalogEntrySelectionDialog: quick-open style dialog for selecting
bindable
  catalog entries, populated asynchronously via CompletableFuture
- Add CatalogEntryLabelProvider: styled display of entries with entry
type, identifier,
  and gray-colored catalog filename (disambiguated by path segments when
needed)
- Implement AssociateGrammarDialog with Catalog mode: radio button to
switch between
  Local/Remote and Catalog modes, Browse button that fetches entries
asynchronously
  with progress indicator
- Modify AssociateGrammarHandler: fetch catalog entries only when user
opens dialog,
  no blocking server calls in handler, fresh fetch each dialog open to
reflect
  catalog changes
- Add webURL support in XMLCatalogs: for WTP catalog contributions with
webURL
  attributes on public entries, generate additional system entries
pointing to web URLs

Signed-off-by: azerr <azerr@redhat.com>
@angelozerr
angelozerr force-pushed the associate_catalog_entry branch from dcc86b1 to bf00cd9 Compare December 3, 2026 12:07
@angelozerr

Copy link
Copy Markdown
Contributor Author

@akurtakov please review again.

@akurtakov

Copy link
Copy Markdown
Contributor

Please stop asking me to review, I do it whenever I find time and this is just a noise.

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.

5 participants