Perl5-IDEA icon indicating copy to clipboard operation
Perl5-IDEA copied to clipboard

Parameters are not displayed in the structure view when I set a default assignment for a parameter

Open leobm opened this issue 3 years ago • 6 comments

Hi, when I read in the function parameters via shift and I set a default value via the || notation, the parameters are no longer displayed in the structure view. Is it possible to fix this?

sub exampleGetProductImageByID {

    my $param_sCompanyID = shift;
    my $param_sProductID = shift;
....

grafik

sub exampleGetProductImageByID {

    my $param_sCompanyID = shift || "oode";
    my $param_sProductID = shift || "335418GN";
....

grafik

regards,

Jan-Felix

leobm avatar Jul 08 '21 17:07 leobm

Yep, stumbled on this. Feels like not very easy, but yes, doable

hurricup avatar Jul 08 '21 17:07 hurricup

It happens also with the defined-or operator (‘//’)

Best regards, Emanuele

targzeta avatar Jul 08 '21 17:07 targzeta

yep

hurricup avatar Jul 08 '21 17:07 hurricup

defined-or operator

oh, I didn't know the operator at all. It is often more useful than the || operator.

leobm avatar Jul 13 '21 09:07 leobm

Hi,

I would have another idea. How about if there would be an annotation (maybe @parameter) with which I could define a variable as a parameter? because in practice it will probably be really difficult to cover all cases. See for example my example.

#@parameter
my $param_refHashOrArray = shift;

#@parameter
my $param_arefKeyPath = IsArray($_[0]) ? $_[0] : [ @_ ]; ## optional

Edit: it would be very cool if you could add an option to the annotation. e.g. #@parameter(optional=1) or so? Maybe there could also be more options (e.g. type=...)

leobm avatar Dec 15 '22 17:12 leobm

@leobm how do you see this case in a form of signature?

somemethod($param_refHashOrArray, ???);

hurricup avatar Dec 16 '22 03:12 hurricup