Ruby: Refactor getFilterCallable

Try to force a join with the filter argument string first, to reduce
tuple counts.
This commit is contained in:
Harry Maclean
2023-02-04 12:03:19 +13:00
parent 2590682262
commit 889d97163e

View File

@@ -104,6 +104,10 @@ module Filters {
StringlikeLiteralCfgNode getFilterArgument() { result = this.getPositionalArgument(_) }
string getFilterArgumentName() {
result = this.getFilterArgument().getConstantValue().getStringlikeValue()
}
/**
* Gets the callable that implements the filter with name `name`.
* This currently only finds methods in the local class or superclass.
@@ -122,8 +126,8 @@ module Filters {
* end
* ```
*/
Callable getFilterCallable(string name) {
result.(MethodBase).getName() = name and
Callable getAFilterCallable() {
this.getFilterArgumentName() = result.(MethodBase).getName() and
result.getEnclosingModule().getModule() =
this.getExpr().getEnclosingModule().getModule().getAnAncestor()
}
@@ -321,7 +325,9 @@ module Filters {
string getFilterName() { result = this.getConstantValue().getStringlikeValue() }
Callable getFilterCallable() { result = call.getFilterCallable(this.getFilterName()) }
Callable getFilterCallable() {
result = call.getAFilterCallable() and result.(MethodBase).getName() = this.getFilterName()
}
ActionControllerActionMethod getAnAction() { result = call.getAnAction() }
}