Skip to content

Commit d3da790

Browse files
authored
Merge pull request #6873 from erik-krogh/explicit-this
Approved by esbena
2 parents 3c8f6e3 + 1e752f3 commit d3da790

File tree

88 files changed

+2086
-1960
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+2086
-1960
lines changed

javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/CodeToFeatures.qll

+5-5
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ module Raw {
119119

120120
predicate isEntityNameNode(Entity entity) {
121121
exists(int index |
122-
TAstNode(entity) = getParentNode() and
123-
this = getParentNode().astNodeChild(index) and
122+
TAstNode(entity) = this.getParentNode() and
123+
this = this.getParentNode().astNodeChild(index) and
124124
// An entity name node must be the first child of the entity.
125-
index = min(int otherIndex | exists(getParentNode().astNodeChild(otherIndex))) and
125+
index = min(int otherIndex | exists(this.getParentNode().astNodeChild(otherIndex))) and
126126
entity.getName() = rawNode.(raw::VarDecl).getName()
127127
)
128128
}
@@ -319,7 +319,7 @@ module Wrapped {
319319

320320
AstNode getChild(int index) { result = injectedChild(enclosingEntity, rawNode, index) }
321321

322-
string toString() { result = getType() }
322+
string toString() { result = this.getType() }
323323

324324
Raw::Location getLocation() { result = rawNode.getLocation() }
325325
}
@@ -378,7 +378,7 @@ module DatabaseFeatures {
378378

379379
override string getType() { result = "javascript function" }
380380

381-
override string toString() { result = "Entity: " + getName() }
381+
override string toString() { result = "Entity: " + this.getName() }
382382

383383
override Location getLocation() { result = entity.getLocation() }
384384

javascript/ql/lib/semmle/javascript/AST.qll

+26-26
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class ASTNode extends @ast_node, NodeInStmtContainer {
2626
override Location getLocation() { hasLocation(this, result) }
2727

2828
override File getFile() {
29-
result = getLocation().getFile() // Specialized for performance reasons
29+
result = this.getLocation().getFile() // Specialized for performance reasons
3030
}
3131

3232
/** Gets the first token belonging to this element. */
@@ -76,7 +76,7 @@ class ASTNode extends @ast_node, NodeInStmtContainer {
7676

7777
/** Gets the toplevel syntactic unit to which this element belongs. */
7878
cached
79-
TopLevel getTopLevel() { Stages::Ast::ref() and result = getParent().getTopLevel() }
79+
TopLevel getTopLevel() { Stages::Ast::ref() and result = this.getParent().getTopLevel() }
8080

8181
/**
8282
* Gets the `i`th child node of this node.
@@ -85,10 +85,10 @@ class ASTNode extends @ast_node, NodeInStmtContainer {
8585
* change between versions of the extractor.
8686
*/
8787
ASTNode getChild(int i) {
88-
result = getChildExpr(i) or
89-
result = getChildStmt(i) or
88+
result = this.getChildExpr(i) or
89+
result = this.getChildStmt(i) or
9090
properties(result, this, i, _, _) or
91-
result = getChildTypeExpr(i)
91+
result = this.getChildTypeExpr(i)
9292
}
9393

9494
/** Gets the `i`th child statement of this node. */
@@ -101,22 +101,22 @@ class ASTNode extends @ast_node, NodeInStmtContainer {
101101
TypeExpr getChildTypeExpr(int i) { typeexprs(result, _, this, i, _) }
102102

103103
/** Gets a child node of this node. */
104-
ASTNode getAChild() { result = getChild(_) }
104+
ASTNode getAChild() { result = this.getChild(_) }
105105

106106
/** Gets a child expression of this node. */
107-
Expr getAChildExpr() { result = getChildExpr(_) }
107+
Expr getAChildExpr() { result = this.getChildExpr(_) }
108108

109109
/** Gets a child statement of this node. */
110-
Stmt getAChildStmt() { result = getChildStmt(_) }
110+
Stmt getAChildStmt() { result = this.getChildStmt(_) }
111111

112112
/** Gets the number of child nodes of this node. */
113-
int getNumChild() { result = count(getAChild()) }
113+
int getNumChild() { result = count(this.getAChild()) }
114114

115115
/** Gets the number of child expressions of this node. */
116-
int getNumChildExpr() { result = count(getAChildExpr()) }
116+
int getNumChildExpr() { result = count(this.getAChildExpr()) }
117117

118118
/** Gets the number of child statements of this node. */
119-
int getNumChildStmt() { result = count(getAChildStmt()) }
119+
int getNumChildStmt() { result = count(this.getAChildStmt()) }
120120

121121
/** Gets the parent node of this node, if any. */
122122
cached
@@ -126,7 +126,7 @@ class ASTNode extends @ast_node, NodeInStmtContainer {
126126
ControlFlowNode getFirstControlFlowNode() { result = this }
127127

128128
/** Holds if this syntactic entity belongs to an externs file. */
129-
predicate inExternsFile() { getTopLevel().isExterns() }
129+
predicate inExternsFile() { this.getTopLevel().isExterns() }
130130

131131
/**
132132
* Holds if this is an ambient node that is not a `TypeExpr` and is not inside a `.d.ts` file
@@ -137,9 +137,9 @@ class ASTNode extends @ast_node, NodeInStmtContainer {
137137
cached
138138
private predicate isAmbientInternal() {
139139
Stages::Ast::ref() and
140-
getParent().isAmbientInternal()
140+
this.getParent().isAmbientInternal()
141141
or
142-
not isAmbientTopLevel(getTopLevel()) and
142+
not isAmbientTopLevel(this.getTopLevel()) and
143143
(
144144
this instanceof ExternalModuleDeclaration
145145
or
@@ -176,9 +176,9 @@ class ASTNode extends @ast_node, NodeInStmtContainer {
176176
*/
177177
pragma[inline]
178178
predicate isAmbient() {
179-
isAmbientInternal()
179+
this.isAmbientInternal()
180180
or
181-
isAmbientTopLevel(getTopLevel())
181+
isAmbientTopLevel(this.getTopLevel())
182182
or
183183
this instanceof TypeExpr
184184
}
@@ -211,11 +211,11 @@ class TopLevel extends @toplevel, StmtContainer {
211211
predicate isMinified() {
212212
Stages::Ast::ref() and
213213
// file name contains 'min' (not as part of a longer word)
214-
getFile().getBaseName().regexpMatch(".*[^-._]*[-._]min([-._].*)?\\.\\w+")
214+
this.getFile().getBaseName().regexpMatch(".*[^-._]*[-._]min([-._].*)?\\.\\w+")
215215
or
216216
exists(int numstmt | numstmt = strictcount(Stmt s | s.getTopLevel() = this) |
217217
// there are more than two statements per line on average
218-
numstmt.(float) / getNumberOfLines() > 2 and
218+
numstmt.(float) / this.getNumberOfLines() > 2 and
219219
// and there are at least ten statements overall
220220
numstmt >= 10
221221
)
@@ -249,9 +249,9 @@ class TopLevel extends @toplevel, StmtContainer {
249249
/** Gets the number of lines containing comments in this toplevel. */
250250
int getNumberOfLinesOfComments() { numlines(this, _, _, result) }
251251

252-
override predicate isStrict() { getAStmt() instanceof StrictModeDecl }
252+
override predicate isStrict() { this.getAStmt() instanceof StrictModeDecl }
253253

254-
override ControlFlowNode getFirstControlFlowNode() { result = getEntry() }
254+
override ControlFlowNode getFirstControlFlowNode() { result = this.getEntry() }
255255

256256
override string toString() { result = "<toplevel>" }
257257
}
@@ -348,7 +348,7 @@ class JavaScriptURL extends @javascript_url, CodeInAttribute { }
348348
* </pre>
349349
*/
350350
class Externs extends TopLevel {
351-
Externs() { isExterns() }
351+
Externs() { this.isExterns() }
352352
}
353353

354354
/**
@@ -393,7 +393,7 @@ class StmtContainer extends @stmt_container, ASTNode {
393393
StmtContainer getFunctionBoundary() {
394394
if this instanceof Function or this instanceof TopLevel
395395
then result = this
396-
else result = getEnclosingContainer().getFunctionBoundary()
396+
else result = this.getEnclosingContainer().getFunctionBoundary()
397397
}
398398

399399
/** Gets a statement that belongs to this container. */
@@ -427,19 +427,19 @@ class StmtContainer extends @stmt_container, ASTNode {
427427
*
428428
* Empty toplevels do not have a start node.
429429
*/
430-
ConcreteControlFlowNode getStart() { successor(getEntry(), result) }
430+
ConcreteControlFlowNode getStart() { successor(this.getEntry(), result) }
431431

432432
/**
433433
* Gets the entry basic block of this function, that is, the basic block
434434
* containing the entry node of its CFG.
435435
*/
436-
EntryBasicBlock getEntryBB() { result = getEntry() }
436+
EntryBasicBlock getEntryBB() { result = this.getEntry() }
437437

438438
/**
439439
* Gets the start basic block of this function, that is, the basic block
440440
* containing the start node of its CFG.
441441
*/
442-
BasicBlock getStartBB() { result.getANode() = getStart() }
442+
BasicBlock getStartBB() { result.getANode() = this.getStart() }
443443

444444
/** Gets the scope induced by this toplevel or function, if any. */
445445
Scope getScope() { scopenodes(this, result) }
@@ -449,7 +449,7 @@ class StmtContainer extends @stmt_container, ASTNode {
449449
*
450450
* See Annex C of the ECMAScript language specification.
451451
*/
452-
predicate isStrict() { getEnclosingContainer().isStrict() }
452+
predicate isStrict() { this.getEnclosingContainer().isStrict() }
453453
}
454454

455455
/**

0 commit comments

Comments
 (0)