Minor: move getResolveScope out of ResolutionFacade
This commit is contained in:
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.kotlin.idea.caches.resolve
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import org.jetbrains.kotlin.analyzer.AnalysisResult
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
@@ -52,18 +51,6 @@ public interface ResolutionFacade {
|
||||
public fun <T> getIdeService(element: PsiElement, serviceClass: Class<T>): T
|
||||
|
||||
public fun <T> getIdeService(moduleDescriptor: ModuleDescriptor, serviceClass: Class<T>): T
|
||||
|
||||
companion object {
|
||||
//NOTE: idea default API returns module search scope for file under module but not in source or production source (for example, test data )
|
||||
// this scope can't be used to search for kotlin declarations in index in order to resolve in that case
|
||||
// see com.intellij.psi.impl.file.impl.ResolveScopeManagerImpl.getInherentResolveScope
|
||||
public fun getResolveScope(file: JetFile): GlobalSearchScope {
|
||||
return when (file.getModuleInfo()) {
|
||||
is ModuleSourceInfo -> file.getResolveScope()
|
||||
else -> GlobalSearchScope.EMPTY_SCOPE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public inline fun <reified T> ResolutionFacade.frontendService(element: PsiElement): T
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.caches.resolve
|
||||
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import org.jetbrains.kotlin.analyzer.AnalysisResult
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
@@ -65,3 +66,13 @@ public fun JetElement.analyzeFully(): BindingContext {
|
||||
public fun JetElement.analyzeFullyAndGetResult(vararg extraFiles: JetFile): AnalysisResult {
|
||||
return KotlinCacheService.getInstance(getProject()).getResolutionFacade(listOf(this) + extraFiles.toList()).analyzeFullyAndGetResult(listOf(this))
|
||||
}
|
||||
|
||||
//NOTE: idea default API returns module search scope for file under module but not in source or production source (for example, test data )
|
||||
// this scope can't be used to search for kotlin declarations in index in order to resolve in that case
|
||||
// see com.intellij.psi.impl.file.impl.ResolveScopeManagerImpl.getInherentResolveScope
|
||||
public fun getResolveScope(file: JetFile): GlobalSearchScope {
|
||||
return when (file.getModuleInfo()) {
|
||||
is ModuleSourceInfo -> file.getResolveScope()
|
||||
else -> GlobalSearchScope.EMPTY_SCOPE
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user