Skip to content

Commit

Permalink
Mixin tweaks for upcoming MixinExtras feature (#2205)
Browse files Browse the repository at this point in the history
* Mixin: Look for injector annotations more widely when autocompleting in `@At`s.

* Mixin: Don't warn about lack of possible injector signatures if a custom injection point is used.
  • Loading branch information
LlamaLad7 authored Jan 14, 2024
1 parent 2439870 commit 8b003af
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,12 @@ class InvalidInjectorMethodSignatureInspection : MixinInspection() {

if (possibleSignatures.isEmpty()) {
reportedSignature = true
holder.registerProblem(
parameters,
"There are no possible signatures for this injector",
)
if (handler.isUnresolved(annotation) != null) {
holder.registerProblem(
parameters,
"There are no possible signatures for this injector",
)
}
continue
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

package com.demonwav.mcdev.platform.mixin.reference.target

import com.demonwav.mcdev.platform.mixin.handlers.InjectorAnnotationHandler
import com.demonwav.mcdev.platform.mixin.handlers.MixinAnnotationHandler
import com.demonwav.mcdev.platform.mixin.handlers.injectionPoint.AtResolver
import com.demonwav.mcdev.platform.mixin.reference.MixinReference
Expand Down Expand Up @@ -71,9 +72,13 @@ object TargetReference : PolyReferenceResolver(), MixinReference {
private fun getTargets(at: PsiAnnotation, forUnresolved: Boolean): List<ClassAndMethodNode>? {
val (handler, annotation) = generateSequence(at.parent) { it.parent }
.filterIsInstance<PsiAnnotation>()
.flatMap { it.owner?.annotations?.asSequence() ?: emptySequence() }
.mapNotNull { annotation ->
val qName = annotation.qualifiedName ?: return@mapNotNull null
MixinAnnotationHandler.forMixinAnnotation(qName, annotation.project)?.let { it to annotation }
(
MixinAnnotationHandler.forMixinAnnotation(qName, annotation.project)
as? InjectorAnnotationHandler
)?.let { it to annotation }
}.firstOrNull() ?: return null
if (forUnresolved && handler.isSoft) {
return null
Expand Down

0 comments on commit 8b003af

Please sign in to comment.