From 683bbe396d23fe2f394502bfcdc28b7481fde8a3 Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Thu, 9 Nov 2017 21:26:42 +0300 Subject: [PATCH] Data Inflow: Support grouping by leaf expressions --- .../kotlin/generators/tests/GenerateTests.kt | 9 +- .../kotlin/idea/slicer/KotlinSliceProvider.kt | 19 +- .../kotlin/idea/slicer/KotlinSliceUsage.kt | 15 + .../anonymousFunBodyExpression.leafGroups.txt | 12 + ...nonymousFunReturnExpression.leafGroups.txt | 12 + .../slicer/inflow/cast.leafGroups.txt | 6 + .../compositeAssignments.leafGroups.txt | 17 + .../defaultGetterFieldInSetter.leafGroups.txt | 14 + .../inflow/delegateGetter.leafGroups.txt | 7 + ...mondHierarchyMiddleClassFun.leafGroups.txt | 12 + ...HierarchyMiddleInterfaceFun.leafGroups.txt | 12 + ...ndHierarchyRootInterfaceFun.leafGroups.txt | 24 ++ .../inflow/doubleLambdaResult.leafGroups.txt | 14 + .../slicer/inflow/funParamerer.leafGroups.txt | 4 + .../funParamererWithDefault.leafGroups.txt | 8 + .../funResultViaCallableRef.leafGroups.txt | 12 + ...iaCallableRefWithAssignment.leafGroups.txt | 14 + ...iaCallableRefWithDirectCall.leafGroups.txt | 8 + .../funWithExpressionBody.leafGroups.txt | 4 + .../funWithReturnExpressions.leafGroups.txt | 9 + .../getterAndSetterUsingField.leafGroups.txt | 18 + .../getterExpressionBody.leafGroups.txt | 6 + .../getterReturnExpression.leafGroups.txt | 6 + .../slicer/inflow/ifExpression.leafGroups.txt | 11 + .../slicer/inflow/lambdaResult.leafGroups.txt | 11 + ...lambdaResultWithAssignments.leafGroups.txt | 13 + .../lambdaResultWithDirectCall.leafGroups.txt | 7 + ...WithDirectCallViaAssignment.leafGroups.txt | 9 + .../slicer/inflow/localVal.leafGroups.txt | 5 + .../slicer/inflow/localVar.leafGroups.txt | 9 + .../memberValWithInitializer.leafGroups.txt | 4 + ...mberValWithSplitInitializer.leafGroups.txt | 4 + .../memberVarWithInitializer.leafGroups.txt | 8 + ...mberVarWithSplitInitializer.leafGroups.txt | 8 + .../inflow/noFieldInGetter.leafGroups.txt | 5 + .../inflow/nonLocalReturn.leafGroups.txt | 16 + .../inflow/notNullAssertion.leafGroups.txt | 6 + .../overridingFunctionResult.leafGroups.txt | 12 + .../inflow/overridingParameter.leafGroups.txt | 11 + ...rridingPropertyGetterResult.leafGroups.txt | 12 + .../overridingPropertyResult.leafGroups.txt | 12 + ...primaryConstructorParameter.leafGroups.txt | 4 + ...tructorParameterWithDefault.leafGroups.txt | 8 + ...dAssignmentsForQualifiedRef.leafGroups.txt | 21 ++ ...fiedAssignmentsForSimpleRef.leafGroups.txt | 21 ++ .../slicer/inflow/safeCast.leafGroups.txt | 6 + ...condaryConstructorParameter.leafGroups.txt | 4 + ...tructorParameterWithDefault.leafGroups.txt | 8 + ...sViaDelegateForQualifiedRef.leafGroups.txt | 29 ++ ...tersViaDelegateForSimpleRef.leafGroups.txt | 29 ++ .../slicer/inflow/topLevelVal.leafGroups.txt | 4 + .../slicer/inflow/topLevelVar.leafGroups.txt | 8 + .../slicer/inflow/valParameter.leafGroups.txt | 8 + .../slicer/inflow/varParameter.leafGroups.txt | 12 + .../inflow/whenExpression.leafGroups.txt | 16 + .../slicer/AbstractSlicerLeafGroupingTest.kt | 38 ++ .../kotlin/idea/slicer/AbstractSlicerTest.kt | 134 ++++--- .../idea/slicer/AbstractSlicerTreeTest.kt | 27 ++ .../SlicerLeafGroupingTestGenerated.java | 350 ++++++++++++++++++ ...ated.java => SlicerTreeTestGenerated.java} | 2 +- 60 files changed, 1074 insertions(+), 80 deletions(-) create mode 100644 idea/testData/slicer/inflow/anonymousFunBodyExpression.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/anonymousFunReturnExpression.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/cast.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/compositeAssignments.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/defaultGetterFieldInSetter.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/delegateGetter.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/diamondHierarchyMiddleClassFun.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/diamondHierarchyMiddleInterfaceFun.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/diamondHierarchyRootInterfaceFun.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/doubleLambdaResult.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/funParamerer.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/funParamererWithDefault.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/funResultViaCallableRef.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/funResultViaCallableRefWithAssignment.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/funResultViaCallableRefWithDirectCall.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/funWithExpressionBody.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/funWithReturnExpressions.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/getterAndSetterUsingField.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/getterExpressionBody.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/getterReturnExpression.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/ifExpression.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/lambdaResult.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/lambdaResultWithAssignments.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/lambdaResultWithDirectCall.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/lambdaResultWithDirectCallViaAssignment.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/localVal.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/localVar.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/memberValWithInitializer.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/memberValWithSplitInitializer.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/memberVarWithInitializer.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/memberVarWithSplitInitializer.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/noFieldInGetter.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/nonLocalReturn.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/notNullAssertion.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/overridingFunctionResult.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/overridingParameter.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/overridingPropertyGetterResult.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/overridingPropertyResult.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/primaryConstructorParameter.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/primaryConstructorParameterWithDefault.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/qualifiedAssignmentsForQualifiedRef.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/qualifiedAssignmentsForSimpleRef.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/safeCast.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/secondaryConstructorParameter.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/secondaryConstructorParameterWithDefault.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/settersViaDelegateForQualifiedRef.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/settersViaDelegateForSimpleRef.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/topLevelVal.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/topLevelVar.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/valParameter.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/varParameter.leafGroups.txt create mode 100644 idea/testData/slicer/inflow/whenExpression.leafGroups.txt create mode 100644 idea/tests/org/jetbrains/kotlin/idea/slicer/AbstractSlicerLeafGroupingTest.kt create mode 100644 idea/tests/org/jetbrains/kotlin/idea/slicer/AbstractSlicerTreeTest.kt create mode 100644 idea/tests/org/jetbrains/kotlin/idea/slicer/SlicerLeafGroupingTestGenerated.java rename idea/tests/org/jetbrains/kotlin/idea/slicer/{SlicerTestGenerated.java => SlicerTreeTestGenerated.java} (99%) diff --git a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt index af2eb38fed0..664d97d2e78 100755 --- a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt +++ b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt @@ -132,7 +132,8 @@ import org.jetbrains.kotlin.idea.resolve.* import org.jetbrains.kotlin.idea.script.AbstractScriptConfigurationCompletionTest import org.jetbrains.kotlin.idea.script.AbstractScriptConfigurationHighlightingTest import org.jetbrains.kotlin.idea.script.AbstractScriptConfigurationNavigationTest -import org.jetbrains.kotlin.idea.slicer.AbstractSlicerTest +import org.jetbrains.kotlin.idea.slicer.AbstractSlicerLeafGroupingTest +import org.jetbrains.kotlin.idea.slicer.AbstractSlicerTreeTest import org.jetbrains.kotlin.idea.structureView.AbstractKotlinFileStructureTest import org.jetbrains.kotlin.idea.stubs.AbstractMultiFileHighlightingTest import org.jetbrains.kotlin.idea.stubs.AbstractResolveByStubTest @@ -719,9 +720,13 @@ fun main(args: Array) { model("refactoring/nameSuggestionProvider") } - testClass { + testClass { model("slicer", singleClass = true) } + + testClass { + model("slicer/inflow", singleClass = true) + } } testGroup("idea/idea-maven/test", "idea/idea-maven/testData") { diff --git a/idea/src/org/jetbrains/kotlin/idea/slicer/KotlinSliceProvider.kt b/idea/src/org/jetbrains/kotlin/idea/slicer/KotlinSliceProvider.kt index 240cf1e20e1..c4e7a808095 100644 --- a/idea/src/org/jetbrains/kotlin/idea/slicer/KotlinSliceProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/slicer/KotlinSliceProvider.kt @@ -19,15 +19,22 @@ package org.jetbrains.kotlin.idea.slicer import com.intellij.ide.util.treeView.AbstractTreeStructure import com.intellij.openapi.actionSystem.DefaultActionGroup import com.intellij.psi.PsiElement -import com.intellij.slicer.SliceAnalysisParams -import com.intellij.slicer.SliceLanguageSupportProvider -import com.intellij.slicer.SliceTreeBuilder +import com.intellij.slicer.* +import org.jetbrains.kotlin.idea.references.KtReference import org.jetbrains.kotlin.idea.references.mainReference import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.isPlainWithEscapes import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf class KotlinSliceProvider : SliceLanguageSupportProvider { + companion object { + val LEAF_ELEMENT_EQUALITY = object : SliceLeafEquality() { + override fun substituteElement(element: PsiElement) = (element as? KtReference)?.resolve() ?: element + } + } + + val leafAnalyzer by lazy { SliceLeafAnalyzer(LEAF_ELEMENT_EQUALITY, this) } + override fun createRootUsage(element: PsiElement, params: SliceAnalysisParams) = KotlinSliceUsage(element, params) override fun getExpressionAtCaret(atCaret: PsiElement?, dataFlowToThis: Boolean): KtExpression? { @@ -56,7 +63,7 @@ class KotlinSliceProvider : SliceLanguageSupportProvider { override fun getRenderer() = KotlinSliceUsageCellRenderer override fun startAnalyzeLeafValues(structure: AbstractTreeStructure, finalRunnable: Runnable) { - + leafAnalyzer.startAnalyzeValues(structure, finalRunnable) } override fun startAnalyzeNullness(structure: AbstractTreeStructure, finalRunnable: Runnable) { @@ -64,6 +71,8 @@ class KotlinSliceProvider : SliceLanguageSupportProvider { } override fun registerExtraPanelActions(group: DefaultActionGroup, builder: SliceTreeBuilder) { - + if (builder.dataFlowToThis) { + group.add(GroupByLeavesAction(builder)) + } } } \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/slicer/KotlinSliceUsage.kt b/idea/src/org/jetbrains/kotlin/idea/slicer/KotlinSliceUsage.kt index 5dc7fd131c5..cf76c9b283d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/slicer/KotlinSliceUsage.kt +++ b/idea/src/org/jetbrains/kotlin/idea/slicer/KotlinSliceUsage.kt @@ -19,10 +19,13 @@ package org.jetbrains.kotlin.idea.slicer import com.intellij.psi.PsiElement import com.intellij.slicer.SliceAnalysisParams import com.intellij.slicer.SliceUsage +import com.intellij.usageView.UsageInfo import com.intellij.util.Processor import org.jetbrains.kotlin.psi.KtExpression open class KotlinSliceUsage : SliceUsage { + class UsageInfoLambdaWrapper(element: PsiElement) : UsageInfo(element) + val lambdaLevel: Int val forcedExpressionMode: Boolean @@ -42,6 +45,18 @@ open class KotlinSliceUsage : SliceUsage { return KotlinSliceUsage(element, parent, lambdaLevel, forcedExpressionMode) } + override fun getUsageInfo(): UsageInfo { + val originalInfo = super.getUsageInfo() + if (lambdaLevel > 0 && forcedExpressionMode) { + val element = originalInfo.element ?: return originalInfo + // Do not let IDEA consider usages of the same anonymous function as duplicates when their levels differ + return UsageInfoLambdaWrapper(element) + } + return originalInfo + } + + override fun canBeLeaf() = element != null && lambdaLevel == 0 + public override fun processUsagesFlownDownTo(element: PsiElement, uniqueProcessor: Processor) { InflowSlicer(element as? KtExpression ?: return, uniqueProcessor, this).processChildren() } diff --git a/idea/testData/slicer/inflow/anonymousFunBodyExpression.leafGroups.txt b/idea/testData/slicer/inflow/anonymousFunBodyExpression.leafGroups.txt new file mode 100644 index 00000000000..5cb6b36a859 --- /dev/null +++ b/idea/testData/slicer/inflow/anonymousFunBodyExpression.leafGroups.txt @@ -0,0 +1,12 @@ +8 val x = foo(fun(n: Int) = n) +8 val x = foo(fun(n: Int) = n) +8 val x = foo(fun(n: Int) = n) +3 fun foo(f: (Int) -> Int): Int { +4 return f(1) +4 [LAMBDA] return f(1) +3 [LAMBDA] fun foo(f: (Int) -> Int): Int { +8 [LAMBDA] val x = foo(fun(n: Int) = n) +8 val x = foo(fun(n: Int) = n) +8 val x = foo(fun(n: Int) = n) +8 val x = foo(fun(n: Int) = n) + diff --git a/idea/testData/slicer/inflow/anonymousFunReturnExpression.leafGroups.txt b/idea/testData/slicer/inflow/anonymousFunReturnExpression.leafGroups.txt new file mode 100644 index 00000000000..3ec330eaae2 --- /dev/null +++ b/idea/testData/slicer/inflow/anonymousFunReturnExpression.leafGroups.txt @@ -0,0 +1,12 @@ +8 val x = foo(fun(n: Int): Int { return n }) +8 val x = foo(fun(n: Int): Int { return n }) +8 val x = foo(fun(n: Int): Int { return n }) +3 fun foo(f: (Int) -> Int): Int { +4 return f(1) +4 [LAMBDA] return f(1) +3 [LAMBDA] fun foo(f: (Int) -> Int): Int { +8 [LAMBDA] val x = foo(fun(n: Int): Int { return n }) +8 val x = foo(fun(n: Int): Int { return n }) +8 val x = foo(fun(n: Int): Int { return n }) +8 val x = foo(fun(n: Int): Int { return n }) + diff --git a/idea/testData/slicer/inflow/cast.leafGroups.txt b/idea/testData/slicer/inflow/cast.leafGroups.txt new file mode 100644 index 00000000000..f1bfddc1dd3 --- /dev/null +++ b/idea/testData/slicer/inflow/cast.leafGroups.txt @@ -0,0 +1,6 @@ +3 fun test(o: Any) { +4 val x = o as String +4 val x = o as String +4 val x = o as String +3 fun test(o: Any) { + diff --git a/idea/testData/slicer/inflow/compositeAssignments.leafGroups.txt b/idea/testData/slicer/inflow/compositeAssignments.leafGroups.txt new file mode 100644 index 00000000000..77a94ae1b4f --- /dev/null +++ b/idea/testData/slicer/inflow/compositeAssignments.leafGroups.txt @@ -0,0 +1,17 @@ +7 --result +3 fun assignmentWithSum(n: Int): Int { +8 return result +4 var result = 0 +7 --result + +4 var result = 0 +3 fun assignmentWithSum(n: Int): Int { +8 return result +4 var result = 0 +4 var result = 0 + +5 result += n +3 fun assignmentWithSum(n: Int): Int { +8 return result +4 var result = 0 +5 result += n diff --git a/idea/testData/slicer/inflow/defaultGetterFieldInSetter.leafGroups.txt b/idea/testData/slicer/inflow/defaultGetterFieldInSetter.leafGroups.txt new file mode 100644 index 00000000000..7dc418989a4 --- /dev/null +++ b/idea/testData/slicer/inflow/defaultGetterFieldInSetter.leafGroups.txt @@ -0,0 +1,14 @@ +6 field = if (b) value else 0 +10 val x = foo +4 var foo: Int +6 field = if (b) value else 0 +6 field = if (b) value else 0 + +11 foo = 1 +10 val x = foo +4 var foo: Int +6 field = if (b) value else 0 +6 field = if (b) value else 0 +5 set(value) { +11 foo = 1 + diff --git a/idea/testData/slicer/inflow/delegateGetter.leafGroups.txt b/idea/testData/slicer/inflow/delegateGetter.leafGroups.txt new file mode 100644 index 00000000000..2e65fe12825 --- /dev/null +++ b/idea/testData/slicer/inflow/delegateGetter.leafGroups.txt @@ -0,0 +1,7 @@ +6 operator fun getValue(thisRef: Any?, property: KProperty<*>) = 1 +12 val x = foo +12 val x = foo +9 val foo: Int by D +6 operator fun getValue(thisRef: Any?, property: KProperty<*>) = 1 +6 operator fun getValue(thisRef: Any?, property: KProperty<*>) = 1 + diff --git a/idea/testData/slicer/inflow/diamondHierarchyMiddleClassFun.leafGroups.txt b/idea/testData/slicer/inflow/diamondHierarchyMiddleClassFun.leafGroups.txt new file mode 100644 index 00000000000..e5207d66585 --- /dev/null +++ b/idea/testData/slicer/inflow/diamondHierarchyMiddleClassFun.leafGroups.txt @@ -0,0 +1,12 @@ +8 override fun foo() = 2 +21 val y = b.foo() +21 val y = b.foo() +8 override fun foo() = 2 +8 override fun foo() = 2 + +16 override fun foo() = 4 +21 val y = b.foo() +21 val y = b.foo() +16 override fun foo() = 4 +16 override fun foo() = 4 + diff --git a/idea/testData/slicer/inflow/diamondHierarchyMiddleInterfaceFun.leafGroups.txt b/idea/testData/slicer/inflow/diamondHierarchyMiddleInterfaceFun.leafGroups.txt new file mode 100644 index 00000000000..30f9f5bdaab --- /dev/null +++ b/idea/testData/slicer/inflow/diamondHierarchyMiddleInterfaceFun.leafGroups.txt @@ -0,0 +1,12 @@ +12 override fun foo() = 3 +22 val z = c.foo() +22 val z = c.foo() +12 override fun foo() = 3 +12 override fun foo() = 3 + +16 override fun foo() = 4 +22 val z = c.foo() +22 val z = c.foo() +16 override fun foo() = 4 +16 override fun foo() = 4 + diff --git a/idea/testData/slicer/inflow/diamondHierarchyRootInterfaceFun.leafGroups.txt b/idea/testData/slicer/inflow/diamondHierarchyRootInterfaceFun.leafGroups.txt new file mode 100644 index 00000000000..34a3dd15af3 --- /dev/null +++ b/idea/testData/slicer/inflow/diamondHierarchyRootInterfaceFun.leafGroups.txt @@ -0,0 +1,24 @@ +4 fun foo() = 1 +20 val x = a.foo() +20 val x = a.foo() +4 fun foo() = 1 +4 fun foo() = 1 + +8 override fun foo() = 2 +20 val x = a.foo() +20 val x = a.foo() +8 override fun foo() = 2 +8 override fun foo() = 2 + +12 override fun foo() = 3 +20 val x = a.foo() +20 val x = a.foo() +12 override fun foo() = 3 +12 override fun foo() = 3 + +16 override fun foo() = 4 +20 val x = a.foo() +20 val x = a.foo() +16 override fun foo() = 4 +16 override fun foo() = 4 + diff --git a/idea/testData/slicer/inflow/doubleLambdaResult.leafGroups.txt b/idea/testData/slicer/inflow/doubleLambdaResult.leafGroups.txt new file mode 100644 index 00000000000..62e8a17c198 --- /dev/null +++ b/idea/testData/slicer/inflow/doubleLambdaResult.leafGroups.txt @@ -0,0 +1,14 @@ +8 val x = foo(1, 2) { { it } } +8 val x = foo(1, 2) { { it } } +8 val x = foo(1, 2) { { it } } +3 fun foo(a: Int, b: Int, f: (Int) -> (Int) -> Int): Int { +4 return f(a)(b) +4 [LAMBDA] return f(a)(b) +4 [LAMBDA] [LAMBDA] return f(a)(b) +3 [LAMBDA] [LAMBDA] fun foo(a: Int, b: Int, f: (Int) -> (Int) -> Int): Int { +8 [LAMBDA] [LAMBDA] val x = foo(1, 2) { { it } } +8 [LAMBDA] val x = foo(1, 2) { { it } } +8 [LAMBDA] val x = foo(1, 2) { { it } } +8 val x = foo(1, 2) { { it } } +8 val x = foo(1, 2) { { it } } + diff --git a/idea/testData/slicer/inflow/funParamerer.leafGroups.txt b/idea/testData/slicer/inflow/funParamerer.leafGroups.txt new file mode 100644 index 00000000000..522fc76c838 --- /dev/null +++ b/idea/testData/slicer/inflow/funParamerer.leafGroups.txt @@ -0,0 +1,4 @@ +8 foo(1) +3 fun foo(n: Int, s: String = "???") { +8 foo(1) + diff --git a/idea/testData/slicer/inflow/funParamererWithDefault.leafGroups.txt b/idea/testData/slicer/inflow/funParamererWithDefault.leafGroups.txt new file mode 100644 index 00000000000..16aea0abbd4 --- /dev/null +++ b/idea/testData/slicer/inflow/funParamererWithDefault.leafGroups.txt @@ -0,0 +1,8 @@ +9 foo(1, "2") +3 fun foo(n: Int, s: String = "???") { +9 foo(1, "2") + +3 fun foo(n: Int, s: String = "???") { +3 fun foo(n: Int, s: String = "???") { +3 fun foo(n: Int, s: String = "???") { + diff --git a/idea/testData/slicer/inflow/funResultViaCallableRef.leafGroups.txt b/idea/testData/slicer/inflow/funResultViaCallableRef.leafGroups.txt new file mode 100644 index 00000000000..4585f605971 --- /dev/null +++ b/idea/testData/slicer/inflow/funResultViaCallableRef.leafGroups.txt @@ -0,0 +1,12 @@ +8 fun bar(n: Int) = n +9 val x = foo(::bar) +9 val x = foo(::bar) +3 fun foo(f: (Int) -> Int): Int { +4 return f(1) +4 [LAMBDA] return f(1) +3 [LAMBDA] fun foo(f: (Int) -> Int): Int { +9 [LAMBDA] val x = foo(::bar) +8 fun bar(n: Int) = n +8 fun bar(n: Int) = n +8 fun bar(n: Int) = n + diff --git a/idea/testData/slicer/inflow/funResultViaCallableRefWithAssignment.leafGroups.txt b/idea/testData/slicer/inflow/funResultViaCallableRefWithAssignment.leafGroups.txt new file mode 100644 index 00000000000..9ec414ea1f5 --- /dev/null +++ b/idea/testData/slicer/inflow/funResultViaCallableRefWithAssignment.leafGroups.txt @@ -0,0 +1,14 @@ +8 fun bar(n: Int) = n +10 val x = foo(f) +10 val x = foo(f) +3 fun foo(f: (Int) -> Int): Int { +4 return f(1) +4 [LAMBDA] return f(1) +3 [LAMBDA] fun foo(f: (Int) -> Int): Int { +10 [LAMBDA] val x = foo(f) +9 [LAMBDA] val f = ::bar +9 [LAMBDA] val f = ::bar +8 fun bar(n: Int) = n +8 fun bar(n: Int) = n +8 fun bar(n: Int) = n + diff --git a/idea/testData/slicer/inflow/funResultViaCallableRefWithDirectCall.leafGroups.txt b/idea/testData/slicer/inflow/funResultViaCallableRefWithDirectCall.leafGroups.txt new file mode 100644 index 00000000000..438da5a8c89 --- /dev/null +++ b/idea/testData/slicer/inflow/funResultViaCallableRefWithDirectCall.leafGroups.txt @@ -0,0 +1,8 @@ +4 fun bar(n: Int) = n +5 val x = (::bar)(1) +5 val x = (::bar)(1) +5 [LAMBDA] val x = (::bar)(1) +4 fun bar(n: Int) = n +4 fun bar(n: Int) = n +4 fun bar(n: Int) = n + diff --git a/idea/testData/slicer/inflow/funWithExpressionBody.leafGroups.txt b/idea/testData/slicer/inflow/funWithExpressionBody.leafGroups.txt new file mode 100644 index 00000000000..a9b007f1ff5 --- /dev/null +++ b/idea/testData/slicer/inflow/funWithExpressionBody.leafGroups.txt @@ -0,0 +1,4 @@ +3 fun foo(n: Int) = n + 1 +3 fun foo(n: Int) = n + 1 +3 fun foo(n: Int) = n + 1 + diff --git a/idea/testData/slicer/inflow/funWithReturnExpressions.leafGroups.txt b/idea/testData/slicer/inflow/funWithReturnExpressions.leafGroups.txt new file mode 100644 index 00000000000..693e710fc7c --- /dev/null +++ b/idea/testData/slicer/inflow/funWithReturnExpressions.leafGroups.txt @@ -0,0 +1,9 @@ +5 return -n +3 fun foo(n: Int): Int { +5 return -n + +3 fun foo(n: Int): Int { +3 fun foo(n: Int): Int { +4 if (n > 0) return n +3 fun foo(n: Int): Int { + diff --git a/idea/testData/slicer/inflow/getterAndSetterUsingField.leafGroups.txt b/idea/testData/slicer/inflow/getterAndSetterUsingField.leafGroups.txt new file mode 100644 index 00000000000..d31f8a7664b --- /dev/null +++ b/idea/testData/slicer/inflow/getterAndSetterUsingField.leafGroups.txt @@ -0,0 +1,18 @@ +7 field = if (b) value else 0 +11 val x = foo +4 var foo: Int +5 get() = if (b) field else 0 +5 get() = if (b) field else 0 +7 field = if (b) value else 0 +7 field = if (b) value else 0 + +12 foo = 1 +11 val x = foo +4 var foo: Int +5 get() = if (b) field else 0 +5 get() = if (b) field else 0 +7 field = if (b) value else 0 +7 field = if (b) value else 0 +6 set(value) { +12 foo = 1 + diff --git a/idea/testData/slicer/inflow/getterExpressionBody.leafGroups.txt b/idea/testData/slicer/inflow/getterExpressionBody.leafGroups.txt new file mode 100644 index 00000000000..4b6b2771561 --- /dev/null +++ b/idea/testData/slicer/inflow/getterExpressionBody.leafGroups.txt @@ -0,0 +1,6 @@ +4 get() = 0 +7 val x = foo +7 val x = foo +3 val foo: Int +4 get() = 0 + diff --git a/idea/testData/slicer/inflow/getterReturnExpression.leafGroups.txt b/idea/testData/slicer/inflow/getterReturnExpression.leafGroups.txt new file mode 100644 index 00000000000..462676a98b7 --- /dev/null +++ b/idea/testData/slicer/inflow/getterReturnExpression.leafGroups.txt @@ -0,0 +1,6 @@ +5 return 0 +9 val x = foo +9 val x = foo +3 val foo: Int +5 return 0 + diff --git a/idea/testData/slicer/inflow/ifExpression.leafGroups.txt b/idea/testData/slicer/inflow/ifExpression.leafGroups.txt new file mode 100644 index 00000000000..7461694b02b --- /dev/null +++ b/idea/testData/slicer/inflow/ifExpression.leafGroups.txt @@ -0,0 +1,11 @@ +3 fun test(m: Int, n: Int) { +4 val x = if (m > 1) n else 1 +4 val x = if (m > 1) n else 1 +4 val x = if (m > 1) n else 1 +3 fun test(m: Int, n: Int) { + +4 val x = if (m > 1) n else 1 +4 val x = if (m > 1) n else 1 +4 val x = if (m > 1) n else 1 +4 val x = if (m > 1) n else 1 + diff --git a/idea/testData/slicer/inflow/lambdaResult.leafGroups.txt b/idea/testData/slicer/inflow/lambdaResult.leafGroups.txt new file mode 100644 index 00000000000..b087d61984a --- /dev/null +++ b/idea/testData/slicer/inflow/lambdaResult.leafGroups.txt @@ -0,0 +1,11 @@ +8 val x = foo { it } +8 val x = foo { it } +8 val x = foo { it } +3 fun foo(f: (Int) -> Int): Int { +4 return f(1) +4 [LAMBDA] return f(1) +3 [LAMBDA] fun foo(f: (Int) -> Int): Int { +8 [LAMBDA] val x = foo { it } +8 val x = foo { it } +8 val x = foo { it } + diff --git a/idea/testData/slicer/inflow/lambdaResultWithAssignments.leafGroups.txt b/idea/testData/slicer/inflow/lambdaResultWithAssignments.leafGroups.txt new file mode 100644 index 00000000000..2d31c99ed33 --- /dev/null +++ b/idea/testData/slicer/inflow/lambdaResultWithAssignments.leafGroups.txt @@ -0,0 +1,13 @@ +9 val y = foo { it } +9 val y = foo { it } +9 val y = foo { it } +3 fun foo(f: (Int) -> Int): Int { +5 return x(1) +5 [LAMBDA] return x(1) +4 [LAMBDA] val x = f +4 [LAMBDA] val x = f +3 [LAMBDA] fun foo(f: (Int) -> Int): Int { +9 [LAMBDA] val y = foo { it } +9 val y = foo { it } +9 val y = foo { it } + diff --git a/idea/testData/slicer/inflow/lambdaResultWithDirectCall.leafGroups.txt b/idea/testData/slicer/inflow/lambdaResultWithDirectCall.leafGroups.txt new file mode 100644 index 00000000000..bc3ef25b42a --- /dev/null +++ b/idea/testData/slicer/inflow/lambdaResultWithDirectCall.leafGroups.txt @@ -0,0 +1,7 @@ +4 val x = { 1 }() +4 val x = { 1 }() +4 val x = { 1 }() +4 [LAMBDA] val x = { 1 }() +4 val x = { 1 }() +4 val x = { 1 }() + diff --git a/idea/testData/slicer/inflow/lambdaResultWithDirectCallViaAssignment.leafGroups.txt b/idea/testData/slicer/inflow/lambdaResultWithDirectCallViaAssignment.leafGroups.txt new file mode 100644 index 00000000000..de67d850593 --- /dev/null +++ b/idea/testData/slicer/inflow/lambdaResultWithDirectCallViaAssignment.leafGroups.txt @@ -0,0 +1,9 @@ +4 val f = { 1 } +5 val x = f() +5 val x = f() +5 [LAMBDA] val x = f() +4 [LAMBDA] val f = { 1 } +4 [LAMBDA] val f = { 1 } +4 val f = { 1 } +4 val f = { 1 } + diff --git a/idea/testData/slicer/inflow/localVal.leafGroups.txt b/idea/testData/slicer/inflow/localVal.leafGroups.txt new file mode 100644 index 00000000000..b73b7e0a974 --- /dev/null +++ b/idea/testData/slicer/inflow/localVal.leafGroups.txt @@ -0,0 +1,5 @@ +3 fun test(n: Int) { +4 val x = n +4 val x = n +3 fun test(n: Int) { + diff --git a/idea/testData/slicer/inflow/localVar.leafGroups.txt b/idea/testData/slicer/inflow/localVar.leafGroups.txt new file mode 100644 index 00000000000..3161578aec9 --- /dev/null +++ b/idea/testData/slicer/inflow/localVar.leafGroups.txt @@ -0,0 +1,9 @@ +3 fun test(n: Int) { +4 var x = n +4 var x = n +3 fun test(n: Int) { + +6 x = 0 +4 var x = n +6 x = 0 + diff --git a/idea/testData/slicer/inflow/memberValWithInitializer.leafGroups.txt b/idea/testData/slicer/inflow/memberValWithInitializer.leafGroups.txt new file mode 100644 index 00000000000..4842215e6b3 --- /dev/null +++ b/idea/testData/slicer/inflow/memberValWithInitializer.leafGroups.txt @@ -0,0 +1,4 @@ +4 val x: Int = 1 +4 val x: Int = 1 +4 val x: Int = 1 + diff --git a/idea/testData/slicer/inflow/memberValWithSplitInitializer.leafGroups.txt b/idea/testData/slicer/inflow/memberValWithSplitInitializer.leafGroups.txt new file mode 100644 index 00000000000..04a87251bb6 --- /dev/null +++ b/idea/testData/slicer/inflow/memberValWithSplitInitializer.leafGroups.txt @@ -0,0 +1,4 @@ +7 x = 1 +4 val x: Int +7 x = 1 + diff --git a/idea/testData/slicer/inflow/memberVarWithInitializer.leafGroups.txt b/idea/testData/slicer/inflow/memberVarWithInitializer.leafGroups.txt new file mode 100644 index 00000000000..4b58ad03385 --- /dev/null +++ b/idea/testData/slicer/inflow/memberVarWithInitializer.leafGroups.txt @@ -0,0 +1,8 @@ +4 var x: Int = 1 +4 var x: Int = 1 +4 var x: Int = 1 + +9 x = 2 +4 var x: Int = 1 +9 x = 2 + diff --git a/idea/testData/slicer/inflow/memberVarWithSplitInitializer.leafGroups.txt b/idea/testData/slicer/inflow/memberVarWithSplitInitializer.leafGroups.txt new file mode 100644 index 00000000000..a0cc659b542 --- /dev/null +++ b/idea/testData/slicer/inflow/memberVarWithSplitInitializer.leafGroups.txt @@ -0,0 +1,8 @@ +7 x = 1 +4 var x: Int +7 x = 1 + +14 x = 2 +4 var x: Int +14 x = 2 + diff --git a/idea/testData/slicer/inflow/noFieldInGetter.leafGroups.txt b/idea/testData/slicer/inflow/noFieldInGetter.leafGroups.txt new file mode 100644 index 00000000000..472677c44ab --- /dev/null +++ b/idea/testData/slicer/inflow/noFieldInGetter.leafGroups.txt @@ -0,0 +1,5 @@ +5 get() = 1 +11 val x = foo +4 var foo: Int +5 get() = 1 + diff --git a/idea/testData/slicer/inflow/nonLocalReturn.leafGroups.txt b/idea/testData/slicer/inflow/nonLocalReturn.leafGroups.txt new file mode 100644 index 00000000000..a9af915157d --- /dev/null +++ b/idea/testData/slicer/inflow/nonLocalReturn.leafGroups.txt @@ -0,0 +1,16 @@ +5 fun bar(a: Int): Int = foo(a) { if (it > 0) it else return 0 } +5 fun bar(a: Int): Int = foo(a) { if (it > 0) it else return 0 } +5 fun bar(a: Int): Int = foo(a) { if (it > 0) it else return 0 } +3 inline fun foo(a: Int, f: (Int) -> Int) = f(a) +3 inline fun foo(a: Int, f: (Int) -> Int) = f(a) +3 [LAMBDA] inline fun foo(a: Int, f: (Int) -> Int) = f(a) +3 [LAMBDA] inline fun foo(a: Int, f: (Int) -> Int) = f(a) +5 [LAMBDA] fun bar(a: Int): Int = foo(a) { if (it > 0) it else return 0 } +5 fun bar(a: Int): Int = foo(a) { if (it > 0) it else return 0 } +5 fun bar(a: Int): Int = foo(a) { if (it > 0) it else return 0 } +5 fun bar(a: Int): Int = foo(a) { if (it > 0) it else return 0 } + +5 fun bar(a: Int): Int = foo(a) { if (it > 0) it else return 0 } +5 fun bar(a: Int): Int = foo(a) { if (it > 0) it else return 0 } +5 fun bar(a: Int): Int = foo(a) { if (it > 0) it else return 0 } + diff --git a/idea/testData/slicer/inflow/notNullAssertion.leafGroups.txt b/idea/testData/slicer/inflow/notNullAssertion.leafGroups.txt new file mode 100644 index 00000000000..e657a597ff7 --- /dev/null +++ b/idea/testData/slicer/inflow/notNullAssertion.leafGroups.txt @@ -0,0 +1,6 @@ +3 fun test(s: String?) { +4 val x = s!! +4 val x = s!! +4 val x = s!! +3 fun test(s: String?) { + diff --git a/idea/testData/slicer/inflow/overridingFunctionResult.leafGroups.txt b/idea/testData/slicer/inflow/overridingFunctionResult.leafGroups.txt new file mode 100644 index 00000000000..c15a95bd653 --- /dev/null +++ b/idea/testData/slicer/inflow/overridingFunctionResult.leafGroups.txt @@ -0,0 +1,12 @@ +8 override fun foo() = 2 +17 val y = b.foo() +17 val y = b.foo() +8 override fun foo() = 2 +8 override fun foo() = 2 + +12 override fun foo() = 3 +17 val y = b.foo() +17 val y = b.foo() +12 override fun foo() = 3 +12 override fun foo() = 3 + diff --git a/idea/testData/slicer/inflow/overridingParameter.leafGroups.txt b/idea/testData/slicer/inflow/overridingParameter.leafGroups.txt new file mode 100644 index 00000000000..bf2c9d42b27 --- /dev/null +++ b/idea/testData/slicer/inflow/overridingParameter.leafGroups.txt @@ -0,0 +1,11 @@ +7 open class B(override val foo: Int) : A() +15 val y = b.foo +15 val y = b.foo +7 open class B(override val foo: Int) : A() + +10 override val foo = 3 +15 val y = b.foo +15 val y = b.foo +10 override val foo = 3 +10 override val foo = 3 + diff --git a/idea/testData/slicer/inflow/overridingPropertyGetterResult.leafGroups.txt b/idea/testData/slicer/inflow/overridingPropertyGetterResult.leafGroups.txt new file mode 100644 index 00000000000..17726de11f4 --- /dev/null +++ b/idea/testData/slicer/inflow/overridingPropertyGetterResult.leafGroups.txt @@ -0,0 +1,12 @@ +10 get() = 2 +20 val y = b.foo +20 val y = b.foo +9 override val foo: Int +10 get() = 2 + +15 get() = 3 +20 val y = b.foo +20 val y = b.foo +14 override val foo: Int +15 get() = 3 + diff --git a/idea/testData/slicer/inflow/overridingPropertyResult.leafGroups.txt b/idea/testData/slicer/inflow/overridingPropertyResult.leafGroups.txt new file mode 100644 index 00000000000..2a7b2ca8155 --- /dev/null +++ b/idea/testData/slicer/inflow/overridingPropertyResult.leafGroups.txt @@ -0,0 +1,12 @@ +8 override val foo = 2 +17 val y = b.foo +17 val y = b.foo +8 override val foo = 2 +8 override val foo = 2 + +12 override val foo = 3 +17 val y = b.foo +17 val y = b.foo +12 override val foo = 3 +12 override val foo = 3 + diff --git a/idea/testData/slicer/inflow/primaryConstructorParameter.leafGroups.txt b/idea/testData/slicer/inflow/primaryConstructorParameter.leafGroups.txt new file mode 100644 index 00000000000..bf5e449eadc --- /dev/null +++ b/idea/testData/slicer/inflow/primaryConstructorParameter.leafGroups.txt @@ -0,0 +1,4 @@ +5 class B1: A(1) +3 open class A(n: Int, s: String = "???") +5 class B1: A(1) + diff --git a/idea/testData/slicer/inflow/primaryConstructorParameterWithDefault.leafGroups.txt b/idea/testData/slicer/inflow/primaryConstructorParameterWithDefault.leafGroups.txt new file mode 100644 index 00000000000..069ec782427 --- /dev/null +++ b/idea/testData/slicer/inflow/primaryConstructorParameterWithDefault.leafGroups.txt @@ -0,0 +1,8 @@ +6 class B2: A(1, "2") +3 open class A(n: Int, s: String = "???") +6 class B2: A(1, "2") + +3 open class A(n: Int, s: String = "???") +3 open class A(n: Int, s: String = "???") +3 open class A(n: Int, s: String = "???") + diff --git a/idea/testData/slicer/inflow/qualifiedAssignmentsForQualifiedRef.leafGroups.txt b/idea/testData/slicer/inflow/qualifiedAssignmentsForQualifiedRef.leafGroups.txt new file mode 100644 index 00000000000..56c3ddbe824 --- /dev/null +++ b/idea/testData/slicer/inflow/qualifiedAssignmentsForQualifiedRef.leafGroups.txt @@ -0,0 +1,21 @@ +13 val a = AClass("main: hello") +15 println("Now my name is '${a.name}'") +4 var name : String = name1 +4 var name : String = name1 +3 class AClass(name1: String){ +13 val a = AClass("main: hello") + +14 a.name = "main: bye" +15 println("Now my name is '${a.name}'") +4 var name : String = name1 +14 a.name = "main: bye" + +6 name = "uses: bye" +15 println("Now my name is '${a.name}'") +4 var name : String = name1 +6 name = "uses: bye" + +7 this.name = "uses: after this" +15 println("Now my name is '${a.name}'") +4 var name : String = name1 +7 this.name = "uses: after this" diff --git a/idea/testData/slicer/inflow/qualifiedAssignmentsForSimpleRef.leafGroups.txt b/idea/testData/slicer/inflow/qualifiedAssignmentsForSimpleRef.leafGroups.txt new file mode 100644 index 00000000000..b0f7bdd8861 --- /dev/null +++ b/idea/testData/slicer/inflow/qualifiedAssignmentsForSimpleRef.leafGroups.txt @@ -0,0 +1,21 @@ +13 val a = AClass("main: hello") +8 println("And now my name is '$name'") +4 var name : String = name1 +4 var name : String = name1 +3 class AClass(name1: String){ +13 val a = AClass("main: hello") + +14 a.name = "main: bye" +8 println("And now my name is '$name'") +4 var name : String = name1 +14 a.name = "main: bye" + +6 name = "uses: bye" +8 println("And now my name is '$name'") +4 var name : String = name1 +6 name = "uses: bye" + +7 this.name = "uses: after this" +8 println("And now my name is '$name'") +4 var name : String = name1 +7 this.name = "uses: after this" diff --git a/idea/testData/slicer/inflow/safeCast.leafGroups.txt b/idea/testData/slicer/inflow/safeCast.leafGroups.txt new file mode 100644 index 00000000000..ed1d77f390c --- /dev/null +++ b/idea/testData/slicer/inflow/safeCast.leafGroups.txt @@ -0,0 +1,6 @@ +3 fun test(o: Any) { +4 val x = o as? String +4 val x = o as? String +4 val x = o as? String +3 fun test(o: Any) { + diff --git a/idea/testData/slicer/inflow/secondaryConstructorParameter.leafGroups.txt b/idea/testData/slicer/inflow/secondaryConstructorParameter.leafGroups.txt new file mode 100644 index 00000000000..6270f30b3e8 --- /dev/null +++ b/idea/testData/slicer/inflow/secondaryConstructorParameter.leafGroups.txt @@ -0,0 +1,4 @@ +7 class B1: A(1) +4 constructor(n: Int, s: String = "???") +7 class B1: A(1) + diff --git a/idea/testData/slicer/inflow/secondaryConstructorParameterWithDefault.leafGroups.txt b/idea/testData/slicer/inflow/secondaryConstructorParameterWithDefault.leafGroups.txt new file mode 100644 index 00000000000..5e8e7fdabb1 --- /dev/null +++ b/idea/testData/slicer/inflow/secondaryConstructorParameterWithDefault.leafGroups.txt @@ -0,0 +1,8 @@ +8 class B2: A(1, "2") +4 constructor(n: Int, s: String = "???") +8 class B2: A(1, "2") + +4 constructor(n: Int, s: String = "???") +4 constructor(n: Int, s: String = "???") +4 constructor(n: Int, s: String = "???") + diff --git a/idea/testData/slicer/inflow/settersViaDelegateForQualifiedRef.leafGroups.txt b/idea/testData/slicer/inflow/settersViaDelegateForQualifiedRef.leafGroups.txt new file mode 100644 index 00000000000..7b6728cb82a --- /dev/null +++ b/idea/testData/slicer/inflow/settersViaDelegateForQualifiedRef.leafGroups.txt @@ -0,0 +1,29 @@ +4 private var _value: String = "" +25 println("My name is '${a.name}'") +12 var name by Delegate() +5 operator fun getValue(thisRef: Any?, property: KProperty<*>) = _value +5 operator fun getValue(thisRef: Any?, property: KProperty<*>) = _value +4 private var _value: String = "" +4 private var _value: String = "" + +18 name = "bye" +25 println("My name is '${a.name}'") +12 var name by Delegate() +5 operator fun getValue(thisRef: Any?, property: KProperty<*>) = _value +5 operator fun getValue(thisRef: Any?, property: KProperty<*>) = _value +4 private var _value: String = "" +7 _value = value +6 operator fun setValue(thisRef: Any?, property: KProperty<*>, value: String) { +18 name = "bye" + +24 val a = AClass("hello") +25 println("My name is '${a.name}'") +12 var name by Delegate() +5 operator fun getValue(thisRef: Any?, property: KProperty<*>) = _value +5 operator fun getValue(thisRef: Any?, property: KProperty<*>) = _value +4 private var _value: String = "" +7 _value = value +6 operator fun setValue(thisRef: Any?, property: KProperty<*>, value: String) { +14 name = name1 +11 class AClass(name1: String){ +24 val a = AClass("hello") diff --git a/idea/testData/slicer/inflow/settersViaDelegateForSimpleRef.leafGroups.txt b/idea/testData/slicer/inflow/settersViaDelegateForSimpleRef.leafGroups.txt new file mode 100644 index 00000000000..8c9dccb835b --- /dev/null +++ b/idea/testData/slicer/inflow/settersViaDelegateForSimpleRef.leafGroups.txt @@ -0,0 +1,29 @@ +4 private var _value: String = "" +19 println("Now my name is '$name'") +12 var name by Delegate() +5 operator fun getValue(thisRef: Any?, property: KProperty<*>) = _value +5 operator fun getValue(thisRef: Any?, property: KProperty<*>) = _value +4 private var _value: String = "" +4 private var _value: String = "" + +18 name = "bye" +19 println("Now my name is '$name'") +12 var name by Delegate() +5 operator fun getValue(thisRef: Any?, property: KProperty<*>) = _value +5 operator fun getValue(thisRef: Any?, property: KProperty<*>) = _value +4 private var _value: String = "" +7 _value = value +6 operator fun setValue(thisRef: Any?, property: KProperty<*>, value: String) { +18 name = "bye" + +24 val a = AClass("hello") +19 println("Now my name is '$name'") +12 var name by Delegate() +5 operator fun getValue(thisRef: Any?, property: KProperty<*>) = _value +5 operator fun getValue(thisRef: Any?, property: KProperty<*>) = _value +4 private var _value: String = "" +7 _value = value +6 operator fun setValue(thisRef: Any?, property: KProperty<*>, value: String) { +14 name = name1 +11 class AClass(name1: String){ +24 val a = AClass("hello") diff --git a/idea/testData/slicer/inflow/topLevelVal.leafGroups.txt b/idea/testData/slicer/inflow/topLevelVal.leafGroups.txt new file mode 100644 index 00000000000..6f666e91846 --- /dev/null +++ b/idea/testData/slicer/inflow/topLevelVal.leafGroups.txt @@ -0,0 +1,4 @@ +3 val foo: Int = 1 +3 val foo: Int = 1 +3 val foo: Int = 1 + diff --git a/idea/testData/slicer/inflow/topLevelVar.leafGroups.txt b/idea/testData/slicer/inflow/topLevelVar.leafGroups.txt new file mode 100644 index 00000000000..e48dcf25c6b --- /dev/null +++ b/idea/testData/slicer/inflow/topLevelVar.leafGroups.txt @@ -0,0 +1,8 @@ +3 var foo: Int = 1 +3 var foo: Int = 1 +3 var foo: Int = 1 + +7 foo = 2 +3 var foo: Int = 1 +7 foo = 2 + diff --git a/idea/testData/slicer/inflow/valParameter.leafGroups.txt b/idea/testData/slicer/inflow/valParameter.leafGroups.txt new file mode 100644 index 00000000000..8c98dea6875 --- /dev/null +++ b/idea/testData/slicer/inflow/valParameter.leafGroups.txt @@ -0,0 +1,8 @@ +5 class B : A(1) +3 open class A(val n: Int) +5 class B : A(1) + +8 val z = A(2).n +3 open class A(val n: Int) +8 val z = A(2).n + diff --git a/idea/testData/slicer/inflow/varParameter.leafGroups.txt b/idea/testData/slicer/inflow/varParameter.leafGroups.txt new file mode 100644 index 00000000000..5d90f9c4d70 --- /dev/null +++ b/idea/testData/slicer/inflow/varParameter.leafGroups.txt @@ -0,0 +1,12 @@ +20 class B : A(1) +3 open class A(var n: Int) { +20 class B : A(1) + +23 val z = A(2).n +3 open class A(var n: Int) { +23 val z = A(2).n + +24 A(3).n = 2 +3 open class A(var n: Int) { +24 A(3).n = 2 + diff --git a/idea/testData/slicer/inflow/whenExpression.leafGroups.txt b/idea/testData/slicer/inflow/whenExpression.leafGroups.txt new file mode 100644 index 00000000000..b2d94154450 --- /dev/null +++ b/idea/testData/slicer/inflow/whenExpression.leafGroups.txt @@ -0,0 +1,16 @@ +3 fun test(m: Int, n: Int) { +4 val x = when (m) { +4 val x = when (m) { +6 2 -> n +3 fun test(m: Int, n: Int) { + +7 else -> 0 +4 val x = when (m) { +4 val x = when (m) { +7 else -> 0 + +5 1 -> 1 +4 val x = when (m) { +4 val x = when (m) { +5 1 -> 1 + diff --git a/idea/tests/org/jetbrains/kotlin/idea/slicer/AbstractSlicerLeafGroupingTest.kt b/idea/tests/org/jetbrains/kotlin/idea/slicer/AbstractSlicerLeafGroupingTest.kt new file mode 100644 index 00000000000..dc59b356b17 --- /dev/null +++ b/idea/tests/org/jetbrains/kotlin/idea/slicer/AbstractSlicerLeafGroupingTest.kt @@ -0,0 +1,38 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea.slicer + +import com.intellij.slicer.SliceRootNode +import org.jetbrains.kotlin.test.KotlinTestUtils +import java.io.File + +abstract class AbstractSlicerLeafGroupingTest : AbstractSlicerTest() { + override fun doTest(path: String, sliceProvider: KotlinSliceProvider, rootNode: SliceRootNode) { + val treeStructure = SliceTreeStructure(rootNode) + val analyzer = sliceProvider.leafAnalyzer + val possibleElementsByNode = analyzer.createMap() + val leafExpressions = analyzer.calcLeafExpressions(rootNode, treeStructure, possibleElementsByNode) + val newRootNode = analyzer.createTreeGroupedByValues(leafExpressions, rootNode, possibleElementsByNode) + val renderedForest = buildString { + for (groupRootNode in newRootNode.children) { + append(buildTreeRepresentation(groupRootNode)) + append("\n") + } + } + KotlinTestUtils.assertEqualsToFile(File(path.replace(".kt", ".leafGroups.txt")), renderedForest) + } +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/slicer/AbstractSlicerTest.kt b/idea/tests/org/jetbrains/kotlin/idea/slicer/AbstractSlicerTest.kt index f1c26f1d9b4..58539af8dc3 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/slicer/AbstractSlicerTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/slicer/AbstractSlicerTest.kt @@ -17,16 +17,15 @@ package org.jetbrains.kotlin.idea.slicer import com.intellij.analysis.AnalysisScope +import com.intellij.ide.projectView.TreeStructureProvider +import com.intellij.ide.util.treeView.AbstractTreeStructureBase import com.intellij.openapi.util.io.FileUtil +import com.intellij.slicer.DuplicateMap import com.intellij.slicer.SliceAnalysisParams -import com.intellij.slicer.SliceUsage +import com.intellij.slicer.SliceNode +import com.intellij.slicer.SliceRootNode import com.intellij.usages.TextChunk -import com.intellij.util.CommonProcessors -import com.intellij.util.Processor -import gnu.trove.THashSet -import gnu.trove.TObjectHashingStrategy import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase -import org.jetbrains.kotlin.idea.util.application.runReadAction import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.test.InTextDirectivesUtils import org.jetbrains.kotlin.test.KotlinTestUtils @@ -34,80 +33,70 @@ import java.awt.Font import java.io.File abstract class AbstractSlicerTest : KotlinLightCodeInsightFixtureTestCase() { - object SliceUsageHashingStrategy : TObjectHashingStrategy { - override fun computeHashCode(`object`: KotlinSliceUsage): Int { - return `object`.usageInfo.hashCode() * 31 + `object`.forcedExpressionMode.hashCode() + protected class SliceTreeStructure(private val rootNode: SliceNode) : AbstractTreeStructureBase(rootNode.project) { + override fun getProviders(): List? = emptyList() + + override fun getRootElement() = rootNode + + override fun commit() { + } - override fun equals(o1: KotlinSliceUsage, o2: KotlinSliceUsage): Boolean { - return o1.usageInfo == o2.usageInfo && o1.forcedExpressionMode == o2.forcedExpressionMode - } + override fun hasSomethingToCommit() = false } - // Based on SliceUsage.processChildren - private fun KotlinSliceUsage.processChildrenWithoutProgress(processor: (KotlinSliceUsage) -> Unit) { - if (this is KotlinSliceDereferenceUsage) return - - val element = runReadAction { element } - - @Suppress("UNCHECKED_CAST") - val uniqueProcessor = CommonProcessors.UniqueProcessor( - { - processor(it as KotlinSliceUsage) - true - }, - SliceUsageHashingStrategy - ) as Processor - - runReadAction { - if (params.dataFlowToThis) { - processUsagesFlownDownTo(element, uniqueProcessor) - } - else { - processUsagesFlownFromThe(element, uniqueProcessor) - } - } - } - - private fun buildTreeRepresentation(rootUsage: KotlinSliceUsage): String { - val visitedUsages = THashSet(SliceUsageHashingStrategy) - - fun TextChunk.render(): String { - var text = text - if (attributes.fontType == Font.BOLD) { - text = "$text" - } - return text - } - - fun process(usage: KotlinSliceUsage, indent: Int): String { - val isDuplicated = !visitedUsages.add(usage) - - return buildString { - val chunks = usage.text - append(chunks.first().render() + " ") - append("\t".repeat(indent)) - if (usage is KotlinSliceDereferenceUsage) { - append("DEREFERENCE: ") + companion object { + @JvmStatic + protected fun buildTreeRepresentation(rootNode: SliceNode): String { + fun TextChunk.render(): String { + var text = text + if (attributes.fontType == Font.BOLD) { + text = "$text" } - append("[LAMBDA] ".repeat(usage.lambdaLevel)) - chunks.slice(1..chunks.size - 1).joinTo( - this, - separator = "", - prefix = if (isDuplicated) "DUPLICATE: " else "", - postfix = "\n" - ) { it.render() } - if (!isDuplicated) { - usage.processChildrenWithoutProgress { - append(process(it, indent + 1)) + return text + } + + fun process(node: SliceNode, indent: Int): String { + val usage = node.element!!.value as KotlinSliceUsage + + node.calculateDupNode() + val isDuplicated = node.duplicate != null + + return buildString { + when { + node is SliceRootNode && usage.element is KtFile -> { + node.children.forEach { append(process(it, indent)) } + return@buildString + } + else -> { + val chunks = usage.text + append(chunks.first().render() + " ") + append("\t".repeat(indent)) + if (usage is KotlinSliceDereferenceUsage) { + append("DEREFERENCE: ") + } + append("[LAMBDA] ".repeat(usage.lambdaLevel)) + chunks.slice(1..chunks.size - 1).joinTo( + this, + separator = "", + prefix = if (isDuplicated) "DUPLICATE: " else "", + postfix = "\n" + ) { it.render() } + } } - } - }.replace(Regex(""), "") - } - return process(rootUsage, 0) + if (!isDuplicated) { + node.children.forEach { append(process(it, indent + 1)) } + } + }.replace(Regex(""), "") + } + + return process(rootNode, 0) + } } + protected abstract fun doTest(path: String, sliceProvider: KotlinSliceProvider, rootNode: SliceRootNode) + protected fun doTest(path: String) { val mainFile = File(path) @@ -131,6 +120,7 @@ abstract class AbstractSlicerTest : KotlinLightCodeInsightFixtureTestCase() { val sliceProvider = KotlinSliceProvider() val expression = sliceProvider.getExpressionAtCaret(elementAtCaret, analysisParams.dataFlowToThis)!! val rootUsage = sliceProvider.createRootUsage(expression, analysisParams) - KotlinTestUtils.assertEqualsToFile(File(path.replace(".kt", ".results.txt")), buildTreeRepresentation(rootUsage)) + val rootNode = SliceRootNode(project, DuplicateMap(), rootUsage) + doTest(path, sliceProvider, rootNode) } } \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/slicer/AbstractSlicerTreeTest.kt b/idea/tests/org/jetbrains/kotlin/idea/slicer/AbstractSlicerTreeTest.kt new file mode 100644 index 00000000000..168e1bc8405 --- /dev/null +++ b/idea/tests/org/jetbrains/kotlin/idea/slicer/AbstractSlicerTreeTest.kt @@ -0,0 +1,27 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea.slicer + +import com.intellij.slicer.SliceRootNode +import org.jetbrains.kotlin.test.KotlinTestUtils +import java.io.File + +abstract class AbstractSlicerTreeTest : AbstractSlicerTest() { + override fun doTest(path: String, sliceProvider: KotlinSliceProvider, rootNode: SliceRootNode) { + KotlinTestUtils.assertEqualsToFile(File(path.replace(".kt", ".results.txt")), buildTreeRepresentation(rootNode)) + } +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/slicer/SlicerLeafGroupingTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/slicer/SlicerLeafGroupingTestGenerated.java new file mode 100644 index 00000000000..00cde0b5549 --- /dev/null +++ b/idea/tests/org/jetbrains/kotlin/idea/slicer/SlicerLeafGroupingTestGenerated.java @@ -0,0 +1,350 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea.slicer; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.TargetBackend; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("idea/testData/slicer/inflow") +@TestDataPath("$PROJECT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +public class SlicerLeafGroupingTestGenerated extends AbstractSlicerLeafGroupingTest { + public void testAllFilesPresentInSlicer() throws Exception { + KotlinTestUtils.assertAllTestsPresentInSingleGeneratedClass(this.getClass(), new File("idea/testData/slicer/inflow"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY); + } + + @TestMetadata("anonymousFunBodyExpression.kt") + public void testInflow_AnonymousFunBodyExpression() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/anonymousFunBodyExpression.kt"); + doTest(fileName); + } + + @TestMetadata("anonymousFunReturnExpression.kt") + public void testInflow_AnonymousFunReturnExpression() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/anonymousFunReturnExpression.kt"); + doTest(fileName); + } + + @TestMetadata("cast.kt") + public void testInflow_Cast() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/cast.kt"); + doTest(fileName); + } + + @TestMetadata("compositeAssignments.kt") + public void testInflow_CompositeAssignments() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/compositeAssignments.kt"); + doTest(fileName); + } + + @TestMetadata("defaultGetterFieldInSetter.kt") + public void testInflow_DefaultGetterFieldInSetter() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/defaultGetterFieldInSetter.kt"); + doTest(fileName); + } + + @TestMetadata("delegateGetter.kt") + public void testInflow_DelegateGetter() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/delegateGetter.kt"); + doTest(fileName); + } + + @TestMetadata("diamondHierarchyMiddleClassFun.kt") + public void testInflow_DiamondHierarchyMiddleClassFun() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/diamondHierarchyMiddleClassFun.kt"); + doTest(fileName); + } + + @TestMetadata("diamondHierarchyMiddleInterfaceFun.kt") + public void testInflow_DiamondHierarchyMiddleInterfaceFun() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/diamondHierarchyMiddleInterfaceFun.kt"); + doTest(fileName); + } + + @TestMetadata("diamondHierarchyRootInterfaceFun.kt") + public void testInflow_DiamondHierarchyRootInterfaceFun() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/diamondHierarchyRootInterfaceFun.kt"); + doTest(fileName); + } + + @TestMetadata("doubleLambdaResult.kt") + public void testInflow_DoubleLambdaResult() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/doubleLambdaResult.kt"); + doTest(fileName); + } + + @TestMetadata("funParamerer.kt") + public void testInflow_FunParamerer() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/funParamerer.kt"); + doTest(fileName); + } + + @TestMetadata("funParamererWithDefault.kt") + public void testInflow_FunParamererWithDefault() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/funParamererWithDefault.kt"); + doTest(fileName); + } + + @TestMetadata("funResultViaCallableRef.kt") + public void testInflow_FunResultViaCallableRef() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/funResultViaCallableRef.kt"); + doTest(fileName); + } + + @TestMetadata("funResultViaCallableRefWithAssignment.kt") + public void testInflow_FunResultViaCallableRefWithAssignment() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/funResultViaCallableRefWithAssignment.kt"); + doTest(fileName); + } + + @TestMetadata("funResultViaCallableRefWithDirectCall.kt") + public void testInflow_FunResultViaCallableRefWithDirectCall() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/funResultViaCallableRefWithDirectCall.kt"); + doTest(fileName); + } + + @TestMetadata("funWithExpressionBody.kt") + public void testInflow_FunWithExpressionBody() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/funWithExpressionBody.kt"); + doTest(fileName); + } + + @TestMetadata("funWithReturnExpressions.kt") + public void testInflow_FunWithReturnExpressions() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/funWithReturnExpressions.kt"); + doTest(fileName); + } + + @TestMetadata("getterAndSetterUsingField.kt") + public void testInflow_GetterAndSetterUsingField() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/getterAndSetterUsingField.kt"); + doTest(fileName); + } + + @TestMetadata("getterExpressionBody.kt") + public void testInflow_GetterExpressionBody() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/getterExpressionBody.kt"); + doTest(fileName); + } + + @TestMetadata("getterReturnExpression.kt") + public void testInflow_GetterReturnExpression() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/getterReturnExpression.kt"); + doTest(fileName); + } + + @TestMetadata("ifExpression.kt") + public void testInflow_IfExpression() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/ifExpression.kt"); + doTest(fileName); + } + + @TestMetadata("lambdaResult.kt") + public void testInflow_LambdaResult() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/lambdaResult.kt"); + doTest(fileName); + } + + @TestMetadata("lambdaResultWithAssignments.kt") + public void testInflow_LambdaResultWithAssignments() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/lambdaResultWithAssignments.kt"); + doTest(fileName); + } + + @TestMetadata("lambdaResultWithDirectCall.kt") + public void testInflow_LambdaResultWithDirectCall() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/lambdaResultWithDirectCall.kt"); + doTest(fileName); + } + + @TestMetadata("lambdaResultWithDirectCallViaAssignment.kt") + public void testInflow_LambdaResultWithDirectCallViaAssignment() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/lambdaResultWithDirectCallViaAssignment.kt"); + doTest(fileName); + } + + @TestMetadata("localVal.kt") + public void testInflow_LocalVal() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/localVal.kt"); + doTest(fileName); + } + + @TestMetadata("localVar.kt") + public void testInflow_LocalVar() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/localVar.kt"); + doTest(fileName); + } + + @TestMetadata("memberValWithInitializer.kt") + public void testInflow_MemberValWithInitializer() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/memberValWithInitializer.kt"); + doTest(fileName); + } + + @TestMetadata("memberValWithSplitInitializer.kt") + public void testInflow_MemberValWithSplitInitializer() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/memberValWithSplitInitializer.kt"); + doTest(fileName); + } + + @TestMetadata("memberVarWithInitializer.kt") + public void testInflow_MemberVarWithInitializer() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/memberVarWithInitializer.kt"); + doTest(fileName); + } + + @TestMetadata("memberVarWithSplitInitializer.kt") + public void testInflow_MemberVarWithSplitInitializer() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/memberVarWithSplitInitializer.kt"); + doTest(fileName); + } + + @TestMetadata("noFieldInGetter.kt") + public void testInflow_NoFieldInGetter() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/noFieldInGetter.kt"); + doTest(fileName); + } + + @TestMetadata("nonLocalReturn.kt") + public void testInflow_NonLocalReturn() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/nonLocalReturn.kt"); + doTest(fileName); + } + + @TestMetadata("notNullAssertion.kt") + public void testInflow_NotNullAssertion() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/notNullAssertion.kt"); + doTest(fileName); + } + + @TestMetadata("overridingFunctionResult.kt") + public void testInflow_OverridingFunctionResult() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/overridingFunctionResult.kt"); + doTest(fileName); + } + + @TestMetadata("overridingParameter.kt") + public void testInflow_OverridingParameter() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/overridingParameter.kt"); + doTest(fileName); + } + + @TestMetadata("overridingPropertyGetterResult.kt") + public void testInflow_OverridingPropertyGetterResult() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/overridingPropertyGetterResult.kt"); + doTest(fileName); + } + + @TestMetadata("overridingPropertyResult.kt") + public void testInflow_OverridingPropertyResult() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/overridingPropertyResult.kt"); + doTest(fileName); + } + + @TestMetadata("primaryConstructorParameter.kt") + public void testInflow_PrimaryConstructorParameter() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/primaryConstructorParameter.kt"); + doTest(fileName); + } + + @TestMetadata("primaryConstructorParameterWithDefault.kt") + public void testInflow_PrimaryConstructorParameterWithDefault() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/primaryConstructorParameterWithDefault.kt"); + doTest(fileName); + } + + @TestMetadata("qualifiedAssignmentsForQualifiedRef.kt") + public void testInflow_QualifiedAssignmentsForQualifiedRef() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/qualifiedAssignmentsForQualifiedRef.kt"); + doTest(fileName); + } + + @TestMetadata("qualifiedAssignmentsForSimpleRef.kt") + public void testInflow_QualifiedAssignmentsForSimpleRef() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/qualifiedAssignmentsForSimpleRef.kt"); + doTest(fileName); + } + + @TestMetadata("safeCast.kt") + public void testInflow_SafeCast() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/safeCast.kt"); + doTest(fileName); + } + + @TestMetadata("secondaryConstructorParameter.kt") + public void testInflow_SecondaryConstructorParameter() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/secondaryConstructorParameter.kt"); + doTest(fileName); + } + + @TestMetadata("secondaryConstructorParameterWithDefault.kt") + public void testInflow_SecondaryConstructorParameterWithDefault() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/secondaryConstructorParameterWithDefault.kt"); + doTest(fileName); + } + + @TestMetadata("settersViaDelegateForQualifiedRef.kt") + public void testInflow_SettersViaDelegateForQualifiedRef() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/settersViaDelegateForQualifiedRef.kt"); + doTest(fileName); + } + + @TestMetadata("settersViaDelegateForSimpleRef.kt") + public void testInflow_SettersViaDelegateForSimpleRef() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/settersViaDelegateForSimpleRef.kt"); + doTest(fileName); + } + + @TestMetadata("topLevelVal.kt") + public void testInflow_TopLevelVal() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/topLevelVal.kt"); + doTest(fileName); + } + + @TestMetadata("topLevelVar.kt") + public void testInflow_TopLevelVar() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/topLevelVar.kt"); + doTest(fileName); + } + + @TestMetadata("valParameter.kt") + public void testInflow_ValParameter() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/valParameter.kt"); + doTest(fileName); + } + + @TestMetadata("varParameter.kt") + public void testInflow_VarParameter() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/varParameter.kt"); + doTest(fileName); + } + + @TestMetadata("whenExpression.kt") + public void testInflow_WhenExpression() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/whenExpression.kt"); + doTest(fileName); + } +} diff --git a/idea/tests/org/jetbrains/kotlin/idea/slicer/SlicerTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/slicer/SlicerTreeTestGenerated.java similarity index 99% rename from idea/tests/org/jetbrains/kotlin/idea/slicer/SlicerTestGenerated.java rename to idea/tests/org/jetbrains/kotlin/idea/slicer/SlicerTreeTestGenerated.java index c979f8a9353..d02d2fa928b 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/slicer/SlicerTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/slicer/SlicerTreeTestGenerated.java @@ -20,7 +20,7 @@ import java.util.regex.Pattern; @TestMetadata("idea/testData/slicer") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) -public class SlicerTestGenerated extends AbstractSlicerTest { +public class SlicerTreeTestGenerated extends AbstractSlicerTreeTest { public void testAllFilesPresentInSlicer() throws Exception { KotlinTestUtils.assertAllTestsPresentInSingleGeneratedClass(this.getClass(), new File("idea/testData/slicer"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY); }