Introduced LexicalScope for file top-level to obtain ownerDescriptor
This commit is contained in:
@@ -191,7 +191,7 @@ public class ShadowedDeclarationsFilter private constructor(
|
||||
var scope = context.getResolutionScope(bindingContext, resolutionFacade)
|
||||
|
||||
if (descriptorsToImport.isNotEmpty()) {
|
||||
scope = scope.addImportScope(ExplicitImportsScope(descriptorsToImport, scope.ownerDescriptor))
|
||||
scope = scope.addImportScope(ExplicitImportsScope(descriptorsToImport))
|
||||
}
|
||||
|
||||
val dataFlowInfo = bindingContext.getDataFlowInfo(context)
|
||||
|
||||
@@ -32,7 +32,6 @@ import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.lazy.FileScopeProvider
|
||||
import org.jetbrains.kotlin.resolve.scopes.ImportingScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.collectFunctions
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.collectVariables
|
||||
@@ -79,6 +78,6 @@ public fun PsiElement.getResolutionScope(bindingContext: BindingContext, resolut
|
||||
error("Not in KtFile")
|
||||
}
|
||||
|
||||
public fun ResolutionFacade.getFileResolutionScope(file: KtFile): ImportingScope {
|
||||
public fun ResolutionFacade.getFileResolutionScope(file: KtFile): LexicalScope {
|
||||
return frontendService<FileScopeProvider>().getFileResolutionScope(file)
|
||||
}
|
||||
+4
-4
@@ -31,7 +31,6 @@ import com.intellij.util.ui.UIUtil
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.util.getFileResolutionScope
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor
|
||||
import org.jetbrains.kotlin.idea.core.targetDescriptors
|
||||
@@ -41,6 +40,7 @@ import org.jetbrains.kotlin.idea.references.KtSimpleNameReference
|
||||
import org.jetbrains.kotlin.idea.stubindex.JetSourceFilterScope
|
||||
import org.jetbrains.kotlin.idea.util.application.executeWriteCommand
|
||||
import org.jetbrains.kotlin.idea.util.application.runReadAction
|
||||
import org.jetbrains.kotlin.idea.util.getFileResolutionScope
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
@@ -49,7 +49,7 @@ import org.jetbrains.kotlin.renderer.render
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.model.isReallySuccess
|
||||
import org.jetbrains.kotlin.resolve.isAnnotatedAsHidden
|
||||
import org.jetbrains.kotlin.resolve.scopes.ImportingScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.collectSyntheticExtensionProperties
|
||||
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||
@@ -87,9 +87,9 @@ public class ConflictingExtensionPropertyInspection : AbstractKotlinInspection()
|
||||
}
|
||||
}
|
||||
|
||||
private fun conflictingSyntheticExtension(descriptor: PropertyDescriptor, importingScope: ImportingScope): SyntheticJavaPropertyDescriptor? {
|
||||
private fun conflictingSyntheticExtension(descriptor: PropertyDescriptor, scope: LexicalScope): SyntheticJavaPropertyDescriptor? {
|
||||
val extensionReceiverType = descriptor.extensionReceiverParameter?.type ?: return null
|
||||
return importingScope.collectSyntheticExtensionProperties(listOf(extensionReceiverType), descriptor.name, NoLookupLocation.FROM_IDE)
|
||||
return scope.collectSyntheticExtensionProperties(listOf(extensionReceiverType), descriptor.name, NoLookupLocation.FROM_IDE)
|
||||
.firstIsInstanceOrNull<SyntheticJavaPropertyDescriptor>()
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -207,7 +207,7 @@ object ReplaceWithAnnotationAnalyzer {
|
||||
private fun buildExplicitImportsScope(annotation: ReplaceWith, resolutionFacade: ResolutionFacade, module: ModuleDescriptor): ExplicitImportsScope {
|
||||
val importedSymbols = importFqNames(annotation)
|
||||
.flatMap { resolutionFacade.resolveImportReference(module, it) }
|
||||
return ExplicitImportsScope(importedSymbols, module)
|
||||
return ExplicitImportsScope(importedSymbols)
|
||||
}
|
||||
|
||||
private fun importFqNames(annotation: ReplaceWith): List<FqName> {
|
||||
|
||||
Reference in New Issue
Block a user