Skip to content

Commit

Permalink
fix(plugins): do not parse kotlin metadata if all options disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
skylot committed Aug 5, 2023
1 parent 68b84ea commit a06231d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ class KotlinMetadataOptions : BaseOptionsParser() {
)
}

fun isPreparePassNeeded(): Boolean {
return isClassAlias
}

fun isDecompilePassNeeded(): Boolean {
return isMethodArgs || isFields || isCompanion || isDataClass || isToString || isGetters
}

companion object {
const val CLASS_ALIAS_OPT = "$PLUGIN_ID.class-alias"
const val METHOD_ARGS_OPT = "$PLUGIN_ID.method-args"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ class KotlinMetadataPlugin : JadxPlugin {

override fun init(context: JadxPluginContext) {
context.registerOptions(options)
context.addPass(KotlinMetadataPreparePass(options))
context.addPass(KotlinMetadataDecompilePass(options))
if (options.isPreparePassNeeded()) {
context.addPass(KotlinMetadataPreparePass(options))
}
if (options.isDecompilePassNeeded()) {
context.addPass(KotlinMetadataDecompilePass(options))
}
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class KotlinMetadataDecompilePass(
val args = wrapper.getMethodArgs()
args.forEach { (_, list) ->
list.forEach { (rArg, alias) ->
// TODO comment not being added ?
// TODO: comment not being added?
RenameReasonAttr.forNode(rArg).append(METADATA_REASON)
rArg.name = alias
}
Expand Down

0 comments on commit a06231d

Please sign in to comment.