lib/PMLTQ/Suggest/Utils.pm

filter: Statementstmt 18.3% 33 / 180 Branchbran 0.0% 0 / 88 Conditioncond 0.0% 0 / 36 MC/DCmcdc 0.0% 0 / 23 Subroutinesub 47.6% 10 / 21 Podpod 0.0% 0 / 8 totaltotal 12.0% 43 / 356 CC 65 SCAR 58.4
CC
65
Cov
11%
apply_file_suffix
870.0
_find_tree_no
210.0
parse_file_suffix
56.0
CRAP 343.4
« lib/PMLTQ/Suggest.pm ↑ Summary blib/lib/PMLTQ/Suggest.pm »
1 package PMLTQ::Suggest::Utils;
2 4 our $AUTHORITY = 'cpan:MATY';
3 4 $PMLTQ::Suggest::Utils::VERSION = '0.0.3';
4 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 4 ▶use Treex::PML::Document;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use List::MoreUtils 'uniq';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use File::Basename 'basename';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use UNIVERSAL::DOES;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 4 ▶use Encode ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13 4 ▶use Treex::PML::Schema::CDATA;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 4 ▶use Treex::PML::Factory;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 4 ▶use UNIVERSAL;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 #######################################################################################
18 # Usage : first(\&sub, @list)
19 # Purpose : Return the first element of list for which the sub returns true
20 # (no arguments are passed to the sub, it has to use $_);
21 # Return undef otherwise (or empty list in list context)
22 # Returns : see Purpose
23 # Parameters : anonymous_sub \&sub -- subroutine that does not take any arguments and
24 # returns values which can be evaluated to true or false
25 # list @list -- first element from the @list, which is accepted by \&sub is then returned
26 # Throws : no exceptions
27 # Comments : Prototyped function
28 sub first (&@) {
29 0 ▶ my $code = shift;
Subroutine first: not called CC=3 SCAR=24.8
Pod undocumented
30  
31 0 foreach (@_) {
32 0 ▶ return $_ if &{$code}();
Branch: 1 branch
BranchTrueFalseTotal
if &{$code;}() 0 0 0
33 }
34  
35 0 return;
36 }
37 #######################################################################################
38 ### from TrEd::Utils
39 # Usage : apply_file_suffix($win, $goto)
40 # Purpose : Set current tree and node positions to positions described by
41 # $goto suffix in file displayed in $win window
42 # Returns : 1 if the new position was found and set, 0 otherwise
43 # Parameters : TrEd::Window $win -- reference to TrEd::Window object
44 # string $goto -- suffix of the file (or a position in the file)
45 # Throws : no exceptions
46 # Comments : Possible suffix formats:
47 # ##123.2 -- tree number 123 (if counting from 1) and its second node
48 # #123.3 -- tree whose $root->{form} equals to #123 and its third node
49 # (only hint found in Treex/PML/Backend/CSTS/Csts2fs.pm)
50 # #a123 -- finds node with id #a123 and the tree it belongs to
51 # The node's id can also be placed after the '.', e.g. ##123.#a123, in
52 # which case the sub searches for node with id #a123 inside tree no 123
53 #
54 # Sets $win->{treeNo} and $win->{currentNode} if appropriate.
55 # See Also : parse_file_suffix()
56 sub apply_file_suffix {
57 0 ▶ my ( $win, $goto ) = @_;
Subroutine apply_file_suffix: not called CC=29 SCAR=67.7
Pod undocumented
58 0 ▶ return if ( !defined $win );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $win 0 0 0
59 0 my $fsfile = $win->{FSFile};
60 0 ▶ return if !( defined $fsfile && defined $goto && $goto ne ''); # $EMPTY_STR );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fsfile and defined $goto and $goto ne "" 0 0 0
Condition0%0/6
defined $fsfile and defined $goto and $goto ne ""
!ll&&!rl&&r
000
defined $fsfile and defined $goto
!ll&&!rl&&r
000
MC/DC0%0/3
defined $fsfile and defined $goto and $goto ne ""
defined $fsfile defined $goto $goto ne ""
Truth table0%0/4
A and B and C
A= defined $fsfileB= defined $gotoC= $goto ne ""
ABCresult
0XX0
10X0
1100
1111
61  
62 0 ▶ if ( $goto =~ m/^##([0-9]+)/ ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($goto =~ /^##([0-9]+)/) { } 0 0 0
elsif ($goto =~ /^#([0-9]+)/) { } 0 0 0
elsif ($goto =~ /^#([^#]+)$/) { } 0 0 0
63  
64 # handle cases like '##123'
65 0 my $no = int( $1 - 1 );
66 0 $win->{treeNo} = min( max( 0, $no ), $fsfile->lastTreeNo() );
67 0 ▶ return 0 if $win->{treeNo} != $no;
Branch: 1 branch
BranchTrueFalseTotal
if $win->{"treeNo"} != $no 0 0 0
68 }
69 elsif ( $goto =~ /^#([0-9]+)/ ) {
70  
71 # handle cases like '#123'
72 # this is PDT 1.0-specific code, sorry
73 0 my $no;
74 0 ▶ for ( my $i = 0; $i <= $fsfile->lastTreeNo(); $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $fsfile->lastTreeNo) 0 0 0
75 0 ▶ if ( $fsfile->treeList()->[$i]->{form} eq "#$1" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fsfile->treeList->[$i]{"form"} eq "#$1") 0 0 0
76 0 $no = $i;
77 0 last;
78 }
79 }
80 0 ▶ return 0 if ( !defined $no );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $no 0 0 0
81 0 $win->{treeNo} = $no;
82 }
83 elsif ( $goto =~ /^#([^#]+)$/ ) {
84  
85 # handle cases like '#a123'
86 0 my $id = $1;
87 0 ▶ if ( Treex::PML::Schema::CDATA->check_string_format( $id, 'ID' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ("Treex::PML::Schema::CDATA"->check_string_format($id, "ID")) 0 0 0
88 0 my $id_hash = $fsfile->appData('id-hash');
89 0 ▶ if ( UNIVERSAL::isa( $id_hash, 'HASH' )
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($id_hash, "HASH") and exists $id_hash->{$id}) 0 0 0
Condition0%0/3
UNIVERSAL::isa($id_hash, "HASH") and exists $id_hash->{$id}
!ll&&!rl&&r
000
MC/DC0%0/2
UNIVERSAL::isa($id_hash, "HASH") and exists $id_hash->{$id}
UNIVERSAL::isa($id_hash, "HASH") exists $id_hash->{$id}
Truth table0%0/3
A and B
A= UNIVERSAL::isa($id_hash, "HASH")B= exists $id_hash->{$id}
ABresult
0X0
100
111
90 && exists $id_hash->{$id} )
91 {
92 0 my $node = $id_hash->{$id};
93  
94 # we would like to use Treex::PML::Index() here, but can't
95 # and why we can not?
96 0 my $list = $fsfile->treeList();
97 0 ▶ my $root = UNIVERSAL::can( $node, 'root' ) && $node->root();
Condition0%0/3
UNIVERSAL::can($node, 'root') && $node->root
!ll&&!rl&&r
000
MC/DC0%0/2
UNIVERSAL::can($node, 'root') && $node->root
UNIVERSAL::can($node, 'root') $node->root
Truth table0%0/3
A && B
A= UNIVERSAL::can($node, 'root')B= $node->root
ABresult
0X0
100
111
98 my $n = defined($root) && first {
99 0 ▶ $list->[$_] == $root;
Subroutine __ANON__: not called CC=1 SCAR=6.9
100 }
101 0 ▶ 0 .. $#$list;
Condition0%0/3
defined $root && &first(sub { $list->[$_] == $root; } , 0 .. $list->$#*)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $root && &first(sub { $list->[$_] == $root; } , 0 .. $list->$#*)
defined $root &first(sub { $list->[$_] == $root; } , 0 .. $list->$#*)
Truth table0%0/3
A && B
A= defined $rootB= &first(sub { $list->[$_] == $root; } , 0 .. $list->$#*)
ABresult
0X0
100
111
102  
103 0 ▶ if ( defined $root and !defined($n) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $root and not defined $n) 0 0 0
Condition0%0/3
defined $root and not defined $n
!ll&&!rl&&r
000
MC/DC0%0/2
defined $root and not defined $n
defined $root not defined $n
Truth table0%0/3
A and not(B)
A= defined $rootB= not defined $n
ABresult
0X0
100
111
104 0 $n = _find_tree_no( $fsfile, $root, $list );
105  
106 # exit from _find_tree_no() function
107 0 ▶ if ( !defined $n || $n == -1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $n or $n == -1) 0 0 0
Condition0%0/3
not defined $n or $n == -1
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $n or $n == -1
not defined $n $n == -1
Truth table0%0/3
not(A) or B
A= not defined $nB= $n == -1
ABresult
1X1
011
000
108 0 return 0;
109 }
110 }
111 0 ▶ if ( defined($n) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $n) { } 0 0 0
112 0 $win->{treeNo} = $n;
113 0 $win->{currentNode} = $node;
114 0 return 1;
115 }
116 else {
117 0 return 0;
118 }
119 }
120 }
121 }
122  
123 # new: we're the dot in .[0-9]+ (TM)
124 0 ▶ if ( $goto =~ /\.([0-9]+)$/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($goto =~ /\.([0-9]+)$/) { } 0 0 0
elsif ($goto =~ /\.([^0-9#][^#]*)$/) { } 0 0 0
125 0 my $root = get_node_by_no( $win, $1 );
126 0 ▶ if ($root) {
Branch: 1 branch
BranchTrueFalseTotal
if ($root) { } 0 0 0
127 0 $win->{currentNode} = $root;
128 0 return 1;
129 }
130 else {
131 0 return 0;
132 }
133 }
134 elsif ( $goto =~ /\.([^0-9#][^#]*)$/ ) {
135 0 my $id = $1;
136 0 ▶ if ( Treex::PML::Schema::CDATA->check_string_format( $id, 'ID' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ("Treex::PML::Schema::CDATA"->check_string_format($id, "ID")) 0 0 0
137 0 my $id_hash = $fsfile->appData('id-hash');
138 0 ▶ if ( UNIVERSAL::isa( $id_hash, 'HASH' )
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($id_hash, 'HASH') and exists $id_hash->{$id}) { } 0 0 0
Condition0%0/3
UNIVERSAL::isa($id_hash, "HASH") and exists $id_hash->{$id}
!ll&&!rl&&r
000
MC/DC0%0/2
UNIVERSAL::isa($id_hash, "HASH") and exists $id_hash->{$id}
UNIVERSAL::isa($id_hash, "HASH") exists $id_hash->{$id}
Truth table0%0/3
A and B
A= UNIVERSAL::isa($id_hash, "HASH")B= exists $id_hash->{$id}
ABresult
0X0
100
111
139 && exists( $id_hash->{$id} ) )
140 {
141 return 1
142 0 ▶ if ( $win->{currentNode} = $id_hash->{$id} ); # assignment
Branch: 1 branch
BranchTrueFalseTotal
if $win->{"currentNode"} = $id_hash->{$id} 0 0 0
143 }
144 else {
145 0 return 0;
146 }
147 }
148 }
149 0 return 1;
150  
151 # hey, caller, you should redraw after this!
152 }
153  
154 #TODO: document & test this unclear function
155 sub _find_tree_no {
156 0 ▶ my ( $fsfile, $root, $list ) = @_;
Subroutine _find_tree_no: not called CC=14 SCAR=53.5
157 0 my $n = undef;
158  
159 # hm, we have a node, but don't know to which tree
160 # it belongs
161 0 my $trees_type = $fsfile->metaData('pml_trees_type');
162 0 my $root_type = $root->type();
163  
164 #TODO: empty? or defined???
165 0 ▶ if ( $trees_type and $root_type ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($trees_type and $root_type) 0 0 0
Condition0%0/3
$trees_type and $root_type
!ll&&!rl&&r
000
MC/DC0%0/2
$trees_type and $root_type
$trees_type $root_type
Truth table0%0/3
A and B
A= $trees_typeB= $root_type
ABresult
0X0
100
111
166 0 my $trees_type_is = $trees_type->get_decl_type();
167 0 my %paths;
168 my $is_sequence;
169 0 my $found;
170 0 my @elements;
171 0 ▶ if ( $trees_type_is == Treex::PML::Schema::PML_LIST_DECL() ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($trees_type_is == 6) { } 0 0 0
elsif ($trees_type_is == 5) { } 0 0 0
172 0 @elements = [ 'LM', $trees_type->get_content_decl() ];
173 }
174 elsif ( $trees_type_is == Treex::PML::Schema::PML_SEQUENCE_DECL() ) {
175  
176 # Treex::PML::Schema::Element::get_name(),
177 # ::Schema::Decl::get_content_decl()
178 0 @elements = map { [ $_->get_name(), $_->get_content_decl() ] }
179 $trees_type->get_elements();
180 0 $is_sequence = 1;
181 }
182 else {
183 0 return -1;
184 }
185  
186 0 for my $el (@elements) {
187 $paths{ $el->[0] } = [
188 $trees_type->get_schema->find_decl(
189 sub {
190 0 ▶ $_[0] == $root_type;
Subroutine __ANON__: not called CC=1 SCAR=6.9
191 },
192 0 $el->[1],
193 {}
194 )
195 ];
196 0 ▶ if ( @{ $paths{ $el->[0] } } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$paths{$el->[0]};}) 0 0 0
197 0 $found = 1;
198 }
199 }
200 0 ▶ return -1 if !$found;
Branch: 1 branch
BranchTrueFalseTotal
unless $found 0 0 0
201 TREE:
202 0 for my $i ( 0 .. $#$list ) {
203 0 my $tree = $list->[$i];
204 my $paths
205 = $is_sequence
206 ? $paths{ $tree->{'#name'} }
207 0 ▶ : $paths{LM};
Branch: 1 branch
BranchTrueFalseTotal
$is_sequence ? : 0 0 0
208 0 ▶ for my $p ( @{ $paths || [] } ) {
Branch: 1 branch
BranchTrueFalseTotal
$paths or [] 0 0 0
209 0 for my $value ( $tree->all($p) ) {
210 0 ▶ if ( $value == $root ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value == $root) 0 0 0
211 0 $n = $i;
212 0 last TREE;
213 }
214 }
215 }
216 }
217 }
218 0 return $n;
219 }
220  
221 #######################################################################################
222 ### from TrEd::Utils
223 # Usage : parse_file_suffix($filename)
224 # Purpose : Split file name into file name itself and its suffix
225 # Returns : List which contains file name and its suffix, if there is no suffix,
226 # second list element is undef
227 # Parameters : scalar $filename -- name of the file
228 # Throws : no exceptions
229 # Comments : File suffix can be of the following forms:
230 # a) 1 or 2 #-signs, upper-case characters or numbers, and optionally followed by
231 # optional dash, full stop and at least one number
232 # b) 2 #-signs, at least one number, full stop, followed by
233 # one non-numeric not-# character and any number of not-# chars
234 # c) 1 #-sign followed by any number of not-# characters
235 # See Also :
236 sub parse_file_suffix {
237 0 ▶ my ($filename) = @_;
Subroutine parse_file_suffix: not called CC=7 SCAR=40.3
Pod undocumented
238 #
239 0 ▶ return if ( !defined $filename );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $filename 0 0 0
240 0 ▶ if ( $filename =~ s/(##?[0-9A-Z]+(?:-?\.[0-9]+)?)$// ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($filename =~ s/(##?[0-9A-Z]+(?:-?\.[0-9]+)?)$//) { } 0 0 0
elsif ($filename =~ /^ (.*) # file name with any characters followed by (\#\#[0-9]+\.) # 2x#, at least one number and full stop ([^0-9\#][^\#]*) # followed by one non-numeric not-# character and any number of not-# chars $ /x and 'Treex::PML::Schema::CDATA'->check_string_format($3, 'ID')) { } 0 0 0
elsif ($filename =~ /^ (.*) # file name with any characters followed by \# # one hash followed by ([^\#]+) # any number of not-# characters $ /x and 'Treex::PML::Schema::CDATA'->check_string_format($2, 'ID')) { } 0 0 0
241 0 return ( $filename, $1 );
242 }
243 ▶ elsif (
Condition0%0/3
$filename =~ /^ (.*) # file name with any characters followed by (\#\#[0-9]+\.) # 2x#, at least one number and full stop ([^0-9\#][^\#]*) # followed by one non-numeric not-# character and any number of not-# chars $ /x and "Treex::PML::Schema::CDATA"->check_string_format($3, "ID")
!ll&&!rl&&r
000
MC/DC0%0/2
$filename =~ /^ (.*) # file name with any characters followed by (\#\#[0-9]+\.) # 2x#, at least one number and full stop ([^0-9\#][^\#]*) # followed by one non-numeric not-# character and any number of not-# chars $ /x and "Treex::PML::Schema::CDATA"->check_string_format($3, "ID")
$filename =~ /^ (.*) # file name with any characters followed by (\#\#[0-9]+\.) # 2x#, at least one number and full stop ([^0-9\#][^\#]*) # followed by one non-numeric not-# character and any number of not-# chars $ /x "Treex::PML::Schema::CDATA"->check_string_format($3, "ID")
Truth table0%0/3
A and B
A= $filename =~ /^ (.*) # file name with any characters followed by (\#\#[0-9]+\.) # 2x#, at least one number and full stop ([^0-9\#][^\#]*) # followed by one non-numeric not-# character and any number of not-# chars $ /xB= "Treex::PML::Schema::CDATA"->check_string_format($3, "ID")
ABresult
0X0
100
111
244 $filename =~ m{^
245 (.*) # file name with any characters followed by
246 (\#\#[0-9]+\.) # 2x#, at least one number and full stop
247 ([^0-9\#][^\#]*) # followed by one non-numeric not-# character and any number of not-# chars
248 $
249 }x
250 and Treex::PML::Schema::CDATA->check_string_format( $3, 'ID' )
251 )
252 {
253 0 return ( $1, $2 . $3 );
254 }
255 ▶ elsif (
Condition0%0/3
$filename =~ /^ (.*) # file name with any characters followed by \# # one hash followed by ([^\#]+) # any number of not-# characters $ /x and "Treex::PML::Schema::CDATA"->check_string_format($2, "ID")
!ll&&!rl&&r
000
MC/DC0%0/2
$filename =~ /^ (.*) # file name with any characters followed by \# # one hash followed by ([^\#]+) # any number of not-# characters $ /x and "Treex::PML::Schema::CDATA"->check_string_format($2, "ID")
$filename =~ /^ (.*) # file name with any characters followed by \# # one hash followed by ([^\#]+) # any number of not-# characters $ /x "Treex::PML::Schema::CDATA"->check_string_format($2, "ID")
Truth table0%0/3
A and B
A= $filename =~ /^ (.*) # file name with any characters followed by \# # one hash followed by ([^\#]+) # any number of not-# characters $ /xB= "Treex::PML::Schema::CDATA"->check_string_format($2, "ID")
ABresult
0X0
100
111
256 $filename =~ m{^
257 (.*) # file name with any characters followed by
258 \# # one hash followed by
259 ([^\#]+) # any number of not-# characters
260 $
261 }x
262 and Treex::PML::Schema::CDATA->check_string_format( $2, 'ID' )
263 )
264 {
265 0 return ( $1, '#' . $2 );
266 }
267 else {
268 0 return ( $filename, undef );
269 }
270 }
271  
272 ######################################
273  
274  
275  
276 # open a data file and related files on lower layers
277 sub open_file {
278 0 ▶ my $filename = shift;
Subroutine open_file: not called CC=5 SCAR=34.0
Pod undocumented
279 # TODO fsfile caching and closing !!!
280 0 my $fsfile = Treex::PML::Factory->createDocumentFromFile($filename);
281 0 ▶ if ($Treex::PML::FSError) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Treex::PML::FSError) 0 0 0
282 0 die "Error loading file $filename: $Treex::PML::FSError ($!)\n";
283 }
284 0 my $requires = $fsfile->metaData('fs-require');
285 0 ▶ if ($requires) {
Branch: 1 branch
BranchTrueFalseTotal
if ($requires) 0 0 0
286 0 for my $req (@$requires) {
287 0 my $req_filename = $req->[1]->abs( $fsfile->URL );
288 0 warn("REQUIRES $req_filename");
289 0 my $secondary = $fsfile->appData('ref');
290 0 ▶ unless ($secondary) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($secondary) 0 0 0
291 0 $secondary = {};
292 0 $fsfile->changeAppData( 'ref', $secondary );
293 }
294 0 my $sf = open_file($req_filename);
295 0 $secondary->{ $req->[0] } = $sf;
296 }
297 }
298 0 return $fsfile;
299 }
300 #############################################
301  
302  
303 sub GetSecondaryFiles {
304 0 ▶ my ($fsfile) = @_;
Subroutine GetSecondaryFiles: not called CC=5 SCAR=34.0
Pod undocumented
305 # is probably the same as Treex::PML::Document->relatedDocuments()
306 # a reference to a list of pairs (id, URL)
307 0 my $requires = $fsfile->metaData('fs-require');
308 0 my @secondary;
309 0 ▶ if ($requires) {
Branch: 1 branch
BranchTrueFalseTotal
if ($requires) 0 0 0
310 0 foreach my $req (@$requires) {
311 0 my $id = $req->[0];
312 my $req_fs
313 = ref( $fsfile->appData('ref') )
314 0 ▶ ? $fsfile->appData('ref')->{$id}
Branch: 1 branch
BranchTrueFalseTotal
ref $fsfile->appData('ref') ? : 0 0 0
315 : undef;
316 0 ▶ if ( UNIVERSAL::DOES::does( $req_fs, 'Treex::PML::Document' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::DOES::does($req_fs, "Treex::PML::Document")) 0 0 0
317 0 push( @secondary, $req_fs );
318 }
319 }
320 }
321 0 return uniq(@secondary);
322 }
323  
324  
325 sub OpenSecondaryFiles {
326 0 ▶ my ( $fsfile ) = @_;
Subroutine OpenSecondaryFiles: not called CC=6 SCAR=37.4
Pod undocumented
327 0 my $win = undef;
328 0 my $status = 1;
329 0 ▶ return $status if $fsfile->appData('fs-require-loaded');
Branch: 1 branch
BranchTrueFalseTotal
if $fsfile->appData("fs-require-loaded") 0 0 0
330 0 $fsfile->changeAppData( 'fs-require-loaded', 1 );
331 0 my $requires = $fsfile->metaData('fs-require'); #$fsfile->relatedDocuments()
332 0 ▶ if (defined $requires) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $requires) 0 0 0
333 0 for my $req (@$requires) {
334 0 ▶ next if ref( $fsfile->appData('ref')->{ $req->[0] } );
Branch: 1 branch
BranchTrueFalseTotal
if ref $fsfile->appData("ref")->{$req->[0]} 0 0 0
335 0 my $req_filename
336 = Treex::PML::ResolvePath( $fsfile->filename, $req->[1] );
337 0 print STDERR "Pre-loading dependent $req_filename ($req->[1]) as appData('ref')->{$req->[0]}\n";
338 0 my ( $req_fs, $status2 ) = open_file( # TODO simplify Tred::File::open_file() subrutine
339 $win, $req_filename,
340 -preload => 1,
341 -norecent => 1
342 );
343 0 _merge_status( $status, $status2 );
344 0 ▶ if ( !$status2->{ok} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $status2->{'ok'}) { } 0 0 0
345 0 close_file( $win, -fsfile => $req_fs, -no_update => 1 );
346 0 return $status2;
347 }
348 else { #zaznac do zavisleho, ze je zavisly na nadradenom
349 0 push @{ $req_fs->appData('fs-part-of') },
350 $fsfile; # is this a good idea?
351 0 main::__debug("Setting appData('ref')->{$req->[0]} to $req_fs");
352 0 $fsfile->appData('ref')->{ $req->[0] } = $req_fs;
353 }
354 }
355 }
356 0 return $status;
357 }
358  
359 sub ThisAddress {
360 0 ▶ my ($node, $fsfile) = @_;
Subroutine ThisAddress: not called CC=2 SCAR=17.9
Pod undocumented
361 0 my $type = $node->type;
362 0 ▶ my ($id_attr) = $type && $type->find_members_by_role('#ID');
Condition0%0/3
$type && $type->find_members_by_role('#ID')
!ll&&!rl&&r
000
MC/DC0%0/2
$type && $type->find_members_by_role('#ID')
$type $type->find_members_by_role('#ID')
Truth table0%0/3
A && B
A= $typeB= $type->find_members_by_role('#ID')
ABresult
0X0
100
111
363  
364 0 return basename($fsfile->filename) . '#' . $node->{ $id_attr->get_name }
365 }
366  
367 sub GetNodeIndex {
368 0 ▶ my $node = shift;
Subroutine GetNodeIndex: not called CC=2 SCAR=17.9
Pod undocumented
369 0 my $i = -1;
370 0 ▶ while ($node) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node) 0 0 0
371 0 $node = $node->previous();
372 0 $i++;
373 }
374 0 return $i;
375 }
376  
377  
378 4 1;
« lib/PMLTQ/Suggest.pm ↑ Summary blib/lib/PMLTQ/Suggest.pm »