mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[groovy] resolve: put receiver Argument into resolve state when resolving method references
GitOrigin-RevId: e8f1923a25aadab00edcfafe95cf6152518728ba
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5afc99451b
commit
dccdf09d73
+3
-6
@@ -5,12 +5,11 @@ import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiType
|
||||
import com.intellij.psi.ResolveState
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.rValueProcessor
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.resolveKinds
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.api.Argument
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.api.Arguments
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.processReceiverType
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.processReceiver
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.processors.MethodProcessor
|
||||
|
||||
fun resolveWithArguments(receiver: Argument,
|
||||
@@ -18,16 +17,14 @@ fun resolveWithArguments(receiver: Argument,
|
||||
arguments: Arguments?,
|
||||
place: PsiElement): List<GroovyResolveResult> {
|
||||
val state = ResolveState.initial()
|
||||
val receiverType = receiver.type ?: TypesUtil.getJavaLangObject(place)
|
||||
|
||||
val methodProcessor = MethodProcessor(methodName, place, arguments, PsiType.EMPTY_ARRAY)
|
||||
receiverType.processReceiverType(methodProcessor, state, place)
|
||||
receiver.processReceiver(methodProcessor, state, place)
|
||||
methodProcessor.applicableCandidates?.let {
|
||||
return it
|
||||
}
|
||||
|
||||
val propertyProcessor = rValueProcessor(methodName, place, resolveKinds(true))
|
||||
receiverType.processReceiverType(propertyProcessor, state, place)
|
||||
receiver.processReceiver(propertyProcessor, state, place)
|
||||
val properties = propertyProcessor.results
|
||||
if (properties.size == 1) {
|
||||
return properties
|
||||
|
||||
+13
-3
@@ -8,18 +8,28 @@ import com.intellij.psi.util.InheritanceUtil
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GrMapType
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GrTraitType
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiManager
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil.processClassDeclarations
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil.processNonCodeMembers
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.api.Argument
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.api.JustTypeArgument
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.impl.GroovyMapPropertyImpl
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint.STATIC_CONTEXT
|
||||
|
||||
fun Argument.processReceiver(processor: PsiScopeProcessor, state: ResolveState, place: PsiElement): Boolean {
|
||||
val receiverType: PsiType = type ?: TypesUtil.getJavaLangObject(place) ?: return true
|
||||
return receiverType.doProcessReceiverType0(processor, state.put(ClassHint.RECEIVER, this), place)
|
||||
}
|
||||
|
||||
fun PsiType?.processReceiverType(processor: PsiScopeProcessor, state: ResolveState, place: PsiElement): Boolean {
|
||||
if (this == null) return true
|
||||
val newState = state.put(ClassHint.RECEIVER, JustTypeArgument(this))
|
||||
if (!doProcessReceiverType(processor, newState, place)) return false
|
||||
return !state.processNonCodeMembers() || processNonCodeMembers(this, processor, place, newState)
|
||||
return doProcessReceiverType0(processor, state.put(ClassHint.RECEIVER, JustTypeArgument(this)), place)
|
||||
}
|
||||
|
||||
private fun PsiType.doProcessReceiverType0(processor: PsiScopeProcessor, state: ResolveState, place: PsiElement): Boolean {
|
||||
if (!doProcessReceiverType(processor, state, place)) return false
|
||||
return !state.processNonCodeMembers() || processNonCodeMembers(this, processor, place, state)
|
||||
}
|
||||
|
||||
private fun PsiType.doProcessReceiverType(processor: PsiScopeProcessor, state: ResolveState, place: PsiElement): Boolean {
|
||||
|
||||
Reference in New Issue
Block a user