From d4c8f42336e44fc83106f28c8a1ba54673a3e1dd Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Mon, 28 Mar 2022 09:54:08 +0200 Subject: [PATCH 1/2] add QLDoc to the child relation for TopLevel --- ql/ql/src/codeql_ql/ast/Ast.qll | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ql/ql/src/codeql_ql/ast/Ast.qll b/ql/ql/src/codeql_ql/ast/Ast.qll index 5d3fdffaea2..a36330000a9 100644 --- a/ql/ql/src/codeql_ql/ast/Ast.qll +++ b/ql/ql/src/codeql_ql/ast/Ast.qll @@ -135,6 +135,8 @@ class TopLevel extends TTopLevel, AstNode { pred = directMember("getAModule") and result = this.getAModule() or pred = directMember("getANewType") and result = this.getANewType() + or + pred = directMember("getQLDoc") and result = this.getQLDoc() } QLDoc getQLDocFor(ModuleMember m) { From 77aff04429d39790ee706d5a624a08bc9eceab4e Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Mon, 28 Mar 2022 10:14:27 +0200 Subject: [PATCH 2/2] add a getImportString utility predicate to Import --- ql/ql/src/codeql_ql/ast/Ast.qll | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ql/ql/src/codeql_ql/ast/Ast.qll b/ql/ql/src/codeql_ql/ast/Ast.qll index a36330000a9..afa10e3db8b 100644 --- a/ql/ql/src/codeql_ql/ast/Ast.qll +++ b/ql/ql/src/codeql_ql/ast/Ast.qll @@ -1129,6 +1129,21 @@ class Import extends TImport, ModuleMember, ModuleRef { result = imp.getChild(0).(QL::ImportModuleExpr).getChild().getName(i).getValue() } + /** + * Gets the full string specifying the module being imported. + */ + string getImportString() { + exists(string selec | + not exists(getQualifiedName(_)) and selec = "" + or + selec = + "::" + strictconcat(int i, string q | q = this.getSelectionName(i) | q, "::" order by i) + | + result = + strictconcat(int i, string q | q = this.getQualifiedName(i) | q, "." order by i) + selec + ) + } + final override FileOrModule getResolvedModule() { resolve(this, result) } }