Ruby: Add TAnyKeywordArgumentPosition and TAnyKeywordParameterPosition

This commit is contained in:
Rasmus Wriedt Larsen
2022-05-23 14:03:45 +02:00
parent 5d6fbcec64
commit 3afa9425ef
3 changed files with 26 additions and 4 deletions

View File

@@ -790,6 +790,9 @@ module API {
result = Label::blockParameter()
// NOTE: `self` should NOT be included, as described in the QLDoc for `isAny()`
)
or
pos.isAnyNamed() and
result = Label::keywordParameter(_)
// TODO: needs handling of `self` ArgumentPosition
// or
// pos.isSelf() and
@@ -820,6 +823,9 @@ module API {
result = Label::blockParameter()
// NOTE: `self` should NOT be included, as described in the QLDoc for `isAny()`
)
or
pos.isAnyNamed() and
result = Label::keywordParameter(_)
// TODO: needs handling of `self` ParameterPosition
// or
// pos.isSelf() and

View File

@@ -260,7 +260,8 @@ private module Cached {
or
FlowSummaryImplSpecific::ParsePositions::isParsedKeywordParameterPosition(_, name)
} or
TAnyArgumentPosition()
TAnyArgumentPosition() or
TAnyKeywordArgumentPosition()
cached
newtype TParameterPosition =
@@ -279,7 +280,8 @@ private module Cached {
or
FlowSummaryImplSpecific::ParsePositions::isParsedKeywordArgumentPosition(_, name)
} or
TAnyParameterPosition()
TAnyParameterPosition() or
TAnyKeywordParameterPosition()
}
import Cached
@@ -483,6 +485,9 @@ class ParameterPosition extends TParameterPosition {
*/
predicate isAny() { this = TAnyParameterPosition() }
/** Holds if this position represents any positional parameter. */
predicate isAnyNamed() { this = TAnyKeywordParameterPosition() }
/** Gets a textual representation of this position. */
string toString() {
this.isSelf() and result = "self"
@@ -496,6 +501,8 @@ class ParameterPosition extends TParameterPosition {
exists(string name | this.isKeyword(name) and result = "keyword " + name)
or
this.isAny() and result = "any"
or
this.isAnyNamed() and result = "any-named"
}
}
@@ -519,6 +526,9 @@ class ArgumentPosition extends TArgumentPosition {
*/
predicate isAny() { this = TAnyArgumentPosition() }
/** Holds if this position represents any positional parameter. */
predicate isAnyNamed() { this = TAnyKeywordArgumentPosition() }
/** Gets a textual representation of this position. */
string toString() {
this.isSelf() and result = "self"
@@ -530,6 +540,8 @@ class ArgumentPosition extends TArgumentPosition {
exists(string name | this.isKeyword(name) and result = "keyword " + name)
or
this.isAny() and result = "any"
or
this.isAnyNamed() and result = "any-named"
}
}
@@ -551,4 +563,8 @@ predicate parameterMatch(ParameterPosition ppos, ArgumentPosition apos) {
ppos.isAny() and not apos.isSelf()
or
apos.isAny() and not ppos.isSelf()
or
ppos.isAnyNamed() and apos.isKeyword(_)
or
apos.isAnyNamed() and ppos.isKeyword(_)
}

View File

@@ -262,7 +262,7 @@ ArgumentPosition parseParamBody(string s) {
result.isAny()
or
s = "any-named" and
result.isKeyword(_)
result.isAnyNamed()
}
/** Gets the parameter position obtained by parsing `X` in `Argument[X]`. */
@@ -292,5 +292,5 @@ ParameterPosition parseArgBody(string s) {
result.isAny()
or
s = "any-named" and
result.isKeyword(_)
result.isAnyNamed()
}