Search in sources :

Example 11 with ICodeComment

use of jadx.api.data.ICodeComment in project jadx by skylot.

the class TestCodeComments2 method test.

@Test
public void test() {
    printOffsets();
    String baseClsId = TestCls.class.getName();
    JadxNodeRef mthRef = new JadxNodeRef(RefType.METHOD, baseClsId, "test(Z)I");
    IJavaCodeRef insnRef = JadxCodeRef.forInsn(isJavaInput() ? 13 : 10);
    ICodeComment insnComment = new JadxCodeComment(mthRef, insnRef, "return comment");
    IJavaCodeRef insnRef2 = JadxCodeRef.forInsn(isJavaInput() ? 15 : 11);
    ICodeComment insnComment2 = new JadxCodeComment(mthRef, insnRef2, "another return comment");
    JadxCodeData codeData = new JadxCodeData();
    codeData.setComments(Arrays.asList(insnComment, insnComment2));
    getArgs().setCodeData(codeData);
    assertThat(getClassNode(TestCls.class)).decompile().checkCodeOffsets().code().containsOne("return 1; // " + insnComment.getComment()).containsOne("return 3; // " + insnComment2.getComment());
}
Also used : ICodeComment(jadx.api.data.ICodeComment) JadxCodeComment(jadx.api.data.impl.JadxCodeComment) IJavaCodeRef(jadx.api.data.IJavaCodeRef) JadxNodeRef(jadx.api.data.impl.JadxNodeRef) JadxCodeData(jadx.api.data.impl.JadxCodeData) Test(org.junit.jupiter.api.Test) IntegrationTest(jadx.tests.api.IntegrationTest)

Aggregations

ICodeComment (jadx.api.data.ICodeComment)11 JadxCodeData (jadx.api.data.impl.JadxCodeData)7 JadxCodeComment (jadx.api.data.impl.JadxCodeComment)6 JadxNodeRef (jadx.api.data.impl.JadxNodeRef)5 IntegrationTest (jadx.tests.api.IntegrationTest)5 Test (org.junit.jupiter.api.Test)5 IJavaCodeRef (jadx.api.data.IJavaCodeRef)4 ClassNode (jadx.core.dex.nodes.ClassNode)2 JadxProject (jadx.gui.settings.JadxProject)2 JNode (jadx.gui.treemodel.JNode)1 Dialog (java.awt.Dialog)1 ArrayList (java.util.ArrayList)1 JDialog (javax.swing.JDialog)1