Ruby: Fix performance of Filter.getAnAction

Only look at the current class and the immediate superclass.
This will miss some edge cases but is much faster.
This commit is contained in:
Harry Maclean
2023-02-19 12:55:39 +13:00
parent 2bc7d4e1ee
commit 710ddb1f96

View File

@@ -65,13 +65,14 @@ module Filters {
not exists(this.getOnlyArgument()) and
forall(string except | except = this.getExceptArgument() | result.getName() != except)
) and
// This is a simple heuristic and will miss some cases.
(
result = this.getExpr().getEnclosingModule().getAMethod()
// The action is in the same class as this call
result = lookupMethod(this.getExpr().getEnclosingModule().getModule(), _)
or
exists(ModuleBase m |
m.getModule() = this.getExpr().getEnclosingModule().getModule().getADescendent() and
result = m.getAMethod()
)
// or the action is in an immediate subclass of this call
result.getEnclosingModule().getModule().getAnImmediateAncestor() =
this.getExpr().getEnclosingModule().getModule()
)
}