Opened 5 years ago

Closed 2 years ago

Last modified 2 years ago

#401 closed enhancement (fixed)

Output Panel should show moose (attributes, methods and method modifiers)

Reported by: jquelin Owned by:
Priority: major Milestone:
Component: Outline Version: 0.36
Keywords: outline Cc:

Description

moose becomes more and more proeminent those days, and thus padre should support it correctly.

so i propose that profile view detects the various sugar syntaxes added by moose. (should i create one ticket per proposal?)

among them:

  • attribute detection

add a new category 'attributes' in profile view, with a list of declared attributes. clicking on the attribute name focuses on it.

attributes are declared in moose with:

has attribute => ( ... );

beware that some people are using 'attribute' or "attribute" instead of using the fat comma stringification

  • also, parsing attributes to fetch if they're read-only or read-write (or nothing), to create the accessors in the profile view
    has attr1 => ( [...], is=>'ro', [...] );
    has attr2 => ( [...], is=>'rw', [...] );
    has attr3 => ( [... no 'is' param ...] );
    

the methods 'attr1' and 'attr2' should be created. (no 'attr3' method at all)

note however that if MooseX::FollowPBP is loaded, the methods will be 'get_attr1', 'set_attr1' and 'get_attr2'. and if MooseX::SemiAffordanceAccessor? is loaded, the methods will be 'attr1', 'set_attr1', 'attr2'.

  • also, MooseX::POE allows to create events easily with the following syntax:
    event my_event => sub { ... }
    

==> a new category Events in the outline view should be created for them

Attachments (4)

update_test_class_09-outline-t.patch (396 bytes) - added by buff3r 3 years ago.
patch to 09-outline.t test class for bareword attribute names
fix_moose_attr_eval_ppix_outline.patch (2.7 KB) - added by buff3r 3 years ago.
Patch to PPIx::EditorTools::Outline that eval()s Moose attribute declarations
update_test_09-outline-t.patch (2.8 KB) - added by buff3r 3 years ago.
patch to 09-outline.t to test for bareword attribute names
MooclassVanilla.pm (535 bytes) - added by buff3r 3 years ago.
class to test parse (sans MooseX::Declare)

Download all attachments as: .zip

Change History (26)

comment:1 Changed 5 years ago by jquelin

oh, one useful & popular module is MooseX::AttributeHelpers?

example - if we have the followin attributes declaration:

has _attribute => (
  metaclass => 'Collection::Array',

  provides => {
    push => 'add_stuff',
    elements => 'all_frobnizers',
   }
);

==> the methods add_stuff and all_frobnizers should be added to the outline view.

comment:2 Changed 5 years ago by jquelin

moose attribute detection added in r5577

comment:3 Changed 5 years ago by jquelin

moosex::poe events detection added in r5578

comment:4 Changed 5 years ago by rhebus

  • Type changed from defect to enhancement

comment:5 Changed 4 years ago by zenogantner

  • Component changed from editor to advanced perl tools

comment:6 Changed 4 years ago by zenogantner

  • Keywords outline added

comment:7 Changed 4 years ago by szabgab

  • Component changed from advanced perl tools to Outline

comment:8 Changed 3 years ago by buff3r

Hi,

I'm new to Padre and noticed when Padre tries to parse my Moose attributes with PPIx::EditorTools::Outline it fails to parse list attribute declarations correctly, such declarations as:

has [qw{ foo bar baz }] => ( is => 'rw', isa => 'Int' );

Ends up looking like:

qw{ foo bar baz }, as one attribute.

fix_moose_attr_eval_ppix_outline.patch parses the token with an eval() that interprets the list declaration and adds each attribute correctly.

Andrew


System Info:

Padre 0.94

Core...

osname linux

archname i686-linux-gnu-thread-multi-64int

Distribution Ubuntu 11.10

Kernel 3.0.0-17-generic

Perl 5.12.4

Threads 4

RAM 237.8MB

Wx...

Wx 0.9906

WxWidgets? 2.8.11

unicode 1

Alien::wxWidgets 0.51

Wx::Perl::ProcessStream? 0.29

Wx::Scintilla 0.3801

Other...

PPI 1.215

Debug::Client 0.20

Config /home/andrews/.local/share/.padre

comment:9 follow-up: Changed 3 years ago by bowtie

but what about the Single-Quoted String Literals

did you look at test files

t/outline/Moo*

output in Padre now has (with patch applied)

'attribute'
or
qw(attribute)

instead of just a nice clean

attribute

look forward to the next version

Changed 3 years ago by buff3r

patch to 09-outline.t test class for bareword attribute names

comment:10 in reply to: ↑ 9 Changed 3 years ago by buff3r

Hi there,

Single-quoted string literals, as well as single-element lists should both work now.

