resolve imports across qlpacks

This commit is contained in:
Erik Krogh Kristensen
2021-10-13 16:20:07 +02:00
parent 06f2345bbb
commit 1a1770fc06
2 changed files with 12 additions and 3 deletions

View File

@@ -2143,7 +2143,7 @@ module YAML {
exists(YAMLEntry entry |
entry.isRoot() and
entry.getKey().getQualifiedName() = name and
result = entry.getValue().getValue() and
result = entry.getValue().getValue().trim() and
entry.getLocation().getFile() = file
)
}
@@ -2190,6 +2190,13 @@ module YAML {
)
}
/**
* Gets a QLPack that this QLPack depends on.
*/
QLPack getADependency() {
exists(string name | hasDependency(name, _) | result.getName().replaceAll("-", "/") = name)
}
Location getLocation() {
// hacky, just pick the first node in the file.
result =

View File

@@ -100,8 +100,10 @@ private predicate resolveQualifiedName(Import imp, ContainerOrModule m, int i) {
exists(Container c, Container parent |
// should ideally look at `qlpack.yml` files
parent = imp.getLocation().getFile().getParentContainer+() and
exists(parent.getFile("qlpack.yml")) and
c.getParentContainer() = parent and
exists(YAML::QLPack pack |
pack.getFile().getParentContainer() = parent and
c.getParentContainer() = pack.getADependency*().getFile().getParentContainer()
) and
q = m.getName()
|
m = TFile(c)