-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use empty line before field in correct place (#2101)
- Loading branch information
Showing
5 changed files
with
89 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
jadx-core/src/test/java/jadx/tests/integration/rename/TestFieldRenameFormat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package jadx.tests.integration.rename; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import com.google.gson.annotations.SerializedName; | ||
|
||
import jadx.api.data.ICodeRename; | ||
import jadx.api.data.IJavaNodeRef.RefType; | ||
import jadx.api.data.impl.JadxCodeData; | ||
import jadx.api.data.impl.JadxCodeRename; | ||
import jadx.api.data.impl.JadxNodeRef; | ||
import jadx.tests.api.IntegrationTest; | ||
|
||
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; | ||
|
||
public class TestFieldRenameFormat extends IntegrationTest { | ||
|
||
@SuppressWarnings({ "unused", "NonSerializableClassWithSerialVersionUID" }) | ||
public static class TestCls { | ||
private static final long serialVersionUID = -2619335455376089892L; | ||
@SerializedName("id") | ||
private int b; | ||
@SerializedName("title") | ||
private String c; | ||
@SerializedName("images") | ||
private List<String> d; | ||
@SerializedName("authors") | ||
private List<String> e; | ||
@SerializedName("description") | ||
private String f; | ||
} | ||
|
||
@Test | ||
public void test() { | ||
noDebugInfo(); | ||
|
||
String baseClsId = TestCls.class.getName(); | ||
List<ICodeRename> renames = Arrays.asList( | ||
fieldRename(baseClsId, "b:I", "id"), | ||
fieldRename(baseClsId, "c:Ljava/lang/String;", "title"), | ||
fieldRename(baseClsId, "e:Ljava/util/List;", "authors")); | ||
|
||
JadxCodeData codeData = new JadxCodeData(); | ||
codeData.setRenames(renames); | ||
getArgs().setCodeData(codeData); | ||
getArgs().setDeobfuscationOn(false); | ||
|
||
assertThat(getClassNode(TestCls.class)) | ||
.code() | ||
.containsOne("private int id;") | ||
.containsOne("private List<String> authors;") | ||
.containsLines(1, | ||
"", | ||
"/* renamed from: c */", | ||
"@SerializedName(\"title\")", | ||
"private String title;", | ||
""); | ||
} | ||
|
||
private static JadxCodeRename fieldRename(String baseClsId, String shortId, String id) { | ||
return new JadxCodeRename(new JadxNodeRef(RefType.FIELD, baseClsId, shortId), id); | ||
} | ||
} |