Multiple sequences clubbed together
aashsach opened this issue · comments
For mining APIs from java files,
If java file contain a overloaded method, it returns a concatenated sequence extracted from both the methods.
I think it is because you use function name as the key.
It should not be like that..
Hmm... it should definitely not be like that. Can you provide an example java file that exhibits this behaviour? I can then figure out why this is happening.
package org.androidaalto.antifrog;
import org.andengine.entity.sprite.Sprite;
public class Frog {
public Sprite sprite;
public Frog() {
sprite = new Sprite(AntiFrogActivity.displayWidth-330, AntiFrogActivity.displayHeight/2-90,
AntiFrogActivity.getSharedInstance().mFrogger, AntiFrogActivity.getSharedInstance().getVertexBufferObjectManager());
init();
}
public void init() {
}
public void clean() {
sprite.m1();
sprite.m1();
}
public void clean(int i) {
sprite.m2();
sprite.m2();
}
public boolean gotHit() {
return false;
}
}
@relation andengine
@attribute fqCaller string
@attribute fqCalls string
@data
'org.androidaalto.antifrog.Frog.Frog','org.andengine.entity.sprite.Sprite.<init>'
'org.androidaalto.antifrog.Frog.clean','org.andengine.entity.sprite.Sprite.m1 org.andengine.entity.sprite.Sprite.m1 org.andengine.entity.sprite.Sprite.m2 org.andengine.entity.sprite.Sprite.m2'
I just modified one of the "andengine" java file. You can see the concatenated output of both methods.
Many thanks. You're absolutely right, this happens because I use the fully qualified name of a method as the key in the multimap and this is the same for overloaded methods.
I'm not sure what the best way of fixing this is, perhaps if I append a counter to each duplicate method name? So in the above example, the second clean method would become clean_2?
Yes you're right @casutton, let's do that. I'll submit a fix later on this week when I have more time to work on this.
Ok I have fixed this. Method names now include fully qualified types in parentheses as is standard. For example:
package org.androidaalto.antifrog;
import org.andengine.entity.sprite.Sprite;
public class Frog {
public Sprite sprite;
public Frog() {
sprite = new Sprite(AntiFrogActivity.displayWidth-330, AntiFrogActivity.displayHeight/2-90,
AntiFrogActivity.getSharedInstance().mFrogger, AntiFrogActivity.getSharedInstance().getVertexBufferObjectManager());
init();
}
public void init() {
}
public void clean(int i) {
sprite.m1();
sprite.m1();
}
public void clean(int i, String s) {
sprite.m2();
sprite.m2();
}
public boolean gotHit() {
return false;
}
}
which now outputs the following:
@relation andengine
@attribute fqCaller string
@attribute fqCalls string
@data
'org.androidaalto.antifrog.Frog.Frog()','org.andengine.entity.sprite.Sprite.<init>'
'org.androidaalto.antifrog.Frog.clean(int)','org.andengine.entity.sprite.Sprite.m1 org.andengine.entity.sprite.Sprite.m1'
'org.androidaalto.antifrog.Frog.clean(int,java.lang.String)','org.andengine.entity.sprite.Sprite.m2 org.andengine.entity.sprite.Sprite.m2'
as expected.