Skip to content

Commit f1dc362

Browse files
committed
update tests and queries that used getId()
1 parent 0867c55 commit f1dc362

File tree

9 files changed

+21
-14
lines changed

9 files changed

+21
-14
lines changed

javascript/ql/src/Declarations/ConflictingFunctions.ql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ where
2424
// ignore ambient, abstract, and overloaded declarations in TypeScript
2525
f.hasBody() and
2626
g.hasBody()
27-
select f.getId(), "Declaration of " + f.describe() + " conflicts with $@ in the same scope.",
28-
g.getId(), "another declaration"
27+
select f.getIdentifier(),
28+
"Declaration of " + f.describe() + " conflicts with $@ in the same scope.", g.getIdentifier(),
29+
"another declaration"

javascript/ql/src/Declarations/DeadStoreOfLocal.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ where
4242
access.isAmbient()
4343
) and
4444
// don't flag function expressions
45-
not exists(FunctionExpr fe | dead = fe.getId()) and
45+
not exists(FunctionExpr fe | dead = fe.getIdentifier()) and
4646
// don't flag function declarations nested inside blocks or other compound statements;
4747
// their meaning is only partially specified by the standard
4848
not exists(FunctionDeclStmt fd, StmtContainer outer |
49-
dead = fd.getId() and outer = fd.getEnclosingContainer()
49+
dead = fd.getIdentifier() and outer = fd.getEnclosingContainer()
5050
|
5151
not fd = outer.getBody().(BlockStmt).getAStmt()
5252
) and

javascript/ql/src/Declarations/RedeclaredVariable.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ where
2222
not decl.isAmbient() and
2323
not redecl.isAmbient() and
2424
// Redeclaring a namespace extends the previous definition.
25-
not decl = any(NamespaceDeclaration ns).getId() and
26-
not redecl = any(NamespaceDeclaration ns).getId()
25+
not decl = any(NamespaceDeclaration ns).getIdentifier() and
26+
not redecl = any(NamespaceDeclaration ns).getIdentifier()
2727
select redecl, "This variable has already been declared $@.", decl, "here"

javascript/ql/src/Declarations/UnusedVariable.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ predicate isEnumMember(VarDecl decl) { decl = any(EnumMember member).getIdentifi
9393
* "function f", "variable v" or "class c".
9494
*/
9595
string describeVarDecl(VarDecl vd) {
96-
if vd = any(Function f).getId()
96+
if vd = any(Function f).getIdentifier()
9797
then result = "function " + vd.getName()
9898
else
9999
if vd = any(ClassDefinition c).getIdentifier()
@@ -115,7 +115,7 @@ class ImportVarDeclProvider extends Stmt {
115115
*/
116116
VarDecl getAVarDecl() {
117117
result = this.(ImportDeclaration).getASpecifier().getLocal() or
118-
result = this.(ImportEqualsDeclaration).getId()
118+
result = this.(ImportEqualsDeclaration).getIdentifier()
119119
}
120120

121121
/**

javascript/ql/src/Expressions/SuspiciousPropAccess.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ private import semmle.javascript.dataflow.InferredTypes
2323
* if it is part of a const enum access, so we conservatively silence the alert in that case.
2424
*/
2525
predicate namespaceOrConstEnumAccess(VarAccess e) {
26-
exists(NamespaceDeclaration decl | e.getVariable().getADeclaration() = decl.getId())
26+
exists(NamespaceDeclaration decl | e.getVariable().getADeclaration() = decl.getIdentifier())
2727
or
2828
exists(EnumDeclaration decl | e.getVariable().getADeclaration() = decl.getIdentifier() |
2929
decl.isConst()

javascript/ql/src/semmle/javascript/DefUse.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ private predicate defn(ControlFlowNode def, Expr lhs, AST::ValueNode rhs) {
3838
or
3939
exists(EnumDeclaration ed | def = ed.getIdentifier() | lhs = def and rhs = ed)
4040
or
41-
exists(ImportEqualsDeclaration i | def = i | lhs = i.getIdentifier() and rhs = i.getImportedEntity())
41+
exists(ImportEqualsDeclaration i | def = i |
42+
lhs = i.getIdentifier() and rhs = i.getImportedEntity()
43+
)
4244
or
4345
exists(ImportSpecifier i | def = i | lhs = i.getLocal() and rhs = i)
4446
or

javascript/ql/src/semmle/javascript/Variables.qll

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,10 @@ class LocalVariable extends Variable {
313313
or
314314
exists(VarDecl d | d = getADeclaration() |
315315
if d = any(FunctionDeclStmt fds).getIdentifier()
316-
then exists(FunctionDeclStmt fds | d = fds.getIdentifier() | result = fds.getEnclosingContainer())
316+
then
317+
exists(FunctionDeclStmt fds | d = fds.getIdentifier() |
318+
result = fds.getEnclosingContainer()
319+
)
317320
else result = d.getContainer()
318321
)
319322
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import javascript
22

33
query predicate test_getId(Function f, VarDecl res0, string res1) {
4-
res0 = f.getId() and res1 = f.getName()
4+
res0 = f.getIdentifier() and res1 = f.getName()
55
}

javascript/ql/test/library-tests/TypeScript/Namespaces/CheckBindings.ql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class ResolveCall extends CallExpr {
1010
string getDeclaredValue() {
1111
result = getVariable().getAnAssignedExpr().getStringValue()
1212
or
13-
exists(NamespaceDeclaration decl | decl.getId() = getVariable().getADeclaration() |
13+
exists(NamespaceDeclaration decl | decl.getIdentifier() = getVariable().getADeclaration() |
1414
result = getNamespaceName(decl)
1515
)
1616
}
@@ -21,7 +21,8 @@ string getNamespaceName(NamespaceDeclaration decl) {
2121
or
2222
not decl.getStmt(0).(ExprStmt).getExpr() instanceof ConstantString and
2323
result =
24-
"Namespace " + decl.getId() + " on line " + decl.getFirstToken().getLocation().getStartLine()
24+
"Namespace " + decl.getIdentifier() + " on line " +
25+
decl.getFirstToken().getLocation().getStartLine()
2526
}
2627

2728
from ResolveCall resolve

0 commit comments

Comments
 (0)