File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import javascript
2+
3+ abstract class ProgressBar extends CallExpr {
4+ ProgressBar ( ) { any ( ) }
5+
6+ abstract Function getCallback ( ) ;
7+
8+ abstract ObjectExpr getOptions ( ) ;
9+
10+ predicate usesToken ( ) { this .getCallback ( ) .getNumParameter ( ) >= 2 }
11+
12+ predicate isCancellable ( ) {
13+ this .getOptions ( ) .getPropertyByName ( "cancellable" ) .getInit ( ) .( BooleanLiteral ) .getBoolValue ( ) =
14+ true
15+ }
16+ }
17+
18+ class WithProgressCall extends ProgressBar {
19+ WithProgressCall ( ) { this .getCalleeName ( ) = "withProgress" }
20+
21+ override Function getCallback ( ) { result = this .getArgument ( 0 ) }
22+
23+ override ObjectExpr getOptions ( ) { result = this .getArgument ( 1 ) }
24+ }
25+
26+ class WithInheritedProgressCall extends ProgressBar {
27+ WithInheritedProgressCall ( ) { this .getCalleeName ( ) = "withInheritedProgress" }
28+
29+ override Function getCallback ( ) { result = this .getArgument ( 1 ) }
30+
31+ override ObjectExpr getOptions ( ) { result = this .getArgument ( 2 ) }
32+ }
Original file line number Diff line number Diff line change 1010 */
1111
1212import javascript
13+ import ProgressBar
1314
14- class NewTokenSource extends CallExpr {
15- NewTokenSource ( ) {
16- this .getCalleeName ( ) = "withProgress" or this .getCalleeName ( ) = "withInheritedProgress"
17- }
18-
19- Function getCallback ( ) {
20- this .getCalleeName ( ) = "withProgress" and result = this .getArgument ( 0 )
21- or
22- this .getCalleeName ( ) = "withInheritedProgress" and result = this .getArgument ( 1 )
23- }
24-
25- ObjectExpr getOptions ( ) {
26- this .getCalleeName ( ) = "withProgress" and result = this .getArgument ( 1 )
27- or
28- this .getCalleeName ( ) = "withInheritedProgress" and result = this .getArgument ( 2 )
29- }
30-
31- predicate usesToken ( ) { this .getCallback ( ) .getNumParameter ( ) >= 2 }
32-
33- predicate isCancellable ( ) {
34- this .getOptions ( ) .getPropertyByName ( "cancellable" ) .getInit ( ) .( BooleanLiteral ) .getBoolValue ( ) =
35- true
36- }
37- }
38-
39- from NewTokenSource t
15+ from ProgressBar t
4016where t .isCancellable ( ) and not t .usesToken ( )
4117select t , "This progress bar is cancelable but the token is not used"
You can’t perform that action at this time.
0 commit comments