Skip to content

Commit ed8e0fb

Browse files
committed
remove CannonicalName API nodes
1 parent 7180a1e commit ed8e0fb

File tree

1 file changed

+2
-72
lines changed

1 file changed

+2
-72
lines changed

javascript/ql/src/semmle/javascript/ApiGraphs.qll

Lines changed: 2 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,6 @@ module API {
313313
module Node {
314314
/** Gets a node whose type has the given qualified name. */
315315
Node ofType(string moduleName, string exportedName) {
316-
exists(TypeName tn |
317-
tn.hasQualifiedName(moduleName, exportedName) and
318-
result = Impl::MkCanonicalNameUse(tn).(Node).getInstance()
319-
)
320-
or
321316
result = Impl::MkHasUnderlyingType(moduleName, exportedName).(Node).getInstance()
322317
}
323318
}
@@ -395,28 +390,6 @@ module API {
395390
} or
396391
MkDef(DataFlow::Node nd) { rhs(_, _, nd) } or
397392
MkUse(DataFlow::Node nd) { use(_, _, nd) } or
398-
/**
399-
* A TypeScript canonical name that is defined somewhere, and that isn't a module root.
400-
* (Module roots are represented by `MkModuleExport` nodes instead.)
401-
*
402-
* For most purposes, you probably want to use the `mkCanonicalNameDef` predicate instead of
403-
* this constructor.
404-
*/
405-
MkCanonicalNameDef(CanonicalName n) {
406-
not n.isRoot() and
407-
isDefined(n)
408-
} or
409-
/**
410-
* A TypeScript canonical name that is used somewhere, and that isn't a module root.
411-
* (Module roots are represented by `MkModuleImport` nodes instead.)
412-
*
413-
* For most purposes, you probably want to use the `mkCanonicalNameUse` predicate instead of
414-
* this constructor.
415-
*/
416-
MkCanonicalNameUse(CanonicalName n) {
417-
not n.isRoot() and
418-
isUsed(n)
419-
} or
420393
/**
421394
* A TypeScript type, identified by name of the type-annotation.
422395
* This API node is exclusively used by `API::Node::ofType`.
@@ -433,11 +406,9 @@ module API {
433406
class TDef = MkModuleDef or TNonModuleDef;
434407

435408
class TNonModuleDef =
436-
MkModuleExport or MkClassInstance or MkAsyncFuncResult or MkDef or MkCanonicalNameDef or
437-
MkSyntheticCallbackArg;
409+
MkModuleExport or MkClassInstance or MkAsyncFuncResult or MkDef or MkSyntheticCallbackArg;
438410

439-
class TUse =
440-
MkModuleUse or MkModuleImport or MkUse or MkCanonicalNameUse or MkHasUnderlyingType;
411+
class TUse = MkModuleUse or MkModuleImport or MkUse or MkHasUnderlyingType;
441412

442413
private predicate hasSemantics(DataFlow::Node nd) { not nd.getTopLevel().isExterns() }
443414

@@ -474,20 +445,6 @@ module API {
474445
)
475446
}
476447

477-
/** An API-graph node representing definitions of the canonical name `cn`. */
478-
private TApiNode mkCanonicalNameDef(CanonicalName cn) {
479-
if cn.isModuleRoot()
480-
then result = MkModuleExport(cn.getExternalModuleName())
481-
else result = MkCanonicalNameDef(cn)
482-
}
483-
484-
/** An API-graph node representing uses of the canonical name `cn`. */
485-
private TApiNode mkCanonicalNameUse(CanonicalName cn) {
486-
if cn.isModuleRoot()
487-
then result = MkModuleImport(cn.getExternalModuleName())
488-
else result = MkCanonicalNameUse(cn)
489-
}
490-
491448
/**
492449
* Holds if `rhs` is the right-hand side of a definition of a node that should have an
493450
* incoming edge from `base` labeled `lbl` in the API graph.
@@ -591,11 +548,6 @@ module API {
591548
exists(string m | nd = MkModuleExport(m) | exports(m, rhs))
592549
or
593550
nd = MkDef(rhs)
594-
or
595-
exists(CanonicalName n | nd = MkCanonicalNameDef(n) |
596-
rhs = n.(Namespace).getADefinition().flow() or
597-
rhs = n.(CanonicalFunctionName).getADefinition().flow()
598-
)
599551
}
600552

601553
/**
@@ -647,12 +599,6 @@ module API {
647599
ref = cls.getConstructor().getParameter(i)
648600
)
649601
or
650-
exists(TypeName tn |
651-
base = MkCanonicalNameUse(tn) and
652-
lbl = Label::instance() and
653-
ref = getANodeWithType(tn)
654-
)
655-
or
656602
exists(string moduleName, string exportName |
657603
base = MkHasUnderlyingType(moduleName, exportName) and
658604
lbl = Label::instance() and
@@ -696,8 +642,6 @@ module API {
696642
)
697643
or
698644
nd = MkUse(ref)
699-
or
700-
exists(CanonicalName n | nd = MkCanonicalNameUse(n) | ref.asExpr() = n.getAnAccess())
701645
}
702646

703647
/** Holds if module `m` exports `rhs`. */
@@ -852,13 +796,6 @@ module API {
852796
result = awaited(call, DataFlow::TypeTracker::end())
853797
}
854798

855-
private DataFlow::SourceNode getANodeWithType(TypeName tn) {
856-
exists(string moduleName, string typeName |
857-
tn.hasQualifiedName(moduleName, typeName) and
858-
result.hasUnderlyingType(moduleName, typeName)
859-
)
860-
}
861-
862799
/**
863800
* Holds if there is an edge from `pred` to `succ` in the API graph that is labeled with `lbl`.
864801
*/
@@ -899,13 +836,6 @@ module API {
899836
succ = MkClassInstance(trackDefNode(def))
900837
)
901838
or
902-
exists(CanonicalName cn1, string n, CanonicalName cn2 |
903-
pred in [mkCanonicalNameDef(cn1), mkCanonicalNameUse(cn1)] and
904-
cn2 = cn1.getChild(n) and
905-
lbl = Label::member(n) and
906-
succ in [mkCanonicalNameDef(cn2), mkCanonicalNameUse(cn2)]
907-
)
908-
or
909839
exists(string moduleName, string exportName |
910840
pred = MkModuleImport(moduleName) and
911841
lbl = Label::member(exportName) and

0 commit comments

Comments
 (0)