Dependencies: Make getAnImport() more precise

In particular, ensure that the go file importing the dependency is under
the directory of the file where the dependency is declared.

Co-authored-by: Max Schaefer <max-schaefer@github.com>
This commit is contained in:
Sauyon Lee
2020-03-05 02:52:13 -08:00
parent b27e63ba83
commit 78239accd5

View File

@@ -26,7 +26,12 @@ abstract class Dependency extends Locatable {
/**
* An import of this dependency.
*/
ImportSpec getAnImport() { result.getPath() = this.getDepPath() }
ImportSpec getAnImport() {
result.getPath() = this.getDepPath() and
exists(Folder parent | parent.getAFile() = this.getFile() |
parent.getAFolder*().getAFile() = result.getFile()
)
}
}
/**