Skip to content

Commit

Permalink
New: Add support for string concat expressions in MixinExtras. (#2281)
Browse files Browse the repository at this point in the history
  • Loading branch information
LlamaLad7 committed Apr 16, 2024
1 parent d93dd13 commit ab50622
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ abstract class MixinExtrasInjectorAnnotationHandler : InjectorAnnotationHandler(
},
SIMPLE_EXPRESSION {
override fun matches(target: TargetInsn) = target.hasDecoration(Decorations.SIMPLE_EXPRESSION_TYPE)
},
STRING_CONCAT_EXPRESSION {
override fun matches(target: TargetInsn) = target.hasDecoration(Decorations.IS_STRING_CONCAT_EXPRESSION)
};

abstract fun matches(target: TargetInsn): Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import org.objectweb.asm.tree.MethodNode
class ModifyExpressionValueHandler : MixinExtrasInjectorAnnotationHandler() {
override val supportedInstructionTypes = listOf(
InstructionType.METHOD_CALL, InstructionType.FIELD_GET, InstructionType.INSTANTIATION, InstructionType.CONSTANT,
InstructionType.SIMPLE_EXPRESSION
InstructionType.SIMPLE_EXPRESSION, InstructionType.STRING_CONCAT_EXPRESSION
)

override fun extraTargetRestrictions(insn: AbstractInsnNode): Boolean {
Expand Down Expand Up @@ -68,6 +68,9 @@ class ModifyExpressionValueHandler : MixinExtrasInjectorAnnotationHandler() {
target: TargetInsn,
annotation: PsiAnnotation
): PsiType? {
if (target.hasDecoration(Decorations.IS_STRING_CONCAT_EXPRESSION)) {
return PsiType.getJavaLangString(annotation.manager, annotation.resolveScope)
}
val psiReturnType = getPsiReturnType(target.insn, annotation)
val rawReturnType = getInsnReturnType(target.insn)
val exprType = target.getDecoration<Type>(Decorations.SIMPLE_EXPRESSION_TYPE)
Expand Down

0 comments on commit ab50622

Please sign in to comment.