Skip to content

Commit 8d2ace0

Browse files
committed
Refactor Soot method/signature processing
1 parent 1f2019e commit 8d2ace0

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

swan-pipeline/src/main/java/de/fraunhofer/iem/swan/data/Method.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public Method(Method methodAndClass) {
7575
}
7676

7777
public Method deriveWithNewClass(String className) {
78-
Method m = new Method(this.getName(), this.getParameters(), this.getReturnType(), className);
78+
Method m = new Method(className + "." + this.getName(), this.getParameters(), this.getReturnType());
7979
m.setFramework(this.framework);
8080
m.setLink(this.link);
8181
m.setComment(this.comment);
@@ -189,8 +189,8 @@ public String getName() {
189189
@JsonIgnore
190190
public String getClassName() {
191191

192-
if(name.contains("."))
193-
return name.substring(0, name.lastIndexOf("."));
192+
if (name.contains("."))
193+
return name.substring(0, name.lastIndexOf("."));
194194
else
195195
return name;
196196
}
@@ -208,8 +208,7 @@ public String getSubSignature() {
208208
if (subSignature != null)
209209
return subSignature;
210210

211-
StringBuilder sb = new StringBuilder(
212-
10 + this.returnType.length() + this.name.length() + (this.parameters.size() * 30));
211+
StringBuilder sb = new StringBuilder();
213212
if (!this.returnType.isEmpty()) {
214213
sb.append(this.returnType);
215214
sb.append(" ");
@@ -240,8 +239,7 @@ public String getSignature() {
240239
if (signature != null)
241240
return signature;
242241

243-
StringBuilder sb = new StringBuilder(10 + getClassName().length() + this.returnType.length()
244-
+ this.name.length() + (this.parameters.size() * 30));
242+
StringBuilder sb = new StringBuilder();
245243
sb.append("<");
246244
sb.append(getClassName());
247245
sb.append(": ");

swan-pipeline/src/main/java/de/fraunhofer/iem/swan/util/SootUtils.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
public class SootUtils {
77

8-
public static Method convertSootSignature(String sootSignature){
8+
public static Method convertSootSignature(String sootSignature) {
99

1010
//Ignore < and > at the beginning and end of the signature
11-
String[] parts = sootSignature.substring(1, sootSignature.length()-1).split(":");
11+
String[] parts = sootSignature.substring(1, sootSignature.length() - 1).split(":");
1212

1313
String className = parts[0];
1414
String[] method = parts[1].trim().split(" ");
@@ -20,7 +20,9 @@ public static Method convertSootSignature(String sootSignature){
2020
if (methodName.contains("<init>"))
2121
methodName = getSimpleName(className);
2222

23-
return new Method(methodName, Arrays.asList(paramList), returnType, className);
23+
methodName = className + "." + methodName;
24+
25+
return new Method(methodName, Arrays.asList(paramList), returnType);
2426
}
2527

2628
/**

0 commit comments

Comments
 (0)