for unit in self.mainProject.findUnits(IJavaSourceUnit): c = unit.getClassElement() if c.getName() != "La/a/a/b;": continue for m in c.getMethods(): self.decryptMethodStrings(m) self.displayTree(m) unit.notifyGenericChange()
def decryptMethodStrings(self, javaMethod): block = javaMethod.getBody() i = 0 while i < block.size(): stm = block.get(i) self.checkElement(block, stm) i += 1
def checkElement(self, parent, e): if isinstance(e, IJavaCall): r = parent.replaceSubElement(e, self.nullcall) print("replace", e, r) for subelt in e.getSubElements(): self.checkElement(e, subelt) def dealElem(self, m, e): if e.getElementType() == JavaElementType.Call: r = m.replaceSubElement(e, self.cstbuilder.createBlock()) # r = e.replaceSubElement(e, self.cstbuilder.createBlock()) print(e, r) return for item in e.getSubElements(): self.dealElem(m, item)