Skip to content

Commit

Permalink
feat: add immutableMethod
Browse files Browse the repository at this point in the history
added docs
  • Loading branch information
Sculas authored and oSumAtrIX committed Jun 5, 2022
1 parent f806cb3 commit c63b20f
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,39 @@ package app.revanced.patcher.signature

import app.revanced.patcher.proxy.ClassProxy
import app.revanced.patcher.signature.resolver.SignatureResolver
import org.jf.dexlib2.iface.Method

/**
* Represents the result of a [SignatureResolver].
* @param definingClassProxy The [ClassProxy] that the matching method was found in.
* @param resolvedMethodName The name of the actual matching method.
* @param scanData OpCodes pattern scan result.
* @param scanData Opcodes pattern scan result.
*/
data class SignatureResolverResult(
val definingClassProxy: ClassProxy,
val scanData: PatternScanResult,
private val resolvedMethodName: String,
) {
/**
* Returns the **mutable** method by the [resolvedMethodName] from the [definingClassProxy].
*
* Please note, this method creates a [ClassProxy].
* Use [immutableMethod] where possible.
*/
val method get() = definingClassProxy.resolve().methods.first {
it.name == resolvedMethodName
}

/**
* Returns the **immutable** method by the [resolvedMethodName] from the [definingClassProxy].
*
* If you need to modify the method, use [method] instead.
*/
val immutableMethod: Method
get() = definingClassProxy.immutableClass.methods.first {
it.name == resolvedMethodName
}

@Suppress("Unused") // TODO(Sculas): remove this when we have coverage for this method.
fun findParentMethod(signature: MethodSignature): SignatureResolverResult? {
return SignatureResolver.resolveFromProxy(definingClassProxy, signature)
Expand Down

0 comments on commit c63b20f

Please sign in to comment.