Changeset 9649


Ignore:
Timestamp:
12/13/09 00:36:26 (2 years ago)
Author:
szabgab
Message:

move the open selector to the document class

Location:
trunk/Padre/lib/Padre
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Padre/lib/Padre/Document.pm

    r9563 r9649  
    13841384} 
    13851385 
     1386# Individual document classes should override this method 
     1387# It gets a string (the current selection) and it should 
     1388# return a list of files that are possible matches to that file. 
     1389# In Perl for example A::B  would be mapped to A/B.pm in various places on 
     1390# the filesystem. 
     1391sub guess_filename_to_open { 
     1392    return; 
     1393} 
     1394 
    138613951; 
    13871396 
  • trunk/Padre/lib/Padre/Document/Perl.pm

    r9640 r9649  
    17281728 
    17291729 
     1730sub guess_filename_to_open { 
     1731    my ($self, $text) =  @_; 
     1732 
     1733    my $module = $text; 
     1734    $module =~ s{::}{/}g; 
     1735    $module .= ".pm"; 
     1736    my @files; 
     1737    my $filename = File::Spec->catfile( Padre->ide->{original_cwd}, $module, ); 
     1738    if ( -e $filename ) { 
     1739        push @files, $filename; 
     1740    } else { 
     1741 
     1742        # relative to the project lib dir 
     1743        my $filename = File::Spec->catfile( 
     1744            $self->project_dir, 
     1745            'lib', $module, 
     1746        ); 
     1747        if ( -e $filename ) { 
     1748            push @files, $filename; 
     1749        } 
     1750 
     1751        # relative to the project dir 
     1752        my $filename2 = File::Spec->catfile( 
     1753            $self->project_dir, 
     1754            $module, 
     1755        ); 
     1756        if ( -e $filename2 ) { 
     1757            push @files, $filename2; 
     1758        } 
     1759 
     1760        # TO DO: it should not be our @INC but the @INC of the perl used for 
     1761        # script execution 
     1762        foreach my $path (@INC) { 
     1763            my $filename = File::Spec->catfile( $path, $module ); 
     1764            if ( -e $filename ) { 
     1765                push @files, $filename; 
     1766 
     1767                #last; 
     1768            } 
     1769        } 
     1770    } 
     1771     
     1772    return @files; 
     1773} 
     1774 
     1775 
    173017761; 
    17311777 
  • trunk/Padre/lib/Padre/Wx/Main.pm

    r9645 r9649  
    29302930        } 
    29312931    } 
    2932     unless (@files) { # TO DO: and if we are in a Perl environment 
    2933         my $module = $text; 
    2934         $module =~ s{::}{/}g; 
    2935         $module .= ".pm"; 
    2936         my $filename = File::Spec->catfile( $self->ide->{original_cwd}, $module, ); 
    2937         if ( -e $filename ) { 
    2938             push @files, $filename; 
    2939         } else { 
    2940  
    2941             # relative to the project lib dir 
    2942             my $filename = File::Spec->catfile( 
    2943                 $self->current->document->project_dir, 
    2944                 'lib', $module, 
    2945             ); 
    2946             if ( -e $filename ) { 
    2947                 push @files, $filename; 
    2948             } 
    2949  
    2950             # relative to the project dir 
    2951             my $filename2 = File::Spec->catfile( 
    2952                 $self->current->document->project_dir, 
    2953                 $module, 
    2954             ); 
    2955             if ( -e $filename2 ) { 
    2956                 push @files, $filename2; 
    2957             } 
    2958  
    2959             # TO DO: it should not be our @INC but the @INC of the perl used for 
    2960             # script execution 
    2961             foreach my $path (@INC) { 
    2962                 my $filename = File::Spec->catfile( $path, $module ); 
    2963                 if ( -e $filename ) { 
    2964                     push @files, $filename; 
    2965  
    2966                     #last; 
    2967                 } 
    2968             } 
    2969         } 
     2932    unless (@files) { 
     2933        my $doc = $self->current->document; 
     2934        push @files, $doc->guess_filename_to_open($text); 
    29702935    } 
    29712936 
Note: See TracChangeset for help on using the changeset viewer.