Skip to content

Commit 9ac70e3

Browse files
author
Max Schaefer
committed
JavaScript: Clarify the relationship between MkCanonicalName{Def,Use} with an upper-case M and mkCanonicalName{Def,Use} with a lower-case m.
1 parent 0109805 commit 9ac70e3

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,13 +368,25 @@ module API {
368368
} or
369369
MkDef(DataFlow::Node nd) { rhs(_, _, nd) } or
370370
MkUse(DataFlow::Node nd) { use(_, _, nd) } or
371+
/**
372+
* A TypeScript canonical name that is defined somewhere, and that isn't a module root.
373+
* (Module roots are represented by `MkModuleExport` nodes instead.)
374+
*
375+
* For most purposes, you probably want to use the `mkCanonicalNameDef` predicate instead of
376+
* this constructor.
377+
*/
371378
MkCanonicalNameDef(CanonicalName n) {
372-
// module roots are represented by `MkModuleExport` nodes
373379
not n.isRoot() and
374380
isDefined(n)
375381
} or
382+
/**
383+
* A TypeScript canonical name that is used somewhere, and that isn't a module root.
384+
* (Module roots are represented by `MkModuleImport` nodes instead.)
385+
*
386+
* For most purposes, you probably want to use the `mkCanonicalNameUse` predicate instead of
387+
* this constructor.
388+
*/
376389
MkCanonicalNameUse(CanonicalName n) {
377-
// module roots are represented by `MkModuleImport` nodes
378390
not n.isRoot() and
379391
isUsed(n)
380392
}
@@ -421,12 +433,14 @@ module API {
421433
)
422434
}
423435

436+
/** An API-graph node representing definitions of the canonical name `cn`. */
424437
private TApiNode mkCanonicalNameDef(CanonicalName cn) {
425438
if cn.isModuleRoot()
426439
then result = MkModuleExport(cn.getExternalModuleName())
427440
else result = MkCanonicalNameDef(cn)
428441
}
429442

443+
/** An API-graph node representing uses of the canonical name `cn`. */
430444
private TApiNode mkCanonicalNameUse(CanonicalName cn) {
431445
if cn.isModuleRoot()
432446
then result = MkModuleImport(cn.getExternalModuleName())

0 commit comments

Comments
 (0)