lib/Kephra/App/Editor/Tool.pm

filter: Statementstmt 15.0% 6 / 40 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 28.5% 2 / 7 Podpod n/a totaltotal 11.4% 8 / 70 CC 12 SCAR 30.2
CC
12
Cov
10%
toggle_block_comment_line
42.0
toggle_comment_line
20.0
insert_brace
6.0
CRAP 20.6
« lib/Kephra/IO/LocalFile.pm ↑ Summary lib/Kephra/App/Editor/Property.pm »
1 1 ▶use v5.12;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package Kephra::App::Editor::Tool;
5  
6 package Kephra::App::Editor;
7  
8  
9 0 ▶sub insert_brace {
Subroutine insert_brace: not called CC=2 SCAR=17.9
10 0 my ($self, $left, $right) = @_;
11 0 my ($start_pos, $end_pos) = $self->GetSelection;
12  
13 0 ▶ if ($start_pos == $end_pos) {
Branch: 1 branch
BranchTrueFalseTotal
if ($start_pos == $end_pos) { } 0 0 0
14 0 $self->InsertText( $start_pos, $left.$right );
15 0 $self->SetSelection( $start_pos+1, $end_pos+1 );
16 }
17 else {
18 0 $self->BeginUndoAction();
19 0 $self->InsertText( $end_pos, $right );
20 0 $self->InsertText( $start_pos, $left );
21 0 $self->SetSelection( $start_pos, $end_pos+2 );
22 0 $self->EndUndoAction();
23 }
24 }
25  
26 0 ▶sub toggle_comment_line {
Subroutine toggle_comment_line: not called CC=4 SCAR=30.0
27 0 my ($self, $line_nr) = @_;
28 0 ▶ return unless defined $line_nr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $line_nr 0 0 0
29 0 $self->SetSelection( $self->PositionFromLine( $line_nr ),
30 $self->GetLineEndPosition( $line_nr ) );
31 0 $self->GetSelectedText( ) =~ /^(\s*)((?:#\s)|(?:#~\s))?(.*)$/;
32 0 ▶ return unless $3;
Branch: 1 branch
BranchTrueFalseTotal
unless $3 0 0 0
33 0 ▶ $2 ? $self->ReplaceSelection( $1. $3 )
Branch: 1 branch
BranchTrueFalseTotal
$2 ? : 0 0 0
34 : $self->ReplaceSelection( $1.'# '.$3 );
35 }
36  
37 0 ▶sub toggle_block_comment_line {
Subroutine toggle_block_comment_line: not called CC=6 SCAR=37.4
38 0 my ($self, $line_nr) = @_;
39 0 ▶ return unless defined $line_nr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $line_nr 0 0 0
40 0 $self->SetSelection( $self->PositionFromLine( $line_nr ),
41 $self->GetLineEndPosition( $line_nr ) );
42 0 $self->GetSelectedText( ) =~ /^(\s*)(#?)(~\s)?(.*)$/;
43 0 ▶ return if (not $4) or ($2 and not $3);
Branch: 1 branch
BranchTrueFalseTotal
if not $4 or $2 and not $3 0 0 0
Condition0%0/6
not $4 or $2 and not $3
l!l&&r!l&&!r
000
$2 and not $3
!ll&&!rl&&r
000
MC/DC0%0/3
not $4 or $2 and not $3
not $4 $2 not $3
Truth table0%0/4
not(A) or B and not(C)
A= not $4B= $2C= not $3
ABCresult
1XX1
0111
00X0
0100
44 0 ▶ $2 ? $self->ReplaceSelection( $1. $4 )
Branch: 1 branch
BranchTrueFalseTotal
$2 ? : 0 0 0
45 : $self->ReplaceSelection( $1.'#~ '.$4 );
46 }
47  
48 0 ▶sub toggle_comment {
Subroutine toggle_comment: not called CC=2 SCAR=17.9
49 0 my ($self) = @_;
50 0 my ($old_start, $old_end) = $self->GetSelection;
51 0 $self->BeginUndoAction();
52  
53 0 toggle_comment_line( $self, $_ ) for $self->LineFromPosition( $old_start ) ..
54 $self->LineFromPosition( $old_end );
55 0 $self->GotoPos( $old_end );
56 0 $self->EndUndoAction();
57 }
58  
59 0 ▶sub toggle_block_comment {
Subroutine toggle_block_comment: not called CC=2 SCAR=17.9
60 0 my ($self) = @_;
61 0 my ($old_start, $old_end) = $self->GetSelection;
62 0 $self->BeginUndoAction();
63  
64 0 toggle_block_comment_line( $self, $_ ) for $self->LineFromPosition( $old_start ) ..
65 $self->LineFromPosition( $old_end );
66 0 $self->GotoPos( $old_end );
67 0 $self->EndUndoAction();
68 }
69  
70  
71 1 1;
72  
« lib/Kephra/IO/LocalFile.pm ↑ Summary lib/Kephra/App/Editor/Property.pm »