mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[groovy] speed up constructor resolution by providing name hint
This commit is contained in:
+8
-3
@@ -1,8 +1,9 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.groovy.lang.resolve.impl
|
||||
|
||||
import com.intellij.psi.*
|
||||
import com.intellij.psi.scope.ElementClassHint
|
||||
import com.intellij.psi.scope.NameHint
|
||||
import com.intellij.psi.scope.ProcessorWithHints
|
||||
import com.intellij.util.SmartList
|
||||
import org.jetbrains.plugins.groovy.lang.psi.util.elementInfo
|
||||
@@ -28,19 +29,23 @@ private fun classConstructors(clazz: PsiClass): List<PsiMethod> {
|
||||
}
|
||||
|
||||
private fun runtimeConstructors(clazz: PsiClass, place: PsiElement): List<PsiMethod> {
|
||||
val processor = ConstructorProcessor()
|
||||
val name = clazz.name ?: return emptyList()
|
||||
val processor = ConstructorProcessor(name)
|
||||
val qualifierType = JavaPsiFacade.getElementFactory(clazz.project).createType(clazz)
|
||||
processNonCodeMembers(qualifierType, processor, place, ResolveState.initial())
|
||||
return processor.candidates
|
||||
}
|
||||
|
||||
private class ConstructorProcessor : ProcessorWithHints(), GroovyResolveKind.Hint, ElementClassHint {
|
||||
private class ConstructorProcessor(private val name: String) : ProcessorWithHints(), NameHint, GroovyResolveKind.Hint, ElementClassHint {
|
||||
|
||||
init {
|
||||
hint(NameHint.KEY, this)
|
||||
hint(GroovyResolveKind.HINT_KEY, this)
|
||||
hint(ElementClassHint.KEY, this)
|
||||
}
|
||||
|
||||
override fun getName(state: ResolveState): String? = name
|
||||
|
||||
override fun shouldProcess(kind: GroovyResolveKind): Boolean = kind == GroovyResolveKind.METHOD
|
||||
|
||||
override fun shouldProcess(kind: ElementClassHint.DeclarationKind): Boolean = kind == ElementClassHint.DeclarationKind.METHOD
|
||||
|
||||
Reference in New Issue
Block a user