Description
Describe the Bug
Complex parameter default expressions (specifically those involving an AST branch node) are returned incorrectly.
For example:
class test($param = 1 + 1) { ... }
The default value for $param
is returned as +
.
Expected Behavior
The default value should be returned as 1 + 1
.
Additional Context
This seems to happen because ParameterizedStatement
parser uses a SourcePosAdapter
from Puppet to extract the text for the AST object. However, the extract_text
method it calls only extracts the text for the AST branch itself, not for the entire tree rooted in that branch. The SourcePosAdapter
calls @object.locator.extract_text
, but there is an extract_tree_text
method available on the locator which seems to do the right thing.
https://github.com/puppetlabs/puppet-strings/blob/main/lib/puppet-strings/yard/parsers/puppet/statement.rb#L89-L90
https://github.com/puppetlabs/puppet/blob/master/lib/puppet/pops/adapters.rb#L63
https://github.com/puppetlabs/puppet/blob/master/lib/puppet/pops/parser/locator.rb#L55
I would file a PR but I'm not deep enough into puppet-strings to understand its relationship to Puppet and the compatibility issues involved with the SourcePosAdapter
to know the appropriate place to make this change.