Perl6/Colorizer.pm untested

filter: Statementstmt 0.0% 0 / 35 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 57 CC 4 SCAR 23.0
CC
4
Cov
0%
colorize
20.0
BEGIN
2.0
BEGIN
2.0
CRAP 10.0
1 package Padre::Plugin::Perl6::Colorizer;
2 BEGIN {
3 $Padre::Plugin::Perl6::Colorizer::VERSION = '0.71';
4 }
5  
6 # ABSTRACT: Perl 6 Colorizer
7  
8 use 5.010;
9 use strict;
10 use warnings;
11  
12 use Padre::Wx ();
13  
14 # colorize timer to make sure that colorize tasks are scheduled properly...
15 my $COLORIZE_TIMER;
16 my $COLORIZE_TIMEOUT = 100; # wait n-millisecond before starting the Perl6 colorize task
17  
18  
19 our $colorizer;
20  
21 # colorizes a Perl 6 document in a timer
22 # one at a time;
23 # now the user can choose between PGE and STD colorizers
24 # via the preferences
25  
26 sub colorize {
27 my $self = shift;
28  
29 my $doc = Padre::Current->document;
30 my $config = Padre::Plugin::Perl6::plugin_config();
31 if ( $config->{p6_highlight} || $doc->{force_p6_highlight} ) {
32  
33 my $timer_id = Wx::NewId();
34 my $main = Padre->ide->wx->main;
35 $COLORIZE_TIMER = Wx::Timer->new( $main, $timer_id );
36 Wx::Event::EVT_TIMER(
37 $main,
38 $timer_id,
39 sub {
40 my $text = $doc->text_with_one_nl or return;
41  
42 # temporary overlay using the parse tree given by parrot
43 # Create a coloring task
44 my $module = $colorizer eq 'STD'
45 ? 'Padre::Plugin::Perl6::StdColorizerTask' # STD
46 : 'Padre::Plugin::Perl6::Perl6PgeColorizerTask'; # PGE
47 eval "use $module";
48 my $task = $module->new(
49 text => $text,
50 );
51  
52 # hand off to the task manager
53 $task->schedule();
54  
55 # and let us schedule that it is running properly or not
56 if ( $task->is_broken ) {
57  
58 # let us reschedule colorizing task to a later date..
59 $COLORIZE_TIMER->Stop;
60 $COLORIZE_TIMER->Start( $COLORIZE_TIMEOUT, Wx::wxTIMER_ONE_SHOT );
61 }
62 },
63 );
64  
65 # let us reschedule colorizing task to a later date..
66 $COLORIZE_TIMER->Stop;
67 $COLORIZE_TIMER->Start( $COLORIZE_TIMEOUT, Wx::wxTIMER_ONE_SHOT );
68 }
69 }
70  
71  
72 1;
73  
74 __END__