1919 * reading.
2020 * 1. The `package` column selects a package. Note that if the package does not
2121 * contain a major version suffix (like "/v2") then we will match all major
22- * versions. This can be disabled by putting `$THISVERSION ` at the end of
23- * the package path.
22+ * versions. This can be disabled by putting `fixed-version: ` at the start
23+ * of the package path.
2424 * 2. The `type` column selects a type within that package.
2525 * 3. The `subtypes` is a boolean that indicates whether to jump to an
2626 * arbitrary subtype of that type.
@@ -266,7 +266,7 @@ module ModelValidation {
266266 ext = "" and
267267 pred = "neutral"
268268 |
269- not package .replaceAll ( "$ANYVERSION" , "" ) .regexpMatch ( "[a-zA-Z0-9_\\./-]*" ) and
269+ not package .replaceAll ( fixedVersionPrefix ( ) , "" ) .regexpMatch ( "[a-zA-Z0-9_\\./-]*" ) and
270270 result = "Dubious package \"" + package + "\" in " + pred + " model."
271271 or
272272 not type .regexpMatch ( "[a-zA-Z0-9_\\$<>]*" ) and
@@ -309,6 +309,8 @@ private predicate elementSpec(
309309 neutralModel ( package , type , name , signature , _, _) and ext = "" and subtypes = false
310310}
311311
312+ private string fixedVersionPrefix ( ) { result = "fixed-version:" }
313+
312314/**
313315 * Gets the string for the package path corresponding to `p`, if one exists.
314316 *
@@ -318,17 +320,14 @@ private predicate elementSpec(
318320 * so if `github.com/a/b/c/d/v2` or `github.com/a/b/v3/c/d` were imported then
319321 * they will be in the results. There are two situations where we do not do
320322 * this: (1) when `p` already contains a major version suffix; (2) if `p` has
321- * `$THISVERSION ` at the end (which we remove).
323+ * `fixed-version: ` at the start (which we remove).
322324 */
323325bindingset [ p]
324326private string interpretPackage ( string p ) {
325- exists ( Package pkg , string thisVersion |
326- result = pkg .getPath ( ) and
327- thisVersion = "$THISVERSION"
328- |
329- p = result + thisVersion
327+ exists ( Package pkg | result = pkg .getPath ( ) |
328+ p = fixedVersionPrefix ( ) + result
330329 or
331- not p = any ( string s ) + thisVersion and
330+ not p = fixedVersionPrefix ( ) + any ( string s ) and
332331 (
333332 if exists ( p .regexpFind ( majorVersionSuffixRegex ( ) , 0 , _) )
334333 then result = p
0 commit comments