line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Goo::Thing::pm::MethodMatcher; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
############################################################################### |
4
|
|
|
|
|
|
|
# Nigel Hamilton |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Copyright Nigel Hamilton 2005 |
7
|
|
|
|
|
|
|
# All Rights Reserved |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# Author: Nigel Hamilton |
10
|
|
|
|
|
|
|
# Filename: Goo::Thing::pm::MethodMatcher.pm |
11
|
|
|
|
|
|
|
# Description: Match a method in a string |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
# Date Change |
14
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
15
|
|
|
|
|
|
|
# 17/08/2005 Auto generated file |
16
|
|
|
|
|
|
|
# 17/08/2005 Started to do this in multiple places |
17
|
|
|
|
|
|
|
# 26/10/2005 Added method: getScope |
18
|
|
|
|
|
|
|
# |
19
|
|
|
|
|
|
|
############################################################################### |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
1
|
|
6
|
use Goo::TextUtilities; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
246
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# return the method position plus 5 |
26
|
|
|
|
|
|
|
# sp we target the middle of the method |
27
|
|
|
|
|
|
|
my $offset = 5; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
############################################################################### |
31
|
|
|
|
|
|
|
# |
32
|
|
|
|
|
|
|
# get_line_number - return the line of the file that matches the method |
33
|
|
|
|
|
|
|
# |
34
|
|
|
|
|
|
|
############################################################################### |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub get_line_number { |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
0
|
1
|
|
my ($method_name, $string) = @_; |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
my $pattern; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# need to jump to the method of this Thing |
43
|
0
|
0
|
|
|
|
|
if ($method_name eq "main") { |
44
|
0
|
|
|
|
|
|
$pattern = qr/^use\s+strict/; |
45
|
|
|
|
|
|
|
} else { |
46
|
0
|
|
|
|
|
|
$pattern = qr/^sub\s+$method_name/; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# textutilities - to match the pattern, then find the line, then jump |
50
|
0
|
|
|
|
|
|
my $matching_line_number = Goo::TextUtilities::get_matching_line_number($pattern, $string); |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
return $matching_line_number + $offset; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__END__ |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 NAME |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Goo::Thing::pm::MethodMatcher - Match a method in a string |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 SYNOPSIS |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
use Goo::Thing::pm::MethodMatcher; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 DESCRIPTION |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 METHODS |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=over |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=item get_line_number |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
return the line of the file that matches the method |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=back |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 AUTHOR |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Nigel Hamilton <nigel@trexy.com> |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 SEE ALSO |
89
|
|
|
|
|
|
|
|