@@ -174,17 +174,6 @@ abstract class PathString extends string {
174174 Path resolve ( Folder root ) { result = resolveUpTo ( getNumComponent ( ) , root ) }
175175}
176176
177- /**
178- * Non-abstract base class for path expressions.
179- */
180- private class PathExprBase extends Locatable {
181- // We must put getEnclosingModule here for it to be usable in the characteristic predicate of PathExprInModule
182- /** Gets the module containing this path expression, if any. */
183- Module getEnclosingModule ( ) {
184- result = this .( Expr ) .getTopLevel ( ) or result = this .( Comment ) .getTopLevel ( )
185- }
186- }
187-
188177/**
189178 * An expression whose value represents a (relative or absolute) file system path.
190179 *
@@ -197,12 +186,15 @@ private class PathExprBase extends Locatable {
197186 * as their highest-priority root, with default library paths as additional roots
198187 * of lower priority.
199188 */
200- abstract class PathExpr extends PathExprBase {
189+ abstract class PathExpr extends Locatable {
201190 /** Gets the (unresolved) path represented by this expression. */
202191 abstract string getValue ( ) ;
203192
204193 /** Gets the root folder of priority `priority` associated with this path expression. */
205- abstract Folder getSearchRoot ( int priority ) ;
194+ Folder getSearchRoot ( int priority ) {
195+ // We default to the enclosing module's search root, though this may be overridden.
196+ getEnclosingModule ( ) .searchRoot ( this , result , priority )
197+ }
206198
207199 /** Gets the `i`th component of this path. */
208200 string getComponent ( int i ) { result = getValue ( ) .( PathString ) .getComponent ( i ) }
@@ -246,6 +238,11 @@ abstract class PathExpr extends PathExprBase {
246238
247239 /** Gets the file or folder that this path refers to. */
248240 Container resolve ( ) { result = resolveUpTo ( getNumComponent ( ) ) }
241+
242+ /** Gets the module containing this path expression, if any. */
243+ Module getEnclosingModule ( ) {
244+ result = this .( Expr ) .getTopLevel ( ) or result = this .( Comment ) .getTopLevel ( )
245+ }
249246}
250247
251248/** A path string derived from a path expression. */
0 commit comments