Minor: reformat DebuggerUtils.kt
This commit is contained in:
@@ -43,28 +43,29 @@ import java.util.*
|
|||||||
|
|
||||||
object DebuggerUtils {
|
object DebuggerUtils {
|
||||||
fun findSourceFileForClassIncludeLibrarySources(
|
fun findSourceFileForClassIncludeLibrarySources(
|
||||||
project: Project,
|
project: Project,
|
||||||
scope: GlobalSearchScope,
|
scope: GlobalSearchScope,
|
||||||
className: JvmClassName,
|
className: JvmClassName,
|
||||||
fileName: String,
|
fileName: String,
|
||||||
location: Location? = null
|
location: Location? = null
|
||||||
): KtFile? {
|
): KtFile? {
|
||||||
return runReadAction {
|
return runReadAction {
|
||||||
findSourceFileForClass(
|
findSourceFileForClass(
|
||||||
project,
|
project,
|
||||||
listOf(scope, KotlinSourceFilterScope.librarySources(GlobalSearchScope.allScope(project), project)),
|
listOf(scope, KotlinSourceFilterScope.librarySources(GlobalSearchScope.allScope(project), project)),
|
||||||
className,
|
className,
|
||||||
fileName,
|
fileName,
|
||||||
location)
|
location
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun findSourceFileForClass(
|
fun findSourceFileForClass(
|
||||||
project: Project,
|
project: Project,
|
||||||
scopes: List<GlobalSearchScope>,
|
scopes: List<GlobalSearchScope>,
|
||||||
className: JvmClassName,
|
className: JvmClassName,
|
||||||
fileName: String,
|
fileName: String,
|
||||||
location: Location?
|
location: Location?
|
||||||
): KtFile? {
|
): KtFile? {
|
||||||
if (!isKotlinSourceFile(fileName)) return null
|
if (!isKotlinSourceFile(fileName)) return null
|
||||||
if (DumbService.getInstance(project).isDumb) return null
|
if (DumbService.getInstance(project).isDumb) return null
|
||||||
@@ -90,7 +91,9 @@ object DebuggerUtils {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
location?.let { return FileRankingCalculatorForIde.findMostAppropriateSource(filesWithExactName, it) }
|
if (location != null) {
|
||||||
|
return FileRankingCalculatorForIde.findMostAppropriateSource(filesWithExactName, location)
|
||||||
|
}
|
||||||
|
|
||||||
return filesWithExactName.first()
|
return filesWithExactName.first()
|
||||||
}
|
}
|
||||||
@@ -104,24 +107,29 @@ object DebuggerUtils {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun findFilesByNameInPackage(className: JvmClassName, fileName: String, project: Project, searchScope: GlobalSearchScope): List<KtFile> {
|
private fun findFilesByNameInPackage(
|
||||||
|
className: JvmClassName,
|
||||||
|
fileName: String,
|
||||||
|
project: Project,
|
||||||
|
searchScope: GlobalSearchScope
|
||||||
|
): List<KtFile> {
|
||||||
val files = findFilesWithExactPackage(className.packageFqName, searchScope, project).filter { it.name == fileName }
|
val files = findFilesWithExactPackage(className.packageFqName, searchScope, project).filter { it.name == fileName }
|
||||||
return files.sortedWith(JavaElementFinder.byClasspathComparator(searchScope))
|
return files.sortedWith(JavaElementFinder.byClasspathComparator(searchScope))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun analyzeInlinedFunctions(
|
fun analyzeInlinedFunctions(
|
||||||
resolutionFacadeForFile: ResolutionFacade,
|
resolutionFacadeForFile: ResolutionFacade,
|
||||||
file: KtFile,
|
file: KtFile,
|
||||||
analyzeOnlyReifiedInlineFunctions: Boolean,
|
analyzeOnlyReifiedInlineFunctions: Boolean,
|
||||||
bindingContext: BindingContext? = null
|
bindingContext: BindingContext? = null
|
||||||
): Pair<BindingContext, List<KtFile>> {
|
): Pair<BindingContext, List<KtFile>> {
|
||||||
val analyzedElements = HashSet<KtElement>()
|
val analyzedElements = HashSet<KtElement>()
|
||||||
val context = analyzeElementWithInline(
|
val context = analyzeElementWithInline(
|
||||||
resolutionFacadeForFile,
|
resolutionFacadeForFile,
|
||||||
file,
|
file,
|
||||||
1,
|
1,
|
||||||
analyzedElements,
|
analyzedElements,
|
||||||
!analyzeOnlyReifiedInlineFunctions, bindingContext
|
!analyzeOnlyReifiedInlineFunctions, bindingContext
|
||||||
)
|
)
|
||||||
|
|
||||||
//We processing another files just to annotate anonymous classes within their inline functions
|
//We processing another files just to annotate anonymous classes within their inline functions
|
||||||
@@ -149,12 +157,12 @@ object DebuggerUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun analyzeElementWithInline(
|
private fun analyzeElementWithInline(
|
||||||
resolutionFacade: ResolutionFacade,
|
resolutionFacade: ResolutionFacade,
|
||||||
element: KtElement,
|
element: KtElement,
|
||||||
deep: Int,
|
deep: Int,
|
||||||
analyzedElements: MutableSet<KtElement>,
|
analyzedElements: MutableSet<KtElement>,
|
||||||
analyzeInlineFunctions: Boolean,
|
analyzeInlineFunctions: Boolean,
|
||||||
fullResolveContext: BindingContext? = null
|
fullResolveContext: BindingContext? = null
|
||||||
): BindingContext {
|
): BindingContext {
|
||||||
val project = element.project
|
val project = element.project
|
||||||
val inlineFunctions = HashSet<KtNamedFunction>()
|
val inlineFunctions = HashSet<KtNamedFunction>()
|
||||||
@@ -219,7 +227,15 @@ object DebuggerUtils {
|
|||||||
for (inlineFunction in inlineFunctions) {
|
for (inlineFunction in inlineFunctions) {
|
||||||
val body = inlineFunction.bodyExpression
|
val body = inlineFunction.bodyExpression
|
||||||
if (body != null) {
|
if (body != null) {
|
||||||
innerContexts.add(analyzeElementWithInline(resolutionFacade, inlineFunction, deep + 1, analyzedElements, analyzeInlineFunctions))
|
innerContexts.add(
|
||||||
|
analyzeElementWithInline(
|
||||||
|
resolutionFacade,
|
||||||
|
inlineFunction,
|
||||||
|
deep + 1,
|
||||||
|
analyzedElements,
|
||||||
|
analyzeInlineFunctions
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,6 +246,6 @@ object DebuggerUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun hasReifiedTypeParameters(descriptor: CallableDescriptor): Boolean {
|
private fun hasReifiedTypeParameters(descriptor: CallableDescriptor): Boolean {
|
||||||
return descriptor.typeParameters.any() { it.isReified }
|
return descriptor.typeParameters.any { it.isReified }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user