Issue #18931: Add MatchXpath example for large array initialization#19196
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new MatchXpath documentation example demonstrating how to flag large array initializations (more than 10 elements), including an explicit id for the example configuration.
Changes:
- Added
Example6.javawith a MatchXpath query targeting largeARRAY_INITnodes and a custom message. - Added a corresponding example test to validate the reported violation location/message.
- Updated the MatchXpath xdoc template to include the new Example6 config and code snippet.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/coding/matchxpath/Example6.java | New example showing how to match array initializations with >10 elements and includes id=largeConstantCollection. |
| src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/MatchXpathCheckExamplesTest.java | Adds a test case validating the Example6 output (line/column + message). |
| src/site/xdoc/checks/coding/matchxpath.xml.template | Documents the new Example6 configuration and code in the MatchXpath check page. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| <param name="type" value="code"/> | ||
| </macro><hr class="example-separator"/> | ||
| <p id="Example6-config"> | ||
| To violate if array initialization has more than <b>10</b> elements |
There was a problem hiding this comment.
The sentence reads ungrammatically in the rendered docs. Consider rephrasing to something like: “Reports a violation if an array initialization has more than 10 elements.” (and add terminal punctuation) to match typical documentation style.
| To violate if array initialization has more than <b>10</b> elements | |
| Reports a violation if an array initialization has more than <b>10</b> elements. |
1fb1908 to
6e86e05
Compare
|
Please read and watch videos at Starting_Development. |
6e86e05 to
1e80ecc
Compare
1e80ecc to
715226c
Compare
Resolves #18931
I have made the changes as per your suggestion and added the id="largeConstantCollection" in the example. The documentation example, test, and example file have been updated accordingly and the build is passing locally.
Could you please review it and let me know if any further changes are needed? Thank you!