Changeset 5407


Ignore:
Timestamp:
06/20/09 05:25:46 (3 years ago)
Author:
azawawi
Message:

[Perl 6] Initial stub implementation of "Quick Fix" for "undeclared routine" using the Alt-/ right click menu

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Padre-Plugin-Perl6/lib/Padre/Plugin/Perl6/Perl6Document.pm

    r5401 r5407  
    192192sub event_on_right_down { 
    193193    my ($self, $editor, $menu, $event ) = @_; 
    194     #print "event_on_right_down @_\n"; 
    195     my $pos = $editor->GetCurrentPos; 
    196      
    197     return if not $self->{_parse_tree}; 
    198  
    199     my @things; 
    200     foreach my $e (@{ $self->{_parse_tree} }) { 
    201         last if $e->{start} > $pos; 
    202         next if $e->{start} + $e->{length} < $pos; 
    203         push @things, {type => $e->{type}, str => $e->{str}}; 
    204     } 
    205     return if not @things; 
    206      
     194 
     195    my $current_line_no = $editor->GetCurrentLine; 
    207196    my $main = $editor->main; 
    208197    $menu->AppendSeparator; 
    209      
    210 #   my $perl6 = $menu->Append( -1, Wx::gettext("Perl 6 $pos") ); 
    211 #   Wx::Event::EVT_MENU( 
    212 #           $main, $perl6, 
    213 #               sub { 
    214 #                   print "$_[0]\n"; 
    215 #               }, 
    216 #           ); 
    217     foreach my $thing (@things) { 
    218         $menu->Append( -1, sprintf( Wx::gettext("%s is Perl 6 %s "), $thing->{str}, $thing->{type} ) ); 
    219     } 
     198 
     199    foreach my $issue ( @{$self->{issues}} ) { 
     200        my $issue_line_no = $issue->{line} - 1; 
     201        if($issue_line_no == $current_line_no) { 
     202            if($issue->{msg} =~ /^Undeclared routine:\s+(.+?)\s+used/i) { 
     203                my $routine_name = $1; 
     204                Wx::Event::EVT_MENU( 
     205                    $main,  
     206                    $menu->Append( -1, sprintf( Wx::gettext("Insert sub '%s'\t"), $routine_name) ), 
     207                    sub {  
     208                        #XXX-implement insert routine 
     209                    }, 
     210                ); 
     211                Wx::Event::EVT_MENU( 
     212                    $main,  
     213                    $menu->Append( -1, Wx::gettext("Comment current error") ), 
     214                    sub { 
     215                        #XXX-implement comment current error 
     216                    }, 
     217                ); 
     218            } 
     219        } 
     220    } 
     221 
    220222    return; 
    221223} 
Note: See TracChangeset for help on using the changeset viewer.