Improve ResolutionFacade api: it stores moduleInfo and provides moduleDescriptor

Remove some redundant parameters passed along with ResolutionFacade
This commit is contained in:
Pavel V. Talanov
2015-08-20 17:47:37 +03:00
parent a802ab5300
commit 608345df7b
27 changed files with 151 additions and 162 deletions
@@ -110,10 +110,9 @@ public class ReferenceVariantsHelper(
val dataFlowInfo = context.getDataFlowInfo(expression)
val smartCastManager = resolutionFacade.frontendService<SmartCastManager>(expression)
val smartCastManager = resolutionFacade.frontendService<SmartCastManager>()
val implicitReceiverTypes = resolutionScope.getImplicitReceiversWithInstance().flatMap {
smartCastManager
.getSmartCastVariantsWithLessSpecificExcluded(it.value, context, containingDeclaration, dataFlowInfo)
smartCastManager.getSmartCastVariantsWithLessSpecificExcluded(it.value, context, containingDeclaration, dataFlowInfo)
}.toSet()
val pair = getExplicitReceiverData(expression)
@@ -35,25 +35,22 @@ public interface ResolutionFacade {
public fun resolveToDescriptor(declaration: JetDeclaration): DeclarationDescriptor
public fun findModuleDescriptor(element: JetElement): ModuleDescriptor
public val moduleDescriptor: ModuleDescriptor
// get service for the module this resolution was created for
public fun <T> getFrontendService(serviceClass: Class<T>): T
public fun <T> getIdeService(serviceClass: Class<T>): T
// get service for the module defined by PsiElement/ModuleDescriptor passed as parameter
public fun <T> getFrontendService(element: PsiElement, serviceClass: Class<T>): T
public fun <T> getFrontendService(moduleDescriptor: ModuleDescriptor, serviceClass: Class<T>): T
public fun <T> getIdeService(element: PsiElement, serviceClass: Class<T>): T
public fun <T> getIdeService(moduleDescriptor: ModuleDescriptor, serviceClass: Class<T>): T
}
public inline fun <reified T> ResolutionFacade.frontendService(element: PsiElement): T
= this.getFrontendService(element, javaClass<T>())
public inline fun <reified T> ResolutionFacade.frontendService(): T
= this.getFrontendService(javaClass<T>())
public inline fun <reified T> ResolutionFacade.frontendService(moduleDescriptor: ModuleDescriptor): T
= this.getFrontendService(moduleDescriptor, javaClass<T>())
public inline fun <reified T> ResolutionFacade.ideService(element: PsiElement): T
= this.getIdeService(element, javaClass<T>())
public inline fun <reified T> ResolutionFacade.ideService(moduleDescriptor: ModuleDescriptor): T
= this.getIdeService(moduleDescriptor, javaClass<T>())
public inline fun <reified T> ResolutionFacade.ideService(): T
= this.getIdeService(javaClass<T>())
@@ -165,7 +165,7 @@ public class ShadowedDeclarationsFilter(
val context = BasicCallResolutionContext.create(bindingTrace, resolutionScope, newCall, TypeUtils.NO_EXPECTED_TYPE, dataFlowInfo,
ContextDependency.INDEPENDENT, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS,
CallChecker.DoNothing, false)
val callResolver = resolutionFacade.frontendService<CallResolver>(calleeExpression)
val callResolver = resolutionFacade.frontendService<CallResolver>()
val results = if (isFunction) callResolver.resolveFunctionCall(context) else callResolver.resolveSimpleProperty(context)
val resultingDescriptors = results.getResultingCalls().map { it.getResultingDescriptor() }
val resultingOriginals = resultingDescriptors.mapTo(HashSet<DeclarationDescriptor>()) { it.getOriginal() }