File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
ql/lib/codeql/actions/ast/internal Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -4,20 +4,24 @@ private import codeql.actions.Helper
4
4
private import codeql.actions.config.Config
5
5
private import codeql.actions.DataFlow
6
6
7
+ bindingset [ text]
8
+ int numberOfLines ( string text ) { result = max ( int i | exists ( text .splitAt ( "\n" , i ) ) ) }
9
+
7
10
/**
8
11
* Gets the length of each line in the StringValue .
9
12
*/
10
13
bindingset [ text]
11
- int lineLength ( string text , int idx ) {
12
- exists ( string line | line = text .splitAt ( "\n" , idx ) and result = line .length ( ) + 1 )
14
+ int lineLength ( string text , int i ) {
15
+ i in [ 0 .. numberOfLines ( text ) ] and
16
+ result = text .splitAt ( "\n" , i ) .length ( ) + 1
13
17
}
14
18
15
19
/**
16
20
* Gets the sum of the length of the lines up to the given index.
17
21
*/
18
22
bindingset [ text]
19
23
int partialLineLengthSum ( string text , int i ) {
20
- i in [ 0 .. count ( text . splitAt ( "\n" ) ) ] and
24
+ i in [ 0 .. numberOfLines ( text ) ] and
21
25
result = sum ( int j , int length | j in [ 0 .. i ] and length = lineLength ( text , j ) | length )
22
26
}
23
27
You can’t perform that action at this time.
0 commit comments