Skip to content

Commit 77aff04

Browse files
committed
add a getImportString utility predicate to Import
1 parent d4c8f42 commit 77aff04

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

ql/ql/src/codeql_ql/ast/Ast.qll

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,6 +1129,21 @@ class Import extends TImport, ModuleMember, ModuleRef {
11291129
result = imp.getChild(0).(QL::ImportModuleExpr).getChild().getName(i).getValue()
11301130
}
11311131

1132+
/**
1133+
* Gets the full string specifying the module being imported.
1134+
*/
1135+
string getImportString() {
1136+
exists(string selec |
1137+
not exists(getQualifiedName(_)) and selec = ""
1138+
or
1139+
selec =
1140+
"::" + strictconcat(int i, string q | q = this.getSelectionName(i) | q, "::" order by i)
1141+
|
1142+
result =
1143+
strictconcat(int i, string q | q = this.getQualifiedName(i) | q, "." order by i) + selec
1144+
)
1145+
}
1146+
11321147
final override FileOrModule getResolvedModule() { resolve(this, result) }
11331148
}
11341149

0 commit comments

Comments
 (0)