feat(script): add methods for apply renames and reload tabs (#2008)

This commit is contained in:
Skylot
2023-09-15 21:50:47 +01:00
parent b78a0257b4
commit c39a696977
23 changed files with 351 additions and 144 deletions
@@ -20,6 +20,7 @@ import jadx.plugins.script.runtime.data.Rename
import jadx.plugins.script.runtime.data.Replace
import jadx.plugins.script.runtime.data.Search
import jadx.plugins.script.runtime.data.Stages
import org.jetbrains.annotations.ApiStatus.Internal
import java.io.File
const val JADX_SCRIPT_LOG_PREFIX = "JadxScript:"
@@ -73,5 +74,5 @@ class JadxScriptInstance(
}
val internalDecompiler: JadxDecompiler
get() = decompiler
@Internal get() = decompiler
}
@@ -42,6 +42,10 @@ class Gui(
fun open(ref: ICodeNodeRef): Boolean = context().open(ref)
fun reloadActiveTab() = context().reloadActiveTab()
fun reloadAllTabs() = context().reloadAllTabs()
val nodeUnderCaret: ICodeNodeRef?
get() = context().nodeUnderCaret
val nodeUnderMouse: ICodeNodeRef?
@@ -51,6 +55,11 @@ class Gui(
val enclosingNodeUnderMouse: ICodeNodeRef?
get() = context().enclosingNodeUnderMouse
/**
* Save node rename in a project and run all needed UI updates
*/
fun applyNodeRename(node: ICodeNodeRef) = context().applyNodeRename(node)
private fun context(): JadxGuiContext =
guiContext ?: throw IllegalStateException("GUI plugins context not available!")
}
@@ -3,7 +3,7 @@ package jadx.plugins.script.runtime.data
import jadx.core.dex.nodes.ClassNode
import jadx.plugins.script.runtime.JadxScriptInstance
class Search(private val jadx: JadxScriptInstance) {
class Search(jadx: JadxScriptInstance) {
private val dec = jadx.internalDecompiler
fun classByFullName(fullName: String): ClassNode? {