Skip to content

Support for "has" attributes #139

@mbuc82

Description

@mbuc82

Hello,

it would be great, if PLS would support the "has" attribute definitions from the Moose/Moo/Mo implementations of Perl, to be usable in the outline part of VSCode.

Moose

has 'node' => (is => 'rw', isa => 'Any');
 
has 'children' => (
    is      => 'ro',
    isa     => 'ArrayRef',
    default => sub { [] }
);
 
has 'parent' => (
    is          => 'rw',
    isa         => 'Tree',
    weak_ref    => 1,
    handles     => {
        parent_node => 'node',
        siblings    => 'children',
    }
);

Moo

has taste => (
  is => 'ro',
);
 
has brand => (
  is  => 'ro',
  isa => sub {
    die "Only SWEET-TREATZ supported!" unless $_[0] eq 'SWEET-TREATZ'
  },
);
 
has pounds => (
  is  => 'rw',
  isa => sub { die "$_[0] is too much cat food!" unless $_[0] < 15 },
);

Mo

has name1 => ( default => sub { 'Joe' } );
has name2 => ( builder => 'name_builder' );
has name3 => ( coerce => sub {$_[0]} );
has name4 => ( is => 'ro' );
has name4 => ( required => 1 );

Apart from that, the step to Perl's Cor implementation would also be a bit smaller.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions