Go: Move Go package-grouping support into shared lib.

This commit is contained in:
Anders Schack-Mulligen
2025-12-11 10:35:39 +01:00
parent e262438557
commit 5bddc8d289
8 changed files with 104 additions and 138 deletions

View File

@@ -107,86 +107,6 @@ module FlowExtensions = Extensions;
/** Gets the prefix for a group of packages. */
private string groupPrefix() { result = "group:" }
/**
* Gets a package represented by `packageOrGroup`.
*
* If `packageOrGroup` is of the form `group:<groupname>` then `result` is a
* package in the group `<groupname>`, as determined by `packageGrouping`.
* Otherwise, `result` is `packageOrGroup`.
*/
bindingset[packageOrGroup]
private string getPackage(string packageOrGroup) {
not exists(string group | packageOrGroup = groupPrefix() + group) and result = packageOrGroup
or
exists(string group |
FlowExtensions::packageGrouping(group, result) and
packageOrGroup = groupPrefix() + group
)
}
/**
* Holds if a source model exists for the given parameters.
*
* Note that `group:` references are expanded into one or more actual packages
* by this predicate.
*/
predicate sourceModel(
string package, string type, boolean subtypes, string name, string signature, string ext,
string output, string kind, string provenance, QlBuiltins::ExtensionId madId
) {
exists(string packageOrGroup |
package = getPackage(packageOrGroup) and
FlowExtensions::sourceModel(packageOrGroup, type, subtypes, name, signature, ext, output, kind,
provenance, madId)
)
}
/**
* Holds if a sink model exists for the given parameters.
*
* Note that `group:` references are expanded into one or more actual packages
* by this predicate.
*/
predicate sinkModel(
string package, string type, boolean subtypes, string name, string signature, string ext,
string input, string kind, string provenance, QlBuiltins::ExtensionId madId
) {
exists(string packageOrGroup | package = getPackage(packageOrGroup) |
FlowExtensions::sinkModel(packageOrGroup, type, subtypes, name, signature, ext, input, kind,
provenance, madId)
)
}
/**
* Holds if a summary model exists for the given parameters.
*
* Note that `group:` references are expanded into one or more actual packages
* by this predicate.
*/
predicate summaryModel(
string package, string type, boolean subtypes, string name, string signature, string ext,
string input, string output, string kind, string provenance, QlBuiltins::ExtensionId madId
) {
exists(string packageOrGroup | package = getPackage(packageOrGroup) |
FlowExtensions::summaryModel(packageOrGroup, type, subtypes, name, signature, ext, input,
output, kind, provenance, madId)
)
}
/**
* Holds if a neutral model exists for the given parameters.
*
* Note that `group:` references are expanded into one or more actual packages
* by this predicate.
*/
predicate neutralModel(
string package, string type, string name, string signature, string kind, string provenance
) {
exists(string packageOrGroup | package = getPackage(packageOrGroup) |
FlowExtensions::neutralModel(packageOrGroup, type, name, signature, kind, provenance)
)
}
bindingset[p]
private string cleanPackage(string p) {
exists(string noPrefix |

View File

@@ -137,11 +137,9 @@ module SourceSinkInterpretationInput implements
SourceOrSinkElement e, string output, string kind, Public::Provenance provenance, string model
) {
exists(
string package, string type, boolean subtypes, string name, string signature, string ext,
QlBuiltins::ExtensionId madId
string package, string type, boolean subtypes, string name, string signature, string ext
|
sourceModel(package, type, subtypes, name, signature, ext, output, kind, provenance, madId) and
model = "MaD:" + madId.toString() and
sourceModel(package, type, subtypes, name, signature, ext, output, kind, provenance, model) and
e = interpretElement(package, type, subtypes, name, signature, ext)
)
}
@@ -154,11 +152,9 @@ module SourceSinkInterpretationInput implements
SourceOrSinkElement e, string input, string kind, Public::Provenance provenance, string model
) {
exists(
string package, string type, boolean subtypes, string name, string signature, string ext,
QlBuiltins::ExtensionId madId
string package, string type, boolean subtypes, string name, string signature, string ext
|
sinkModel(package, type, subtypes, name, signature, ext, input, kind, provenance, madId) and
model = "MaD:" + madId.toString() and
sinkModel(package, type, subtypes, name, signature, ext, input, kind, provenance, model) and
e = interpretElement(package, type, subtypes, name, signature, ext)
)
}
@@ -504,12 +500,10 @@ module Private {
string model
) {
exists(
string namespace, string type, boolean subtypes, string name, string signature, string ext,
QlBuiltins::ExtensionId madId
string namespace, string type, boolean subtypes, string name, string signature, string ext
|
summaryModel(namespace, type, subtypes, name, signature, ext, input, output, kind,
provenance, madId) and
model = "MaD:" + madId.toString() and
provenance, model) and
c.asFunction() =
interpretElement(namespace, type, subtypes, name, signature, ext).asEntity()
)