Skip to content

Commit 0f2de46

Browse files
committed
JS: Emit variable bindings for 'this' expressions
1 parent f0f58da commit 0f2de46

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

javascript/extractor/src/com/semmle/js/extractor/ASTExtractor.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,6 +1896,15 @@ public Label visit(JSXThisExpr nd, Context c) {
18961896
return visit((ThisExpression) nd, c);
18971897
}
18981898

1899+
@Override
1900+
public Label visit(ThisExpression nd, Context c) {
1901+
Label key = super.visit(nd, c);
1902+
if (c.idcontext == IdContext.VAR_BIND || c.idcontext == IdContext.VAR_IN_TYPE_BIND) {
1903+
addVariableBinding("bind", key, "this");
1904+
}
1905+
return key;
1906+
}
1907+
18991908
@Override
19001909
public Label visit(JSXMemberExpression nd, Context c) {
19011910
Label key = super.visit(nd, c);

javascript/ql/lib/semmlecode.javascript.dbscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ is_arguments_object (int id: @variable ref);
453453

454454
@lexical_name = @variable | @local_type_name | @local_namespace_name;
455455

456-
@bind_id = @varaccess | @local_var_type_access;
456+
@bind_id = @varaccess | @local_var_type_access | @this_expr;
457457
bind (unique int id: @bind_id ref,
458458
int decl: @variable ref);
459459

0 commit comments

Comments
 (0)