[java-decompiler] IDEA-367141 Support encoding for unicode characters at high and medium level

GitOrigin-RevId: 66fb6d059af434c0b4630638cd8cd500bc8939ff
This commit is contained in:
Mikhail Pyltsin
2025-02-07 12:16:35 +01:00
committed by intellij-monorepo-bot
parent 9b9ed3498f
commit 5295a5f150
3 changed files with 12 additions and 2 deletions

View File

@@ -49,7 +49,7 @@ private val highPreset: Map<String, String> = basePreset + mapOf(
IFernflowerPreferences.DECOMPILE_ENUM to "1",
IFernflowerPreferences.REMOVE_GET_CLASS_NEW to "1",
IFernflowerPreferences.LITERALS_AS_IS to "0",
IFernflowerPreferences.ASCII_STRING_CHARACTERS to "1",
IFernflowerPreferences.ASCII_STRING_CHARACTERS to "0",
IFernflowerPreferences.BOOLEAN_TRUE_ONE to "1",
IFernflowerPreferences.UNDEFINED_PARAM_TYPE_OBJECT to "1",
IFernflowerPreferences.USE_DEBUG_VAR_NAMES to "1",
@@ -77,7 +77,7 @@ private val mediumPreset: Map<String, String> = basePreset + mapOf(
IFernflowerPreferences.DECOMPILE_ENUM to "1",
IFernflowerPreferences.REMOVE_GET_CLASS_NEW to "1",
IFernflowerPreferences.LITERALS_AS_IS to "0",
IFernflowerPreferences.ASCII_STRING_CHARACTERS to "1",
IFernflowerPreferences.ASCII_STRING_CHARACTERS to "0",
IFernflowerPreferences.BOOLEAN_TRUE_ONE to "1",
IFernflowerPreferences.UNDEFINED_PARAM_TYPE_OBJECT to "1",
IFernflowerPreferences.USE_DEBUG_VAR_NAMES to "1",

View File

@@ -153,6 +153,16 @@ class IdeaDecompilerTest : LightJavaCodeInsightFixtureTestCase() {
doTestNavigation(17, 28, 16, 13) // to "int r"
}
fun testUnicode_high() {
val state = IdeaDecompilerSettings.State.fromPreset(DecompilerPreset.HIGH)
IdeaDecompilerSettings.getInstance().loadState(state)
val file = getTestFile("UnicodeTest.class")
val decompiled = IdeaDecompiler().getText(file).toString()
assertTrue(decompiled, decompiled.contains("你好"))
assertFalse(decompiled, decompiled.contains("\\u4f60"))
}
private fun doTestNavigation(line: Int, column: Int, expectedLine: Int, expectedColumn: Int) {
val target = GotoDeclarationAction.findTargetElement(project, myFixture.editor, offset(line, column)) as Navigatable
target.navigate(true)