MCPcopy Index your code
hub / github.com/CrackerCat/JSPHorse / changeRef

Method changeRef

src/main/java/org/sec/module/StringModule.java:27–46  ·  view source on GitHub ↗
(MethodDeclaration method, int offset)

Source from the content-addressed store, hash-verified

25 }
26
27 public static void changeRef(MethodDeclaration method, int offset) {
28 List<ArrayAccessExpr> arrayExpr = method.findAll(ArrayAccessExpr.class);
29 for (ArrayAccessExpr expr : arrayExpr) {
30 if (expr.getName().asNameExpr().getNameAsString().equals("globalArr")) {
31 MethodCallExpr methodCallExpr = new MethodCallExpr();
32 methodCallExpr.setName("dec");
33 methodCallExpr.setScope(null);
34 NodeList<Expression> nodeList = new NodeList<>();
35 ArrayAccessExpr a = new ArrayAccessExpr();
36 a.setName(expr.getName());
37 a.setIndex(expr.getIndex());
38 nodeList.add(a);
39 IntegerLiteralExpr intValue = new IntegerLiteralExpr();
40 intValue.setValue(String.valueOf(offset));
41 nodeList.add(intValue);
42 methodCallExpr.setArguments(nodeList);
43 expr.replace(methodCallExpr);
44 }
45 }
46 }
47}

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected