@@ -359,6 +359,9 @@ class ArrayLiteralNode extends DataFlow::ValueNode, DataFlow::SourceNode {
359359
360360 /** Gets an element of this array literal. */
361361 DataFlow:: ValueNode getAnElement ( ) { result = DataFlow:: valueNode ( astNode .getAnElement ( ) ) }
362+
363+ /** Gets the initial size of this array. */
364+ int getSize ( ) { result = astNode .getSize ( ) }
362365}
363366
364367/** A data flow node corresponding to a `new Array()` or `Array()` invocation. */
@@ -376,6 +379,14 @@ class ArrayConstructorInvokeNode extends DataFlow::InvokeNode {
376379 getNumArgument ( ) > 1 and
377380 result = getAnArgument ( )
378381 }
382+
383+ /** Gets the initial size of the created array, if it can be determined. */
384+ int getSize ( ) {
385+ if getNumArgument ( ) = 1 then
386+ result = getArgument ( 0 ) .getIntValue ( )
387+ else
388+ result = count ( getAnElement ( ) )
389+ }
379390}
380391
381392/**
@@ -396,6 +407,12 @@ class ArrayCreationNode extends DataFlow::ValueNode, DataFlow::SourceNode {
396407
397408 /** Gets an initial element of this array, if one if provided. */
398409 DataFlow:: ValueNode getAnElement ( ) { result = getElement ( _) }
410+
411+ /** Gets the initial size of the created array, if it can be determined. */
412+ int getSize ( ) {
413+ result = this .( ArrayLiteralNode ) .getSize ( ) or
414+ result = this .( ArrayConstructorInvokeNode ) .getSize ( )
415+ }
399416}
400417
401418/**
@@ -991,6 +1008,11 @@ private class BindPartialCall extends AdditionalPartialInvokeNode, DataFlow::Met
9911008 callback = getReceiver ( ) and
9921009 argument = getArgument ( index + 1 )
9931010 }
1011+
1012+ override DataFlow:: SourceNode getBoundFunction ( int boundArgs ) {
1013+ boundArgs = getNumArgument ( ) - 1 and
1014+ result = this
1015+ }
9941016}
9951017
9961018/**
@@ -1004,6 +1026,11 @@ private class LodashPartialCall extends AdditionalPartialInvokeNode {
10041026 callback = getArgument ( 0 ) and
10051027 argument = getArgument ( index + 1 )
10061028 }
1029+
1030+ override DataFlow:: SourceNode getBoundFunction ( int boundArgs ) {
1031+ boundArgs = getNumArgument ( ) - 1 and
1032+ result = this
1033+ }
10071034}
10081035
10091036/**
@@ -1020,4 +1047,9 @@ private class RamdaPartialCall extends AdditionalPartialInvokeNode {
10201047 callback = getArgument ( 0 ) and
10211048 argument = getArgumentsArray ( ) .getElement ( index )
10221049 }
1050+
1051+ override DataFlow:: SourceNode getBoundFunction ( int boundArgs ) {
1052+ boundArgs = getArgumentsArray ( ) .getSize ( ) and
1053+ result = this
1054+ }
10231055}
0 commit comments