Skip to content

Commit

Permalink
Code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinkip committed Apr 17, 2020
1 parent 6928700 commit 5040d37
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ import org.jetbrains.kotlin.psi.psiUtil.isAncestor

object CallSliceProducer : SliceProducer {
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) {
null -> {
val element = (usage.reference as? LightMemberReference)?.element ?: return emptyList()
Expand Down
4 changes: 2 additions & 2 deletions idea/src/org/jetbrains/kotlin/idea/slicer/InflowSlicer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ class InflowSlicer(
val anonymousFunction = accessedDescriptor.containingDeclaration as? AnonymousFunctionDescriptor
if (anonymousFunction != null && accessedDescriptor.name.asString() == "it") {
val functionLiteral = anonymousFunction.source.getPsi() as KtFunctionLiteral
val sliceTransformer = ArgumentSliceProducer(anonymousFunction.valueParameters.first())
processCalls(functionLiteral, false, sliceTransformer)
val parameterDescriptor = anonymousFunction.valueParameters.first()
processCalls(functionLiteral, false, ArgumentSliceProducer(parameterDescriptor))
}
} else {
accessedDeclaration.passDeclarationToProcessorWithOverriders()
Expand Down
7 changes: 1 addition & 6 deletions idea/src/org/jetbrains/kotlin/idea/slicer/OutflowSlicer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,7 @@ class OutflowSlicer(
}

private fun processFunction(function: KtFunction) {
//TODO: CallSliceProducer in all cases
if (function is KtConstructor<*> || function is KtNamedFunction && function.name != null) {
processCalls(function, includeOverriders = false, sliceProducer = CallSliceProducer)
} else {
processCalls(function, false, SliceProducer.Trivial)
}
processCalls(function, includeOverriders = false, CallSliceProducer)
}

private fun processExtensionReceiver(declaration: KtCallableDeclaration, declarationWithBody: KtDeclarationWithBody) {
Expand Down

0 comments on commit 5040d37

Please sign in to comment.