Use debugProcess scope in KotlinPositionManager
This commit is contained in:
@@ -30,7 +30,6 @@ import com.intellij.openapi.roots.libraries.LibraryUtil
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiFile
|
||||
import com.intellij.psi.impl.compiled.ClsFileImpl
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.psi.search.searches.ReferencesSearch
|
||||
import com.intellij.psi.util.*
|
||||
import com.intellij.util.ThreeState
|
||||
@@ -100,7 +99,7 @@ public class KotlinPositionManager(private val myDebugProcess: DebugProcess) : M
|
||||
val javaClassName = JvmClassName.byInternalName(defaultInternalName(location))
|
||||
val project = myDebugProcess.project
|
||||
|
||||
val defaultPsiFile = DebuggerUtils.findSourceFileForClass(project, GlobalSearchScope.allScope(project), javaClassName, javaSourceFileName)
|
||||
val defaultPsiFile = DebuggerUtils.findSourceFileForClass(project, myDebugProcess.searchScope, javaClassName, javaSourceFileName)
|
||||
if (defaultPsiFile != null) {
|
||||
return SourcePosition.createFromLine(defaultPsiFile, 0)
|
||||
}
|
||||
@@ -197,7 +196,7 @@ public class KotlinPositionManager(private val myDebugProcess: DebugProcess) : M
|
||||
|
||||
val project = myDebugProcess.project
|
||||
|
||||
return DebuggerUtils.findSourceFileForClass(project, GlobalSearchScope.allScope(project), className, sourceName)
|
||||
return DebuggerUtils.findSourceFileForClass(project, myDebugProcess.searchScope, className, sourceName)
|
||||
}
|
||||
|
||||
private fun defaultInternalName(location: Location): String {
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.intellij.psi.search.GlobalSearchScope
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
|
||||
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.stubindex.KotlinSourceFilterScope
|
||||
import org.jetbrains.kotlin.idea.stubindex.PackageIndexUtil.findFilesWithExactPackage
|
||||
import org.jetbrains.kotlin.idea.stubindex.StaticFacadeIndexUtil
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
@@ -34,6 +35,7 @@ import org.jetbrains.kotlin.resolve.inline.InlineUtil
|
||||
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedSimpleFunctionDescriptor
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.check
|
||||
import java.util.*
|
||||
|
||||
object DebuggerUtils {
|
||||
@@ -49,8 +51,11 @@ object DebuggerUtils {
|
||||
if (!KOTLIN_EXTENSIONS.contains(extension)) return null
|
||||
if (DumbService.getInstance(project).isDumb) return null
|
||||
|
||||
val filesInPackage = findFilesWithExactPackage(className.packageFqName, searchScope, project)
|
||||
val filesWithExactName = filesInPackage.filter { it.name == fileName }
|
||||
val filesWithExactName = findFilesByNameInPackage(className, fileName, project, searchScope).check { it.isNotEmpty() }
|
||||
// Source files for libraries aren't included into ModuleWithDependencies scope
|
||||
?: findFilesByNameInPackage(
|
||||
className, fileName, project,
|
||||
KotlinSourceFilterScope.librarySources(GlobalSearchScope.allScope(project), project))
|
||||
|
||||
if (filesWithExactName.isEmpty()) return null
|
||||
|
||||
@@ -74,6 +79,9 @@ object DebuggerUtils {
|
||||
return filesWithExactName.first()
|
||||
}
|
||||
|
||||
private fun findFilesByNameInPackage(className: JvmClassName, fileName: String, project: Project, searchScope: GlobalSearchScope)
|
||||
= findFilesWithExactPackage(className.packageFqName, searchScope, project).filter { it.name == fileName }
|
||||
|
||||
fun analyzeInlinedFunctions(
|
||||
resolutionFacadeForFile: ResolutionFacade,
|
||||
bindingContextForFile: BindingContext,
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.intellij.debugger.jdi.VirtualMachineProxyImpl;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import com.sun.jdi.Location;
|
||||
import com.sun.jdi.ReferenceType;
|
||||
@@ -203,6 +204,12 @@ public abstract class AbstractPositionManagerTest extends KotlinLightCodeInsight
|
||||
}
|
||||
return virtualMachineProxy;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public GlobalSearchScope getSearchScope() {
|
||||
return GlobalSearchScope.allScope(getProject());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user