Skip to content

Commit 99f03a0

Browse files
committed
JS: Make API graphs take types from models into account
1 parent d166727 commit 99f03a0

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

javascript/ql/lib/semmle/javascript/ApiGraphs.qll

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,9 @@ module API {
533533

534534
/** Gets a node corresponding to an import of module `m`. */
535535
Node moduleImport(string m) {
536-
result = Impl::MkModuleImport(m) or
537-
result = Impl::MkModuleImport(m).(Node).getMember("default")
536+
result = Internal::getAModuleImportRaw(m)
537+
or
538+
result = ModelOutput::getATypeNode(m, "")
538539
}
539540

540541
/** Gets a node corresponding to an export of module `m`. */
@@ -544,6 +545,22 @@ module API {
544545
module Node {
545546
/** Gets a node whose type has the given qualified name. */
546547
Node ofType(string moduleName, string exportedName) {
548+
result = Internal::getANodeOfTypeRaw(moduleName, exportedName)
549+
or
550+
result = ModelOutput::getATypeNode(moduleName, exportedName)
551+
}
552+
}
553+
554+
/** Provides access to API graph nodes without taking into account types from models. */
555+
module Internal {
556+
/** Gets a node corresponding to an import of module `m` without taking into account types from models. */
557+
Node getAModuleImportRaw(string m) {
558+
result = Impl::MkModuleImport(m) or
559+
result = Impl::MkModuleImport(m).(Node).getMember("default")
560+
}
561+
562+
/** Gets a node whose type has the given qualified name, not including types from models. */
563+
Node getANodeOfTypeRaw(string moduleName, string exportedName) {
547564
result = Impl::MkTypeUse(moduleName, exportedName).(Node).getInstance()
548565
}
549566
}

0 commit comments

Comments
 (0)