mirror of
https://github.com/github/codeql.git
synced 2026-05-01 11:45:14 +02:00
JS: Factor out overridden part of PathExpr.getSearchRoot
This commit is contained in:
@@ -112,7 +112,7 @@ class MainModulePath extends PathExpr, @json_string {
|
||||
|
||||
override string getValue() { result = this.(JSONString).getValue() }
|
||||
|
||||
override Folder getSearchRoot(int priority) {
|
||||
override Folder getAdditionalSearchRoot(int priority) {
|
||||
priority = 0 and
|
||||
result = pkg.getFile().getParentContainer()
|
||||
}
|
||||
|
||||
@@ -194,8 +194,18 @@ abstract class PathExpr extends Locatable {
|
||||
Folder getSearchRoot(int priority) {
|
||||
// We default to the enclosing module's search root, though this may be overridden.
|
||||
getEnclosingModule().searchRoot(this, result, priority)
|
||||
or
|
||||
result = getAdditionalSearchRoot(priority)
|
||||
}
|
||||
|
||||
/**
|
||||
* INTERNAL. Use `getSearchRoot` instead.
|
||||
*
|
||||
* Can be overridden by subclasses of `PathExpr` to provide additional search roots
|
||||
* without overriding `getSearchRoot`.
|
||||
*/
|
||||
Folder getAdditionalSearchRoot(int priority) { none() }
|
||||
|
||||
/** Gets the `i`th component of this path. */
|
||||
string getComponent(int i) { result = getValue().(PathString).getComponent(i) }
|
||||
|
||||
@@ -276,8 +286,8 @@ private class ConcatPath extends PathExpr {
|
||||
)
|
||||
}
|
||||
|
||||
override Folder getSearchRoot(int priority) {
|
||||
result = this.(AddExpr).getAnOperand().(PathExpr).getSearchRoot(priority)
|
||||
override Folder getAdditionalSearchRoot(int priority) {
|
||||
result = this.(AddExpr).getAnOperand().(PathExpr).getAdditionalSearchRoot(priority)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user