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

[Feature]: Method calls sorted by sequence #1086

Open
chanmaoganda opened this issue Sep 26, 2024 · 1 comment
Open

[Feature]: Method calls sorted by sequence #1086

chanmaoganda opened this issue Sep 26, 2024 · 1 comment
Labels
good first issue Good for newcomers improvement improve in readability, structure or performance

Comments

@chanmaoganda
Copy link

Missing Feature

callFrom(methodSignature) returns a no-sorted set, consider making a sorted list by the call sequence?

I'm currently doing a research of type-bug

Suppose i have a program below

public class A {
    private int m() { System.out.println("A.m"); return 0; }
    public static void main(String... args) { type_bug.refined.B b = new type_bug.refined.C(); b.m(); }
}

abstract class B extends A implements I {
}

class C extends B {
    public void m() { System.out.println("C.m"); }
}

interface I {
    public void m();
}

i use the following code to get the Methods called in A.main()

final ViewTypeHierarchy typeHierarchy = new ViewTypeHierarchy(view);
CallGraphAlgorithm cha = new ClassHierarchyAnalysisAlgorithm(view);
// Create CG by initializing CHA with entry method(s)CallGraph cg = cha.initialize(Collections.singletonList(methodSignature));
cg.callsFrom(methodSignature).forEach(System.out::println);

i got the following output:
<type_bug.refined.C: void m()>
<type_bug.refined.C: void ()>
<type_bug.refined.I: void m()>

while the correct sequence should be like:
<type_bug.refined.C: void ()>
<type_bug.refined.C: void m()>
<type_bug.refined.I: void m()>

i wonder if there is a way to sort the method call correctly😊

@chanmaoganda chanmaoganda added the improvement improve in readability, structure or performance label Sep 26, 2024
@JonasKlauke
Copy link
Collaborator

JonasKlauke commented Sep 26, 2024

The new Version will save Statemens for each call. You could sort the the calls by this statements with the statementlist of the method body.
I get your usecase. This is a good API extension. Similar to a method that gives you targets of a specific statement in a method

@JonasKlauke JonasKlauke added the good first issue Good for newcomers label Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers improvement improve in readability, structure or performance
Projects
None yet
Development

No branches or pull requests

2 participants