Search in sources :

Example 6 with JadxNodeRef

use of jadx.api.data.impl.JadxNodeRef in project jadx by skylot.

the class TestCodeComments2a 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() ? 22 : 18);
    ICodeComment insnComment = new JadxCodeComment(mthRef, insnRef, "return comment");
    IJavaCodeRef insnRef2 = JadxCodeRef.forInsn(isJavaInput() ? 27 : 19);
    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("// " + insnComment.getComment()).containsOne("// " + 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)

Example 7 with JadxNodeRef

use of jadx.api.data.impl.JadxNodeRef 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

JadxNodeRef (jadx.api.data.impl.JadxNodeRef)7 JadxCodeComment (jadx.api.data.impl.JadxCodeComment)6 JadxCodeData (jadx.api.data.impl.JadxCodeData)6 IntegrationTest (jadx.tests.api.IntegrationTest)6 Test (org.junit.jupiter.api.Test)6 ICodeComment (jadx.api.data.ICodeComment)5 IJavaCodeRef (jadx.api.data.IJavaCodeRef)5 ClassNode (jadx.core.dex.nodes.ClassNode)3 CodePosition (jadx.api.CodePosition)1 JavaMethod (jadx.api.JavaMethod)1 JavaNode (jadx.api.JavaNode)1 ICodeRename (jadx.api.data.ICodeRename)1 InsnCodeOffset (jadx.api.data.annotations.InsnCodeOffset)1 JadxCodeRef (jadx.api.data.impl.JadxCodeRef)1 JadxCodeRename (jadx.api.data.impl.JadxCodeRename)1 CodeLinesInfo (jadx.gui.utils.CodeLinesInfo)1 ArrayList (java.util.ArrayList)1 Nullable (org.jetbrains.annotations.Nullable)1