I also noticed bareword attribute names were not being covered in the tests, so I went ahead and added this test case. (see the patches I've included for the test 09-outline.t)

Replying to bowtie:

but what about the Single-Quoted String Literals

did you look at test files

t/outline/Moo*

output in Padre now has (with patch applied)

'attribute'
or
qw(attribute)

instead of just a nice clean

attribute

look forward to the next version

comment:11 Changed 3 years ago by bowtie

Looking good so far,

the following displays correctly under test with both ( Moose, MooseX)

has moo_att => ( is => 'rw', );
    
has 'attribute1' => (
    is  => 'rw',
    isa => 'Str',
);
    
has qw(account2) => ( is => 'rw', );
    
has [qw/ label progress butWarn butTime start_stop /] => ( isa => 'Ref', is => 'rw' );

has [qw{ foo bar baz }] => ( is => 'rw', isa => 'Int' );
    
has [qw# foo2 bar2 baz2 #] => ( is => 'rw', isa => 'Int' );

Also changes to tests ok

will push into trunk later

Version 0, edited 3 years ago by bowtie (next)

comment:12 follow-up: Changed 3 years ago by bowtie

But we still have an issue with method modifiers and Moose.

The following using Moose Fails to display at all :(

before 'foo' => sub {
    my $self = shift;
    return;
};
after 'bar' => sub {
    my $self = shift;
    return;
};
around 'baz' => sub {
    my $self = shift;
    return;
};
override 'moo' => sub {
    my $self = shift;
    return;
};
augment 'kuh' => sub {
    my $self = shift;
    return;
};

Where as the following using MooseX works :)

my ( $x, $y, $z );

before fooX( $x, $y, $z ) {...}

after barX( $x, $y, $z ) {...}

around bazX( $x, $y, $z ) {...}

override mooX( $x, $y, $z ) {...}

augment kuhX( $x, $y, $z ) {...}

So I thought buff3r that you might like to have a go at the 'method modifiers' using Moose as well.

have you seen http://padre.perlide.org/trac/wiki/PadrePluginMoose how dose it's output look in Padre?

comment:13 Changed 3 years ago by bowtie

  • Summary changed from profile view should take moose into account to Output Panel should show moose (attributes, methods and method modifiers)

Changed 3 years ago by buff3r

Patch to PPIx::EditorTools::Outline that eval()s Moose attribute declarations

Changed 3 years ago by buff3r

patch to 09-outline.t to test for bareword attribute names

Changed 3 years ago by buff3r

class to test parse (sans MooseX::Declare)

comment:14 in reply to: ↑ 12 ; follow-ups: Changed 3 years ago by buff3r

Ok, I was able to patch the Outline module to recognize plain Moose declarations, but I feel there's a conceptual error here: method modifiers in Moose are not class methods (see http://search.cpan.org/~doy/Moose-2.0403/lib/Moose/Manual/MethodModifiers.pod), but modify existing class methods.

We need to display method modifiers in the Outline differently.

Example:

package Moose::Declarations::MethodModifiers::Vanilla;

use Moose;

before 'mm_before' => sub {

return;

};

sub mm_before { };

'mm_before' now shows up twice in the Methods outline (with the latest patches).

I think it would make more sense visually to add these method modifiers as children to the existing attributes/methods they are modifying, otherwise it will confuse the user.

Replying to bowtie:

But we still have an issue with method modifiers and Moose.

The following using Moose Fails to display at all :(

before 'foo' => sub {
    my $self = shift;
    return;
};
after 'bar' => sub {
    my $self = shift;
    return;
};
around 'baz' => sub {
    my $self = shift;
    return;
};
override 'moo' => sub {
    my $self = shift;
    return;
};
augment 'kuh' => sub {
    my $self = shift;
    return;
};

Where as the following using MooseX works :)

my ( $x, $y, $z );

before fooX( $x, $y, $z ) {...}

after barX( $x, $y, $z ) {...}

around bazX( $x, $y, $z ) {...}

override mooX( $x, $y, $z ) {...}

augment kuhX( $x, $y, $z ) {...}

So I thought buff3r that you might like to have a go at the 'method modifiers' using Moose as well.

have you seen http://padre.perlide.org/trac/wiki/PadrePluginMoose how dose it's output look in Padre?

comment:15 in reply to: ↑ 14 Changed 3 years ago by bowtie

buff3r: that sounds like a good idea, we look forward to see a an implementation :)

will check new patches and tests, later

Replying to buff3r:

'mm_before' now shows up twice in the Methods outline (with the latest patches).

I think it would make more sense visually to add these method modifiers as children to the existing attributes/methods they are modifying, otherwise it will confuse the user.

comment:16 Changed 3 years ago by bowtie

Replying to buff3r:

both sets of patches applied to trunk

inc version to 0.15_02

this may be of help http://svn.perlide.org/padre/trunk/PPIx-EditorTools/

if you could make any new patches against the dev version 0.15_02

and I will apply to add to trunk and increment version, so we keep in sync, and others can play along to :)

I also noted that the sub is always fist in Outline regardless of location in pm compared to mm

comment:17 in reply to: ↑ 14 ; follow-up: Changed 3 years ago by bowtie

Replying to buff3r:

I have added an indicator in Help->About-Info in Padre trunk to enable identification of PPIx::EditorTools version :)

comment:18 in reply to: ↑ 17 ; follow-up: Changed 2 years ago by buff3r

Thanks for the help. Expect some major changes to the tests for this next fix.

Replying to bowtie:

Replying to buff3r:

I have added an indicator in Help->About-Info in Padre trunk to enable identification of PPIx::EditorTools version :)

comment:19 in reply to: ↑ 18 Changed 2 years ago by bowtie

Replying to buff3r:

info only,

Can you tidy files before patch using the current Padre-Plugin-PerlTidy against Padre trunk,
by running Padre

perl dev

or to run plug-ings from svn

perl dev -a

you will also need to have downloaded tools/perltidyrc

so that we all use the same perltidyrc

see #1239 for more info

As for Patching/Diff you should be able to use Patch feature Patch

comment:20 Changed 2 years ago by szabgab

The PPIx-EditorTools? module has been moved from SVN to Github. Please fork and commit your changes there: https://github.com/szabgab/PPIx-EditorTools

comment:21 Changed 2 years ago by bowtie

  • Resolution set to fixed
  • Status changed from new to closed

see #1435

this is now fixed

in trunk padre 0.97

with PPIx-EditorTools 0.15_04 2012.07.11

comment:22 Changed 2 years ago by bowtie

close as PPIx-EditorTools? 0.17 now released

see also #1435

Note: See TracTickets for help on using tickets.