| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Reply::Plugin::Autocomplete::ExportedSymbols; |
|
2
|
2
|
|
|
2
|
|
16641
|
use strict; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
52
|
|
|
3
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
59
|
|
|
4
|
2
|
|
|
2
|
|
723
|
use parent qw/Reply::Plugin/; |
|
|
2
|
|
|
|
|
455
|
|
|
|
2
|
|
|
|
|
68
|
|
|
5
|
2
|
|
|
2
|
|
19031
|
use List::MoreUtils; |
|
|
2
|
|
|
|
|
12787
|
|
|
|
2
|
|
|
|
|
24
|
|
|
6
|
2
|
|
|
2
|
|
1196
|
use Module::Runtime qw/$module_name_rx/; |
|
|
2
|
|
|
|
|
8
|
|
|
|
2
|
|
|
|
|
16
|
|
|
7
|
2
|
|
|
2
|
|
104
|
use Package::Stash; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
743
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
12
|
use Reply::Util qw/$ident_rx/; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
685
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $sigil_rx = $Reply::Util::sigil_rx; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = "0.01"; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub tab_handler { |
|
16
|
4
|
|
|
4
|
1
|
1137
|
my $self = shift; |
|
17
|
4
|
|
|
|
|
13
|
my ($line) = @_; |
|
18
|
|
|
|
|
|
|
|
|
19
|
4
|
50
|
|
|
|
64
|
my ($before, $module_name, $fragment) = $line =~ /(.*?)use\s+(${module_name_rx})(.*)$/ or return; |
|
20
|
4
|
50
|
|
|
|
15
|
return if $before =~ /^#/; # commands |
|
21
|
|
|
|
|
|
|
|
|
22
|
4
|
|
|
|
|
12
|
my @symbols = _export_symbols($module_name); |
|
23
|
4
|
100
|
|
|
|
426
|
if (my ($ident) = $fragment =~ /(:$ident_rx?|$ident_rx)$/) { |
|
24
|
2
|
|
|
|
|
6
|
return grep { /^\Q$ident\E/ } @symbols; |
|
|
10
|
|
|
|
|
56
|
|
|
25
|
|
|
|
|
|
|
} |
|
26
|
2
|
|
|
|
|
16
|
return @symbols; |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub _export_symbols { |
|
30
|
5
|
|
|
5
|
|
16
|
my $module_name = shift; |
|
31
|
|
|
|
|
|
|
|
|
32
|
5
|
100
|
|
|
|
12
|
eval { Module::Runtime::require_module($module_name) } or return; |
|
|
5
|
|
|
|
|
19
|
|
|
33
|
|
|
|
|
|
|
|
|
34
|
4
|
|
|
|
|
672
|
my $stash = Package::Stash->new($module_name); |
|
35
|
4
|
|
|
|
|
15
|
my $stash_name = $stash->name; |
|
36
|
4
|
|
|
|
|
24
|
my $namespace = $stash->namespace; |
|
37
|
|
|
|
|
|
|
|
|
38
|
4
|
|
|
|
|
10
|
my @symbols; |
|
39
|
4
|
50
|
|
|
|
29
|
push @symbols, @{$namespace->{EXPORT}} if $stash->has_symbol('@EXPORT'); |
|
|
4
|
|
|
|
|
13
|
|
|
40
|
4
|
50
|
|
|
|
46
|
push @symbols, @{$namespace->{EXPORT_OK}} if $stash->has_symbol('@EXPORT_OK'); |
|
|
4
|
|
|
|
|
15
|
|
|
41
|
4
|
50
|
|
|
|
21
|
push @symbols, map { ":$_" } keys %{$namespace->{EXPORT_TAGS}} if $stash->has_symbol('%EXPORT_TAGS'); |
|
|
4
|
|
|
|
|
15
|
|
|
|
4
|
|
|
|
|
14
|
|
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# Exclude variables. Function names and variable names starting with sigil can not be mixed in completion |
|
44
|
4
|
|
|
|
|
11
|
@symbols = grep { !/^$sigil_rx/ } @symbols; |
|
|
36
|
|
|
|
|
127
|
|
|
45
|
|
|
|
|
|
|
|
|
46
|
4
|
|
|
|
|
18
|
return sort +List::MoreUtils::uniq(@symbols); |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
|
50
|
|
|
|
|
|
|
__END__ |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=encoding utf-8 |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 NAME |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Reply::Plugin::Autocomplete::ExportedSymbols - Tab completion for exported symbol names |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
In your .replyrc |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
[Autocomplete::ExportedSymbols] |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
And use reply! |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
% reply |
|
67
|
|
|
|
|
|
|
0> use List::Util qw/ <TAB> |
|
68
|
|
|
|
|
|
|
all max minstr pairfirst pairmap product sum uniqnum |
|
69
|
|
|
|
|
|
|
any maxstr none pairgrep pairs reduce sum0 uniqstr |
|
70
|
|
|
|
|
|
|
first min notall pairkeys pairvalues shuffle uniq unpairs |
|
71
|
|
|
|
|
|
|
0> use List::Util qw/ pair<TAB> |
|
72
|
|
|
|
|
|
|
pairfirst pairgrep pairkeys pairmap pairs pairvalues |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Reply::Plugin::Autocomplete::ExportedSymbols is a plugin for L<Reply>. |
|
77
|
|
|
|
|
|
|
It provides a tab completion for exported symbols names from L<Exporter>'s C<@EXPORT>, C<@EXPORT_OK> and C<%EXPORT_TAGS>. |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Note that exported variables are not included in completion. |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
L<Reply> |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
L<Exporter> |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 LICENSE |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Copyright (C) Takumi Akiyama. |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
92
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 AUTHOR |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Takumi Akiyama E<lt>t.akiym@gmail.comE<gt> |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |