Repository navigation
Add xml.colors and xml.references preference pages with shared DocumentMatcherWidget - #2316
angelozerr wants to merge 1 commit into
Conversation
| returns strings. AFAICS Lemmix expects array of strings. Can be be aligned? |
|
AFAICS we target Java 21 here, so the warnings for editButton.addSelectionListener(widgetSelectedAdapter(e -> editExpression())); should not be issued / cannot be fixed here. |
@angelozerr WDYT? |
|
@vogella I wonder if we should add as default this Android sample for color. For Android user, It will work out of the box without configuring it. Wat do you think about that? |
I don't understand. Which Android users? Android development tools are AFAIK dead. |
|
I mean if user open a colors.xml file it will see color (like my demo) without some configuration. |
That would be IMHO great, if it needs to be activated almost nobody will think of that. |
There was a problem hiding this comment.
🟡 Changes recommended
Non-pattern matcher criteria are serialized as strings and discarded by the server, potentially matching unrelated documents, while both entry dialogs reject valid matchers without a file pattern.
2 open issues
What changed in this PR
Adds Eclipse preference pages for configuring LemMinX color detection and XPath-based references within Wild Web Developer’s XML support.
Changes:
- Adds Colors and References pages with dialogs for managing XPath rules.
- Introduces a shared widget for document-matching criteria.
- Stores settings as JSON and connects them to the existing LemMinX initialization options.
| File | Description |
|---|---|
org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/ui/preferences/XMLReferencesPreferencePage.java |
Manages and persists reference entries. |
org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/ui/preferences/XMLReferencesEntryDialog.java |
Edits reference matchers and expression lists. |
org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/ui/preferences/XMLReferenceExpressionDialog.java |
Edits from/to XPath pairs, prefixes, and multiple-value settings. |
org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/ui/preferences/XMLPreferenceServerConstants.java |
Registers both settings and converts JSON for initialization options. |
org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/ui/preferences/XMLPreferenceInitializer.java |
Defines empty-array defaults for both settings. |
org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/ui/preferences/XMLColorsPreferencePage.java |
Manages and persists color entries. |
org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/ui/preferences/XMLColorsEntryDialog.java |
Edits color matchers and XPath expressions. |
org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/ui/preferences/DocumentMatcherWidget.java |
Provides shared matcher fields and JSON conversion. |
org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/ui/messages.properties |
Adds UI labels, descriptions, and validation messages. |
org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/ui/Messages.java |
Exposes the new localized message fields. |
org.eclipse.wildwebdeveloper.xml/plugin.xml |
Registers both preference pages and search keywords. |
org.eclipse.wildwebdeveloper.xml/plugin.properties |
Supplies page names and keyword text. |
Review effort: Balanced
| putIfNotEmpty(obj, "namespaceURI", getNamespaceURI()); | ||
| putIfNotEmpty(obj, "rootElement", getRootElement()); | ||
| putIfNotEmpty(obj, "publicId", getPublicId()); | ||
| putIfNotEmpty(obj, "systemId", getSystemId()); | ||
| putIfNotEmpty(obj, "grammarURI", getGrammarURI()); |
| if (matcherWidget != null && matcherWidget.getPattern().isEmpty()) { | ||
| error = Messages.XMLColorsEntryDialog_error_pattern_required; |
|
I don't understand the use case for this quite big PR. Just so colors will be rendered in the editor or one can manually define their own references? If one wants to have good docbook experience , a lemminx extension like lemminx-maven will be needed, no? |
|
Such amount of code for rarely used (according to me) features is definetely what I look to support. |
@akurtakov this PR provides
It is 2 different features. XML references features support provide the capability to manage your own references with declarative mean without developping a LemMinx extension. But if you want I can remove this support and provides only xml.colors? |
I had also this idea, but I think this feature should be managed by LSP4E to have the same UI settings than code. Having this kind of generic UI settings could allow to share the same settings between Eclipse IDE and vscode but it will not use the Eclipse preferences mechanism. |
d4965c1 to
49d10b0
Compare
49d10b0 to
c9611d3
Compare
c9611d3 to
24e3b97
Compare
done |
fa9c827 to
4efe426
Compare
|
@vogella please review again, it should be cleaner. |
|
@angelozerr can you check and resolve the Copilot review feedback? On of it is also what I have commented on. |
There was a problem hiding this comment.
🟡 Changes recommended
The matcher model incorrectly represents array-valued criteria as strings, causing valid entries to be lost on save, while the dialogs also discard non-pattern criteria.
7 open issues
Matcher criteria must support string arrays · New Allow valid matchers without a file pattern · New Matcher criteria are not loaded or saved · New Edit and remove entries by selected row · New Restore Defaults should reload default entries · New Allow matchers without a file pattern when other criteria are set Serialize matcher criteria as arrays to preserve document scoping
Review effort: Balanced
Yes sure! I am working on that. |
49fdc79 to
b5254fa
Compare
| Button addButton = new Button(btnComposite, SWT.PUSH); | ||
| addButton.setText(Messages.Add_button); | ||
| addButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); | ||
| addButton.addSelectionListener(widgetSelectedAdapter(e -> addExpression())); |
| editButton.setText(Messages.XMLColorsEntryDialog_edit_button); | ||
| editButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); | ||
| editButton.setEnabled(false); | ||
| editButton.addSelectionListener(widgetSelectedAdapter(e -> editExpression())); |
| removeButton.setText(Messages.Remove_button); | ||
| removeButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); | ||
| removeButton.setEnabled(false); | ||
| removeButton.addSelectionListener(widgetSelectedAdapter(e -> removeExpression())); |
| Button addButton = new Button(btnComposite, SWT.PUSH); | ||
| addButton.setText(Messages.Add_button); | ||
| addButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); | ||
| addButton.addSelectionListener(widgetSelectedAdapter(e -> addEntry())); |
| editButton.setText(Messages.XMLColorsEntryDialog_edit_button); | ||
| editButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); | ||
| editButton.setEnabled(false); | ||
| editButton.addSelectionListener(widgetSelectedAdapter(e -> editEntry())); |
| removeButton.setText(Messages.Remove_button); | ||
| removeButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); | ||
| removeButton.setEnabled(false); | ||
| removeButton.addSelectionListener(widgetSelectedAdapter(e -> removeEntry())); |
| Button addButton = new Button(buttonComposite, SWT.PUSH); | ||
| addButton.setText(Messages.Add_button); | ||
| addButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); | ||
| addButton.addSelectionListener(widgetSelectedAdapter(e -> addMatcher())); |
| removeButton.setText(Messages.Remove_button); | ||
| removeButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); | ||
| removeButton.setEnabled(false); | ||
| removeButton.addSelectionListener(widgetSelectedAdapter(e -> removeMatcher())); |
| Link colorsLink = new Link(composite, SWT.NONE); | ||
| colorsLink.setText("• <a>Colors</a> - Extract color values from XML files for color picker support"); | ||
| colorsLink.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); | ||
| colorsLink.addSelectionListener(org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter(e -> { |
| Link referencesLink = new Link(composite, SWT.NONE); | ||
| referencesLink.setText("• <a>References</a> - Define reference relationships for navigation and rename refactoring"); | ||
| referencesLink.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); | ||
| referencesLink.addSelectionListener(org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter(e -> { |
b5254fa to
c6d9c31
Compare
|
The unused parameter warnings are kind of annoying. There's not much choice unless we bump to Java 25. |
c6d9c31 to
4c278cd
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved defects can edit or remove the wrong rule, reject valid matcher-only configurations, and prevent bundled servlet and DocBook reference mappings from working.
9 open issues
Matcher criteria must support string arrays Fix the DocBook 5 namespace and ID target XPath · New Servlet and filter mappings use element paths instead of text nodes · New Matcher equality causes row edits and removals to target the wrong entry · New Restore Defaults should reload default entries Edit and remove entries by selected row Allow valid matchers without a file pattern Allow matchers without a file pattern when other criteria are set Serialize matcher criteria as arrays to preserve document scoping
1 resolved since last review
Review effort: Balanced
9c86737 to
e9d58ae
Compare
|
@vogella @merks all issues from Copilot should be fixed and I have improved UI. First I set olor and references in the File Rules page:
I will add in this File Rules (once this PR will be merged) the https://github.com/redhat-developer/vscode-xml/blob/main/docs/Features/XMLFilePathSupport.md support Here the UI for Colors:
Here the UI for References
If you need to have several namespace uri you can add it in the table:
There is defaut references like explained https://github.com/redhat-developer/vscode-xml/blob/main/docs/Features/XMLReferencesFeatures.md (for docbook, tei and web.xml) |
DocumentMatcherWidget Introduces UI for configuring LemMinX's xml.colors and xml.references settings in Eclipse preferences (XML > Colors, XML > References). Both features share a reusable DocumentMatcherWidget that captures the file/document matcher criteria (pattern, namespaceURI, rootElement, publicId, systemId, grammarURI). Colors entries define XPath expressions pointing to color-valued nodes; references entries define from/to XPath pairs enabling cross-element navigation and rename. Settings are stored as JSON in the Eclipse preference store and sent to LemMinX via the existing initialization options mechanism. Signed-off-by: azerr <azerr@redhat.com>
e9d58ae to
e98e354
Compare







Add xml.colors and xml.references preference pages with shared DocumentMatcherWidget
Introduces UI for configuring LemMinX's xml.colors and xml.references settings
in Eclipse preferences (XML > Colors, XML > References). Both features share a
reusable DocumentMatcherWidget that captures the file/document matcher criteria
(pattern, namespaceURI, rootElement, publicId, systemId, grammarURI). Colors
entries define XPath expressions pointing to color-valued nodes; references
entries define from/to XPath pairs enabling cross-element navigation and rename.
Settings are stored as JSON in the Eclipse preference store and sent to LemMinX
via the existing initialization options mechanism.
xml.colors
Given this XML android
colors.xmlfile:With LemMinx you can configure where LSP color is defined by using XPath (see vscode-xml doc at https://github.com/redhat-developer/vscode-xml/blob/main/docs/Features/XMLColorsFeatures.md)
After defining this XPath expression for a given file:
You should benefit with colors:
xml.references
Same thing for references, see doc at https://github.com/redhat-developer/vscode-xml/blob/main/docs/Features/XMLReferencesFeatures.md