Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve resolution of callees in EtsApplicationGraph #263

Open
wants to merge 1 commit into
base: neo
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,29 @@
override fun callees(node: EtsStmt): Sequence<EtsMethod> {
val expr = node.callExpr ?: return emptySequence()
val callee = expr.method
return cp.classes
val allMethods = cp.classes
.asSequence()
.flatMap { it.methods }
.filter { it.signature == callee }
.flatMap { it.methods + it.ctor }
.toList()

val methodsWithSameName = allMethods.filter {
it.name == callee.name
}
if (methodsWithSameName.size == 1) {
return sequenceOf(methodsWithSameName.first())
}

val methodsWithSameClassName = methodsWithSameName.filter {
it.enclosingClass.name == callee.enclosingClass.name

Check warning on line 61 in jacodb-ets/src/main/kotlin/org/jacodb/ets/graph/EtsApplicationGraph.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-ets/src/main/kotlin/org/jacodb/ets/graph/EtsApplicationGraph.kt#L60-L61

Added lines #L60 - L61 were not covered by tests
}
if (methodsWithSameClassName.size == 1) {
return sequenceOf(methodsWithSameClassName.first())

Check warning on line 64 in jacodb-ets/src/main/kotlin/org/jacodb/ets/graph/EtsApplicationGraph.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-ets/src/main/kotlin/org/jacodb/ets/graph/EtsApplicationGraph.kt#L64

Added line #L64 was not covered by tests
}

// Else, return all methods with the same signature.
return allMethods.asSequence().filter {
it.signature == callee

Check warning on line 69 in jacodb-ets/src/main/kotlin/org/jacodb/ets/graph/EtsApplicationGraph.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-ets/src/main/kotlin/org/jacodb/ets/graph/EtsApplicationGraph.kt#L68-L69

Added lines #L68 - L69 were not covered by tests
}
}

override fun callers(method: EtsMethod): Sequence<EtsStmt> {
Expand Down
Loading