Skip to content

feat(inspection): add early DTD validation for Struts config files#66

Merged
lukaszlenart merged 1 commit intomainfrom
feat/early-dtd-validation
Apr 5, 2026
Merged

feat(inspection): add early DTD validation for Struts config files#66
lukaszlenart merged 1 commit intomainfrom
feat/early-dtd-validation

Conversation

@lukaszlenart
Copy link
Copy Markdown
Member

Summary

  • Extracts StrutsDtdValidator as a shared helper that checks whether a struts.xml DOCTYPE SYSTEM URI is valid (recognized https://), uses http:// instead of https:// for newer DTDs (2.5+/6.0), or is completely unrecognized.
  • Calls the validator from Struts2ModelInspection.checkFileElement() to surface a file-level warning in the editor, so users see the issue while editing struts.xml — before opening the Diagram tab.
  • Adds StrutsDtdValidatorTest covering all edge cases (http/https for old and new DTDs, no doctype, unrecognized URI) and a highlighting regression test confirming correct https:// files produce no warning.

Motivation

Users who configure struts.xml with an http:// DOCTYPE URI for Struts 2.5+ or 6.0 DTDs encounter silent failures: the DOM model doesn't resolve packages, and the Diagram tab appears empty. Previously, this was only flagged via a runtime notification when opening the Diagram tab. This PR moves validation earlier into the standard inspection pipeline.

Test plan

  • StrutsDtdValidatorTest — 8 unit tests for the validation helper
  • StrutsHighlightingTest.testDtdHttpsNoWarning — no false positive on valid DTD
  • Full test suite passes (./gradlew test -x rat)

Made with Cursor

Surface invalid DOCTYPE SYSTEM URIs (http:// instead of https://, or
unrecognized URIs) as a file-level warning in Struts2ModelInspection,
so users discover the issue while editing struts.xml rather than only
when opening the Diagram tab.

- Extract StrutsDtdValidator as a shared helper for DTD URI checks
- Call the validator from Struts2ModelInspection.checkFileElement()
- Add message keys for both http-vs-https and unrecognized DTD warnings
- Add StrutsDtdValidatorTest (unit) and highlighting regression test

Made-with: Cursor
@lukaszlenart lukaszlenart marked this pull request as ready for review April 5, 2026 10:24
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 5, 2026

🔌 Plugin artifact ready for testing!

Download from Actions artifacts

Artifact: struts2-261.18970.1

@lukaszlenart lukaszlenart merged commit 53d382f into main Apr 5, 2026
5 checks passed
@lukaszlenart lukaszlenart deleted the feat/early-dtd-validation branch April 5, 2026 10:44
lukaszlenart added a commit that referenced this pull request Apr 5, 2026
Adds early feedback when a Struts-configured module has no WebFacet,
which prevents JSP result path resolution and Diagram navigation.

- WebFacetChecker: shared predicate reused by annotator and initializer
- StrutsWebFacetCheckingAnnotator: file-level warning on struts.xml with
  quick action to open module facet settings
- StrutsFrameworkInitializer: one-time notification per affected module
  on project open
- Struts2ProjectDescriptorBuilder.withoutWebFacet(): test support for
  omitting WebFacet in light tests

Follow-up to PR #66 (DTD validation).

Made-with: Cursor
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