Skip to content

[kotlin] Suppress empty-list attribute values in tree dump tests - #7165

Merged
adangel merged 3 commits into
pmd:mainfrom
stokpop:kotlin/suppress-empty-list-attrs
Oct 27, 2026
Merged

adangel merged 3 commits into
pmd:mainfrom
stokpop:kotlin/suppress-empty-list-attrs

Conversation

@stokpop

@stokpop stokpop commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Fixes one item from #7091 (follow-up tracking issue for #6893).

This just skips the empty collections in a kotlin-specific attribute printer for the tree dump tests.

Updated the 8 affected tree-dump golden fixtures (only @AnnotationFqNames = () removed, nothing else changed) and one unit test that explicitly asserted the old (noisy) behavior, inverting it to assert the attribute is now absent.

Related

@pmd-actions-helper

pmd-actions-helper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Documentation Preview

No relevant source code has been changed, pmdtester skipped.

(comment created at 2026-10-27 10:46:36+00:00 for 6100f6c)

@stokpop stokpop changed the title [kotlin] Suppress empty-list attribute values in tree dumps [kotlin] Suppress empty-list attribute values in tree dumps/designer Oct 9, 2026
@stokpop
stokpop marked this pull request as ready for review October 9, 2026 05:13

@adangel adangel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the PR!

Actually, I wouldn't remove these attributes, if they are empty. The fact, that these attributes exist, but have no value, is still important. The initial reason, why this PR was created, was: clutter in tree dump. And this can be solved, by just not outputting these attributes in tree dumps. I still find it valueable, if all possible attributes are listed in the designer - this helps to explore and understand the AST. If the AST has already too many attributes that it is overwhelming, then we can enhance the designer: It already has a button to "Hide common attributes":

Image

We could add a second button to "Hide empty attributes" - but only, if empty attributes are really a problem.

I'll update the PR to just change the tree dump behavior in Kotlin and leave the attributes as is. Then we also don't need to reason about compatibility with existing XPath rules.

Note: That we skip null-valued attributes, is maybe something we should rethink: Ideally, we would only skip attributes, that we defined explicitly to be optional and not every attribute whose value happen to be null.

Skipping attributes also might result in bad design: If you know, that empty attributes will be skipped, then you could add the attribute to every node by default - since it will only show up, if it has a value. I'd rather be explicit which node supports which attributes.

@adangel adangel added the in:pmd-internals Affects PMD's internals label Oct 27, 2026
The attributes still exist and are not removed.
@adangel adangel changed the title [kotlin] Suppress empty-list attribute values in tree dumps/designer [kotlin] Suppress empty-list attribute values in tree dumps Oct 27, 2026
@adangel adangel changed the title [kotlin] Suppress empty-list attribute values in tree dumps [kotlin] Suppress empty-list attribute values in tree dump tests Oct 27, 2026
@adangel adangel added this to the 7.29.0 milestone Oct 27, 2026
@adangel
adangel merged commit 979f40d into pmd:main Oct 27, 2026
12 checks passed
@stokpop

stokpop commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for merging @adangel . I agree that it is better to have all attributes visible in the designer so you know what is available on what nodes/levels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in:pmd-internals Affects PMD's internals

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants