Address review comments.

Co-authored-by: Max Schaefer <max-schaefer@github.com>
This commit is contained in:
Sauyon Lee
2020-03-06 03:35:11 -08:00
parent 34f34e2241
commit 38596dddc0
2 changed files with 18 additions and 4 deletions

View File

@@ -22,14 +22,18 @@ abstract class Dependency extends Locatable {
/** Gets the version of this dependency. */
string getDepVersion() { this.info(_, result) }
/**
* This dependency is relevant for imports in file `file`. That is, an import of this
* dependency's path that is in `file` will use this dependency.
*/
abstract predicate relevantForFile(File file);
/**
* An import of this dependency.
*/
ImportSpec getAnImport() {
result.getPath() = this.getDepPath() and
exists(Folder parent | parent.getAFile() = this.getFile() |
parent.getAFolder*().getAFile() = result.getFile()
)
this.relevantForFile(result.getFile())
}
}
@@ -44,8 +48,14 @@ class GoModDependency extends Dependency, GoModRequireLine {
this.originalInfo(path, v)
}
override predicate relevantForFile(File file) {
exists(Folder parent | parent.getAFile() = this.getFile() |
parent.getAFolder*().getAFile() = file
)
}
/**
* Holds if there is a replace line that replaces this dependency with a dependency to `path`,
* Holds if there is a replace line that replaces this dependency with a dependency on `path`,
* version `v`.
*/
predicate replacementInfo(string path, string v) {

View File

@@ -1,3 +1,7 @@
/**
* Provides classes for dealing with semantic versions, for strings that dependency's versions.
*/
import semmle.go.dependencies.Dependencies
/**