mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
use qlpack existence to determine the root for imports
This commit is contained in:
committed by
GitHub
parent
4e8157e3cb
commit
6c5e33e3d2
@@ -48,7 +48,11 @@ private class Folder_ extends ContainerOrModule, TFolder {
|
||||
|
||||
Folder_() { this = TFolder(f) }
|
||||
|
||||
override ContainerOrModule getEnclosing() { result = TFolder(f.getParentContainer()) }
|
||||
override ContainerOrModule getEnclosing() {
|
||||
result = TFolder(f.getParentContainer()) and
|
||||
// if this the the root, then we stop.
|
||||
not exists(f.getFile("qlpack.yml"))
|
||||
}
|
||||
|
||||
override string getName() { result = f.getStem() }
|
||||
|
||||
@@ -63,6 +67,11 @@ private class Folder_ extends ContainerOrModule, TFolder {
|
||||
endline = 0 and
|
||||
endcolumn = 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the folder that this IPA type represents.
|
||||
*/
|
||||
Folder getFolder() { result = f }
|
||||
}
|
||||
|
||||
// TODO: Use `AstNode::getParent` once it is total
|
||||
@@ -108,6 +117,7 @@ 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
|
||||
q = m.getName()
|
||||
|
|
||||
@@ -116,7 +126,17 @@ private predicate resolveQualifiedName(Import imp, ContainerOrModule m, int i) {
|
||||
m = TFolder(c)
|
||||
)
|
||||
or
|
||||
definesModule(getEnclosingModule(imp).getEnclosing*(), q, m, _)
|
||||
q = imp.getQualifiedName(i) and
|
||||
exists(ContainerOrModule container | container = getEnclosingModule(imp).getEnclosing+() |
|
||||
definesModule(container, q, m, _) and
|
||||
(
|
||||
exists(container.(Folder_).getFolder().getFile("qlpack.yml")) or
|
||||
container.(Folder_).getFolder() = imp.getLocation().getFile().getParentContainer() or
|
||||
not container instanceof Folder_
|
||||
)
|
||||
)
|
||||
or
|
||||
definesModule(getEnclosingModule(imp), q, m, _)
|
||||
)
|
||||
or
|
||||
exists(Folder_ mid |
|
||||
|
||||
Reference in New Issue
Block a user