File tree Expand file tree Collapse file tree
ql/lib/codeql/actions/ast/internal Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,20 +4,24 @@ private import codeql.actions.Helper
44private import codeql.actions.config.Config
55private import codeql.actions.DataFlow
66
7+ bindingset [ text]
8+ int numberOfLines ( string text ) { result = max ( int i | exists ( text .splitAt ( "\n" , i ) ) ) }
9+
710/**
811 * Gets the length of each line in the StringValue .
912 */
1013bindingset [ 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
1317}
1418
1519/**
1620 * Gets the sum of the length of the lines up to the given index.
1721 */
1822bindingset [ text]
1923int partialLineLengthSum ( string text , int i ) {
20- i in [ 0 .. count ( text . splitAt ( "\n" ) ) ] and
24+ i in [ 0 .. numberOfLines ( text ) ] and
2125 result = sum ( int j , int length | j in [ 0 .. i ] and length = lineLength ( text , j ) | length )
2226}
2327
You can’t perform that action at this time.
0 commit comments