-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code refactoring + better handling of incoming data flow to java supe…
…r methods
- Loading branch information
1 parent
b5b0fd6
commit 1e39d4a
Showing
7 changed files
with
172 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
idea/src/org/jetbrains/kotlin/idea/slicer/SliceProducer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. | ||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. | ||
*/ | ||
|
||
package org.jetbrains.kotlin.idea.slicer | ||
|
||
import com.intellij.slicer.SliceUsage | ||
import com.intellij.usageView.UsageInfo | ||
import org.jetbrains.kotlin.idea.findUsages.handlers.SliceUsageProcessor | ||
|
||
interface SliceProducer { | ||
fun produce(usage: UsageInfo, behaviour: KotlinSliceUsage.SpecialBehaviour?, parent: SliceUsage): Collection<SliceUsage>? | ||
|
||
override fun equals(other: Any?): Boolean | ||
override fun hashCode(): Int | ||
} | ||
|
||
fun SliceProducer.produceAndProcess( | ||
sliceUsage: SliceUsage, | ||
behaviour: KotlinSliceUsage.SpecialBehaviour?, | ||
parentUsage: SliceUsage, | ||
processor: SliceUsageProcessor | ||
): Boolean { | ||
val result = produce(sliceUsage.usageInfo, behaviour, parentUsage) ?: listOf(sliceUsage) | ||
for (usage in result) { | ||
if (!processor.process(usage)) return false | ||
} | ||
return true | ||
} |
Oops, something went wrong.