Changeset 5420


Ignore:
Timestamp:
06/20/09 10:30:26 (3 years ago)
Author:
azawawi
Message:

[Perl 6] Implemented new Foo (C++) -> Foo.new (Perl 6) quick fix

File:
1 edited

Legend:

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

    r5419 r5420  
    310310                    $menu->Append( -1, Wx::gettext("Use Perl 6 constructor syntax") ), 
    311311                    sub {  
    312                         #replace first 'new Foo' with 'Foo.new' in the current line 
    313                          
     312                        #Replace first 'new Foo' with 'Foo.new' in the current line 
     313                        my $line_start = $editor->PositionFromLine( $current_line_no ); 
     314                        my $line_end   = $editor->GetLineEndPosition( $current_line_no ); 
     315                        my $line_text  = $editor->GetTextRange($line_start, $line_end); 
     316                        #new Point or 
     317                        #new Point::Bar or 
     318                        #new Point-In-Box 
     319                        $line_text =~ s/new\s+([\w\-\:\:]+)?/$1.new/; 
     320                        $editor->SetSelection( $line_start, $line_end ); 
     321                        $editor->ReplaceSelection( $line_text ); 
    314322                    }, 
    315323                ); 
Note: See TracChangeset for help on using the changeset viewer.