use of jadx.core.codegen.CodeWriter in project jadx by skylot.
the class JavaClass method getCode.
public String getCode() {
CodeWriter code = cls.getCode();
if (code == null) {
decompile();
code = cls.getCode();
if (code == null) {
return "";
}
}
return code.getCodeStr();
}
use of jadx.core.codegen.CodeWriter in project jadx by skylot.
the class ResourcesLoader method loadToCodeWriter.
public static CodeWriter loadToCodeWriter(InputStream is) throws IOException {
CodeWriter cw = new CodeWriter();
ByteArrayOutputStream baos = new ByteArrayOutputStream(READ_BUFFER_SIZE);
copyStream(is, baos);
cw.add(baos.toString("UTF-8"));
return cw;
}
use of jadx.core.codegen.CodeWriter in project jadx by skylot.
the class TestLineNumbers2 method test.
@Test
public void test() {
ClassNode cls = getClassNode(TestCls.class);
CodeWriter codeWriter = cls.getCode();
String code = codeWriter.toString();
Map<Integer, Integer> lineMapping = codeWriter.getLineMapping();
assertEquals("{8=18, 11=22, 12=23, 13=24, 14=28, 16=25, 17=26, 18=28, 21=31, 22=32}", lineMapping.toString());
}
use of jadx.core.codegen.CodeWriter in project jadx by skylot.
the class TestReturnSourceLine method test.
@Test
public void test() {
ClassNode cls = getClassNode(TestCls.class);
CodeWriter codeWriter = cls.getCode();
String code = codeWriter.toString();
String[] lines = code.split(CodeWriter.NL);
MethodNode test1 = cls.searchMethodByName("test1(Z)I");
checkLine(lines, codeWriter, test1, 3, "return 1;");
MethodNode test2 = cls.searchMethodByName("test2(I)I");
checkLine(lines, codeWriter, test2, 3, "return v - 1;");
// TODO:
// MethodNode test3 = cls.searchMethodByName("test3(I)I");
// checkLine(lines, codeWriter, test3, 3, "return v;");
}
use of jadx.core.codegen.CodeWriter in project jadx by skylot.
the class BinaryXMLParser method parse.
public synchronized CodeWriter parse(InputStream inputStream) throws IOException {
is = new ParserStream(inputStream);
if (!isBinaryXml()) {
return ResourcesLoader.loadToCodeWriter(inputStream);
}
writer = new CodeWriter();
writer.add("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
firstElement = true;
decode();
writer.finish();
return writer;
}
Aggregations