Code refactoring
This commit is contained in:
@@ -16,6 +16,11 @@ import org.jetbrains.kotlin.psi.psiUtil.isAncestor
|
|||||||
|
|
||||||
object CallSliceProducer : SliceProducer {
|
object CallSliceProducer : SliceProducer {
|
||||||
override fun produce(usage: UsageInfo, behaviour: KotlinSliceUsage.SpecialBehaviour?, parent: SliceUsage): Collection<SliceUsage>? {
|
override fun produce(usage: UsageInfo, behaviour: KotlinSliceUsage.SpecialBehaviour?, parent: SliceUsage): Collection<SliceUsage>? {
|
||||||
|
if ((parent as? KotlinSliceUsage)?.behaviour is LambdaCallsBehaviour) {
|
||||||
|
// UsageInfo produced by LambdaCallsBehaviour has full call-element and does not require any processing
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
when (val refElement = usage.element) {
|
when (val refElement = usage.element) {
|
||||||
null -> {
|
null -> {
|
||||||
val element = (usage.reference as? LightMemberReference)?.element ?: return emptyList()
|
val element = (usage.reference as? LightMemberReference)?.element ?: return emptyList()
|
||||||
|
|||||||
@@ -190,8 +190,8 @@ class InflowSlicer(
|
|||||||
val anonymousFunction = accessedDescriptor.containingDeclaration as? AnonymousFunctionDescriptor
|
val anonymousFunction = accessedDescriptor.containingDeclaration as? AnonymousFunctionDescriptor
|
||||||
if (anonymousFunction != null && accessedDescriptor.name.asString() == "it") {
|
if (anonymousFunction != null && accessedDescriptor.name.asString() == "it") {
|
||||||
val functionLiteral = anonymousFunction.source.getPsi() as KtFunctionLiteral
|
val functionLiteral = anonymousFunction.source.getPsi() as KtFunctionLiteral
|
||||||
val sliceTransformer = ArgumentSliceProducer(anonymousFunction.valueParameters.first())
|
val parameterDescriptor = anonymousFunction.valueParameters.first()
|
||||||
processCalls(functionLiteral, false, sliceTransformer)
|
processCalls(functionLiteral, false, ArgumentSliceProducer(parameterDescriptor))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
accessedDeclaration.passDeclarationToProcessorWithOverriders()
|
accessedDeclaration.passDeclarationToProcessorWithOverriders()
|
||||||
|
|||||||
@@ -148,12 +148,7 @@ class OutflowSlicer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun processFunction(function: KtFunction) {
|
private fun processFunction(function: KtFunction) {
|
||||||
//TODO: CallSliceProducer in all cases
|
processCalls(function, includeOverriders = false, CallSliceProducer)
|
||||||
if (function is KtConstructor<*> || function is KtNamedFunction && function.name != null) {
|
|
||||||
processCalls(function, includeOverriders = false, sliceProducer = CallSliceProducer)
|
|
||||||
} else {
|
|
||||||
processCalls(function, false, SliceProducer.Trivial)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun processExtensionReceiver(declaration: KtCallableDeclaration, declarationWithBody: KtDeclarationWithBody) {
|
private fun processExtensionReceiver(declaration: KtCallableDeclaration, declarationWithBody: KtDeclarationWithBody) {
|
||||||
|
|||||||
Reference in New Issue
Block a user