Skip to content

Conversation

mahfouz72
Copy link
Member

@mahfouz72 mahfouz72 commented Mar 3, 2025

closes #14446

We should support @snippet ofc but this PR introduces a workaround to fix the bug.

Diff Regression config: https://gist.githubusercontent.com/mohitsatr/f5a524a06294d907c84b9fc5b68661dc/raw/604872961df92db35e66c26218dc74c61bb10097/config.xml

Comment on lines +3 to +8
* {@snippet :
* import jakarta.persistence.Converter;
* @Converter
* public static class SomeSpecificClassConverter extends SomeBaseConverter {
* // Some stuff here
* }
Copy link
Member Author

Choose a reason for hiding this comment

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

The lexer incorrectly classifies @converter as a custom name Javadoc tag, while the parser expects to hit JAVADOC_INLINE_TAG_END first, causing a mismatch.

The additional condition insideJavadocInlineTag == 0 ensures that the lexer does not consider @something as a Javadoc tag when inside a Javadoc inline tag.

My workaround is to ensure annotations are not treated as Javadoc tags when inside a Javadoc inline tag.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any changes in performance?

Copy link
Member Author

Choose a reason for hiding this comment

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

No

@mahfouz72 mahfouz72 marked this pull request as draft March 3, 2025 19:22
@mahfouz72 mahfouz72 marked this pull request as ready for review March 3, 2025 20:43
@romani romani requested a review from nrmancuso March 4, 2025 05:55
@nrmancuso
Copy link
Contributor

I am good to close #14446 via the changes in this PR, but we should move some details from there to #11455

@romani
Copy link
Member

romani commented Mar 5, 2025

@nrmancuso , please move details that you need, I am not sure what are they

Copy link
Contributor

@nrmancuso nrmancuso left a comment

Choose a reason for hiding this comment

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

Nice hack 🎉

@nrmancuso nrmancuso requested a review from rnveach March 6, 2025 02:54
@nrmancuso nrmancuso assigned rnveach and unassigned nrmancuso Mar 6, 2025
@nrmancuso
Copy link
Contributor

@mahfouz72 please generate a regression report with all javadoc checks (preferably on OpenJDK21+)

@mahfouz72
Copy link
Member Author

Github, generate report

Copy link
Contributor

github-actions bot commented Mar 6, 2025

@mahfouz72
Copy link
Member Author

mahfouz72 commented Mar 6, 2025

All new violations are on javadoc that wasn't parsed before.

Annotaions inside @snippet or any other inline tag.

diff are on jdk21 only

@rnveach
Copy link
Contributor

rnveach commented Mar 7, 2025

All new violations are on javadoc that wasn't parsed before.

Removal of SuppressionXpathSingleFilter would prove your point.

@rnveach
Copy link
Contributor

rnveach commented Mar 7, 2025

I am waiting on a follow up to #16462 (comment) . I don't see anything else needed here.

@nrmancuso
Copy link
Contributor

I am waiting on a follow up to #16462 (comment) . I don't see anything else needed here.

Upon closer inspection, we have everything we need in #11455

@rnveach rnveach merged commit 6197259 into checkstyle:master Mar 7, 2025
102 checks passed

@Test
public void testAnnotationsInsideInlineTag() throws Exception {
verifyJavadocTree(getDocPath("expectedAnnotationsInsideInlineTagAst.txt"),
Copy link
Member

Choose a reason for hiding this comment

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

Issue was opened on AtclauseOrder to work.

I did not notice that it was proven to be working.

Copy link
Contributor

Choose a reason for hiding this comment

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

Issue was opened for four different checks in the configuration

Copy link
Member

Choose a reason for hiding this comment

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

At least we should share CLI on user config to see if output is reasonable

Copy link
Member Author

Choose a reason for hiding this comment

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

@mahfouz72 mahfouz72 deleted the fix-nested-tags branch May 9, 2025 09:38
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.

Parse error when Javadoc contains @snippet with code example that uses Java annotation
4 participants