File tree 4 files changed +48
-0
lines changed
javascript/ql/test/library-tests/GetALocalSource
4 files changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ function t1 ( ) {
2
+ const { ...rest } = source ( 't1.1' ) ;
3
+ rest ; // $ MISSING: getALocalSource=rest
4
+ }
5
+
6
+ function t2 ( ) {
7
+ const [ ...rest ] = source ( 't2.1' ) ;
8
+ rest ; // $ MISSING: getALocalSource=rest
9
+ }
10
+
11
+ function t3 ( ) {
12
+ const { p1, ...rest } = source ( 't3.1' ) ;
13
+ p1 ; // $ getALocalSource=p1
14
+ rest ; // $ MISSING: getALocalSource=rest
15
+ }
Original file line number Diff line number Diff line change
1
+ | rest-pattern.js:13:5:13:6 | p1 | p1 |
Original file line number Diff line number Diff line change
1
+ import javascript
2
+
3
+ string nodeName ( DataFlow:: SourceNode node ) {
4
+ result = node .getAstNode ( ) .( VarRef ) .getName ( )
5
+ or
6
+ result = node .getAstNode ( ) .( PropertyPattern ) .getName ( )
7
+ or
8
+ result = node .getAstNode ( ) .( PropAccess ) .getPropertyName ( )
9
+ or
10
+ exists ( DataFlow:: InvokeNode invoke |
11
+ node = invoke and
12
+ invoke .getCalleeName ( ) = "source" and
13
+ result = invoke .getArgument ( 0 ) .getStringValue ( )
14
+ )
15
+ }
16
+
17
+ bindingset [ node1, node2]
18
+ pragma [ inline_late]
19
+ predicate sameLine ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
20
+ node1 .getLocation ( ) .getFile ( ) = node2 .getLocation ( ) .getFile ( ) and
21
+ node1 .getLocation ( ) .getStartLine ( ) = node2 .getLocation ( ) .getStartLine ( )
22
+ }
23
+
24
+ query predicate getALocalSource ( DataFlow:: Node node , string name ) {
25
+ exists ( DataFlow:: SourceNode sn |
26
+ sn = node .getALocalSource ( ) and
27
+ name = nodeName ( sn ) and
28
+ not sameLine ( node , sn )
29
+ )
30
+ }
Original file line number Diff line number Diff line change
1
+ query: test.ql
2
+ postprocess: utils/test/InlineExpectationsTestQuery.ql
You can’t perform that action at this time.
0 commit comments