@@ -48,7 +48,11 @@ private class Folder_ extends ContainerOrModule, TFolder {
4848
4949 Folder_ ( ) { this = TFolder ( f ) }
5050
51- override ContainerOrModule getEnclosing ( ) { result = TFolder ( f .getParentContainer ( ) ) }
51+ override ContainerOrModule getEnclosing ( ) {
52+ result = TFolder ( f .getParentContainer ( ) ) and
53+ // if this the the root, then we stop.
54+ not exists ( f .getFile ( "qlpack.yml" ) )
55+ }
5256
5357 override string getName ( ) { result = f .getStem ( ) }
5458
@@ -63,6 +67,11 @@ private class Folder_ extends ContainerOrModule, TFolder {
6367 endline = 0 and
6468 endcolumn = 0
6569 }
70+
71+ /**
72+ * Gets the folder that this IPA type represents.
73+ */
74+ Folder getFolder ( ) { result = f }
6675}
6776
6877// TODO: Use `AstNode::getParent` once it is total
@@ -108,6 +117,7 @@ private predicate resolveQualifiedName(Import imp, ContainerOrModule m, int i) {
108117 exists ( Container c , Container parent |
109118 // should ideally look at `qlpack.yml` files
110119 parent = imp .getLocation ( ) .getFile ( ) .getParentContainer + ( ) and
120+ exists ( parent .getFile ( "qlpack.yml" ) ) and
111121 c .getParentContainer ( ) = parent and
112122 q = m .getName ( )
113123 |
@@ -116,7 +126,17 @@ private predicate resolveQualifiedName(Import imp, ContainerOrModule m, int i) {
116126 m = TFolder ( c )
117127 )
118128 or
119- definesModule ( getEnclosingModule ( imp ) .getEnclosing * ( ) , q , m , _)
129+ q = imp .getQualifiedName ( i ) and
130+ exists ( ContainerOrModule container | container = getEnclosingModule ( imp ) .getEnclosing + ( ) |
131+ definesModule ( container , q , m , _) and
132+ (
133+ exists ( container .( Folder_ ) .getFolder ( ) .getFile ( "qlpack.yml" ) ) or
134+ container .( Folder_ ) .getFolder ( ) = imp .getLocation ( ) .getFile ( ) .getParentContainer ( ) or
135+ not container instanceof Folder_
136+ )
137+ )
138+ or
139+ definesModule ( getEnclosingModule ( imp ) , q , m , _)
120140 )
121141 or
122142 exists ( Folder_ mid |
0 commit comments