Repository navigation
[kotlin] Suppress empty-list attribute values in tree dump tests - #7165
Conversation
|
No relevant source code has been changed, pmdtester skipped. (comment created at 2026-10-27 10:46:36+00:00 for 6100f6c) |
adangel
left a comment
There was a problem hiding this comment.
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":
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.
The attributes still exist and are not removed.
|
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. |
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
@AnnotationFqNames) in tree dumps"