/usr/share/perl5/Padre/Plugin/Moose.pm is in libpadre-plugin-moose-perl 0.21-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | package Padre::Plugin::Moose;
use 5.008;
use strict;
use warnings;
use Padre::Plugin ();
our $VERSION = '0.21';
our @ISA = 'Padre::Plugin';
# Child modules we need to unload when disabled
use constant CHILDREN => qw{
Padre::Plugin::Moose
Padre::Plugin::Moose::Role::CanGenerateCode
Padre::Plugin::Moose::Role::CanHandleInspector
Padre::Plugin::Moose::Role::CanProvideHelp
Padre::Plugin::Moose::Role::HasClassMembers
Padre::Plugin::Moose::Role::NeedsPluginEvent
Padre::Plugin::Moose::Attribute
Padre::Plugin::Moose::Class
Padre::Plugin::Moose::ClassMember
Padre::Plugin::Moose::Constructor
Padre::Plugin::Moose::Destructor
Padre::Plugin::Moose::Method
Padre::Plugin::Moose::Program
Padre::Plugin::Moose::Role
Padre::Plugin::Moose::Subtype
Padre::Plugin::Moose::Util
Padre::Plugin::Moose::Assistant
Padre::Plugin::Moose::Preferences
Padre::Plugin::Moose::FBP::Assistant
Padre::Plugin::Moose::FBP::Preferences
};
# Called when Padre wants to check what package versions this
# plugin needs
sub padre_interfaces {
'Padre::Plugin' => 0.94,
'Padre::Document' => 0.94,
'Padre::Wx::Main' => 0.94,
'Padre::Wx::Theme' => 0.94,
'Padre::Wx::Editor' => 0.94,
'Padre::Wx::Role::Main' => 0.94,
'Padre::Wx::Role::Dialog' => 0.94,
;
}
# Called when Padre wants a name for the plugin
sub plugin_name {
Wx::gettext('Moose');
}
# Called when the plugin is enabled by Padre
sub plugin_enable {
my $self = shift;
# Read the plugin configuration, and
my $config = $self->config_read;
unless ( defined $config ) {
# No configuration, let us create it
$config = {};
}
# Make sure defaults are respected if they are undefined.
unless ( defined $config->{type} ) {
$config->{type} = 'Moose';
}
unless ( defined $config->{namespace_autoclean} ) {
$config->{namespace_autoclean} = 0;
}
unless ( defined $config->{comments} ) {
$config->{comments} = 1;
}
unless ( defined $config->{sample_code} ) {
$config->{sample_code} = 1;
}
# Write the plugin's configuration
$self->config_write($config);
# Update configuration attribute
$self->{config} = $config;
# Generate missing Padre's events
# TODO remove once Padre 0.96 is released
require Padre::Plugin::Moose::Role::NeedsPluginEvent;
Padre::Plugin::Moose::Role::NeedsPluginEvent->meta->apply( $self->main );
# Highlight the current editor. This is needed when a plugin is enabled
# for the first time
$self->editor_changed;
return 1;
}
# Called when the plugin is disabled by Padre
sub plugin_disable {
my $self = shift;
# Destroy resident dialog
if ( defined $self->{assistant} ) {
$self->{assistant}->Destroy;
$self->{assistant} = undef;
}
# TODO: Switch to Padre::Unload once Padre 0.96 is released
for my $package (CHILDREN) {
require Padre::Unload;
Padre::Unload->unload($package);
}
}
# Called when Padre wants to display plugin menu items
sub menu_plugins {
my $self = shift;
my $main = $self->main;
my $menu_item = Wx::MenuItem->new( undef, -1, Wx::gettext('Moose Assistant') . "...\tF8", );
Wx::Event::EVT_MENU(
$main,
$menu_item,
sub {
$self->show_assistant;
},
);
return $menu_item;
}
# Shows the Moose assistant dialog. Creates it only once if needed
sub show_assistant {
my $self = shift;
eval {
unless ( defined $self->{assistant} )
{
require Padre::Plugin::Moose::Assistant;
$self->{assistant} = Padre::Plugin::Moose::Assistant->new($self);
}
};
if ($@) {
$self->main->error( sprintf( Wx::gettext('Error: %s'), $@ ) );
} else {
$self->{assistant}->run;
}
return;
}
# Called when an editor is opened
sub editor_enable {
my $self = shift;
my $editor = shift;
my $document = shift;
# Only on Perl documents
return unless $document->isa('Padre::Document::Perl');
require Padre::Plugin::Moose::Util;
Padre::Plugin::Moose::Util::add_moose_keywords_highlighting( $self->{config}->{type}, $document, $editor );
}
# Called when an editor is changed
sub editor_changed {
my $self = shift;
my $current = $self->current or return;
my $document = $current->document or return;
my $editor = $current->editor or return;
# Only on Perl documents
return unless $document->isa('Padre::Document::Perl');
require Padre::Plugin::Moose::Util;
Padre::Plugin::Moose::Util::add_moose_keywords_highlighting( $self->{config}->{type}, $document, $editor );
}
1;
__END__
=pod
=head1 NAME
Padre::Plugin::Moose - Moose, Mouse and MooseX::Declare support for Padre
=head1 SYNOPSIS
cpan Padre::Plugin::Moose
Then use it via L<Padre>, The Perl IDE. Press F8.
=head1 DESCRIPTION
Once you enable this Plugin under Padre, you'll get a brand new menu with the
following options:
=head2 Moose Assistant
Opens up a user-friendly dialog where you can add classes, roles and their
members. The dialog contains a tree view of created class and role elements and
a preview of the generated Perl code. It also contains links to Moose online
references.
=head2 Moose Preferences
Provides the ability to change the operation type (Moose, Mouse or
MooseX::Declare) and toggle the usage of namespace::clean, comments and sample
usage code generation.
=head2 Keyword Syntax Highlighting
Moose/Mouse and MooseX::Declare keywords are highlighted automatically in any
Perl document. The operation type determines what to highlight.
=head1 BUGS
Please report any bugs or feature requests to C<bug-padre-plugin-moose at rt.cpan.org>, or through
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Padre-Plugin-Moose>. I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.
=head1 SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Padre::Plugin::Moose
You can also look for information at:
=over 4
=item * RT: CPAN's request tracker
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Padre-Plugin-Moose>
=item * AnnoCPAN: Annotated CPAN documentation
L<http://annocpan.org/dist/Padre-Plugin-Moose>
=item * CPAN Ratings
L<http://cpanratings.perl.org/d/Padre-Plugin-Moose>
=item * Search CPAN
L<http://search.cpan.org/dist/Padre-Plugin-Moose/>
=back
=head1 SEE ALSO
L<Moose>, L<Padre>
=head1 AUTHORS
Ahmad M. Zawawi <ahmad.zawawi@gmail.com>
=head1 CONTRIBUTORS
Adam Kennedy <adamk@cpan.org>
Kevin Dawson E<lt>bowtie@cpan.orgE<gt>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Ahmad M. Zawawi
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
|