Skip to content

Commit b3c73c5

Browse files
committed
Do prefix matching before creating shadow lookup elements
1 parent 5519c36 commit b3c73c5

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/main/kotlin/platform/mixin/completion/MixinCompletionContributor.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import com.intellij.codeInsight.completion.CompletionType
3232
import com.intellij.codeInsight.completion.JavaCompletionContributor
3333
import com.intellij.codeInsight.completion.JavaCompletionSorting
3434
import com.intellij.codeInsight.completion.LegacyCompletionContributor
35-
import com.intellij.codeInsight.completion.PrioritizedLookupElement
35+
import com.intellij.openapi.util.text.StringUtil
3636
import com.intellij.psi.PsiClassType
3737
import com.intellij.psi.PsiExpression
3838
import com.intellij.psi.PsiJavaReference
@@ -107,8 +107,11 @@ class MixinCompletionContributor : CompletionContributor() {
107107

108108
// Process methods and fields from target class
109109
val elements = findShadowTargets(psiClass, start, superMixin != null)
110+
.filter {
111+
val name = it.name
112+
StringUtil.isJavaIdentifier(name) && prefixMatcher.prefixMatches(name)
113+
}
110114
.map { it.createLookupElement(psiClass.project) }
111-
.filter { prefixMatcher.prefixMatches(it) }
112115
.filter(filter, position)
113116
.toList()
114117

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ private fun findShadowTargetsDeep(psiClass: PsiClass, start: PsiClass): Sequence
120120

121121
sealed class MixinTargetMember(val mixin: PsiClass?) {
122122
abstract val access: Int
123+
abstract val name: String
123124

124125
abstract fun findSourceElement(
125126
project: Project,
@@ -138,6 +139,7 @@ class FieldTargetMember(val classAndField: ClassAndFieldNode, mixin: PsiClass? =
138139
constructor(clazz: ClassNode, field: FieldNode) : this(ClassAndFieldNode(clazz, field))
139140

140141
override val access = classAndField.field.access
142+
override val name: String = classAndField.field.name
141143

142144
override fun findSourceElement(project: Project, scope: GlobalSearchScope, canDecompile: Boolean) =
143145
classAndField.field.findSourceField(classAndField.clazz, project, scope, canDecompile)
@@ -153,6 +155,7 @@ class MethodTargetMember(val classAndMethod: ClassAndMethodNode, mixin: PsiClass
153155
constructor(clazz: ClassNode, method: MethodNode) : this(ClassAndMethodNode(clazz, method))
154156

155157
override val access = classAndMethod.method.access
158+
override val name: String = classAndMethod.method.name
156159

157160
override fun findSourceElement(project: Project, scope: GlobalSearchScope, canDecompile: Boolean) =
158161
classAndMethod.method.findSourceElement(classAndMethod.clazz, project, scope, canDecompile)

0 commit comments

Comments
 (0)