Skip to content

Commit 6f1a15c

Browse files
committed
Fix mixin autocomplete spinning indefinitely in classes with many lambdas
1 parent 3e136d0 commit 6f1a15c

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/main/kotlin/platform/mixin/util/AsmUtil.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import com.demonwav.mcdev.util.findMethods
3030
import com.demonwav.mcdev.util.findModule
3131
import com.demonwav.mcdev.util.findQualifiedClass
3232
import com.demonwav.mcdev.util.fullQualifiedName
33-
import com.demonwav.mcdev.util.hasSyntheticMethod
3433
import com.demonwav.mcdev.util.innerIndexAndName
3534
import com.demonwav.mcdev.util.isErasureEquivalentTo
3635
import com.demonwav.mcdev.util.localClasses
@@ -729,17 +728,20 @@ private fun findContainingMethod(clazz: ClassNode, lambdaMethod: MethodNode): Pa
729728
else -> return@nextInsn
730729
}
731730

732-
// check if this lambda generated a synthetic method
731+
// Count every LambdaMetafactory invokedynamic unconditionally so the index matches
732+
// a PSI walk that counts all lambda expressions and method references without needing
733+
// to call hasSyntheticMethod to filter them.
734+
lambdaCount++
735+
val lambdaCountThisLine =
736+
lineNumber?.let { lambdaCountPerLine.merge(it, 1, Int::plus) } ?: lambdaCount
737+
738+
// Only record an entry when the lambda generated a synthetic method in this class.
733739
if (invokedMethod.owner != clazz.name) return@nextInsn
734740
val invokedMethodNode = clazz.findMethod(MemberReference(invokedMethod.name, invokedMethod.desc))
735741
if (invokedMethodNode == null || !invokedMethodNode.hasAccess(Opcodes.ACC_SYNTHETIC)) {
736742
return@nextInsn
737743
}
738744

739-
lambdaCount++
740-
val lambdaCountThisLine =
741-
lineNumber?.let { lambdaCountPerLine.merge(it, 1, Int::plus) } ?: lambdaCount
742-
743745
if (invokedMethod.name == lambdaMethod.name && invokedMethod.desc == lambdaMethod.desc) {
744746
val locationInfo =
745747
SourceCodeLocationInfo(lambdaCount - 1, lineNumber, lambdaCountThisLine - 1)
@@ -782,10 +784,8 @@ private fun findAssociatedLambda(project: Project, scope: GlobalSearchScope, cla
782784
// walk inside the reference first, visits the qualifier first (it's first in the bytecode)
783785
super.visitMethodReferenceExpression(expression)
784786

785-
if (expression.hasSyntheticMethod(clazz.version)) {
786-
if (matcher.accept(expression)) {
787-
stopWalking()
788-
}
787+
if (matcher.accept(expression)) {
788+
stopWalking()
789789
}
790790
}
791791
},

0 commit comments

Comments
 (0)