diff --git a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt index 664d97d2e78..a2758c06b3f 100755 --- a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt +++ b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt @@ -133,6 +133,7 @@ import org.jetbrains.kotlin.idea.script.AbstractScriptConfigurationCompletionTes import org.jetbrains.kotlin.idea.script.AbstractScriptConfigurationHighlightingTest import org.jetbrains.kotlin.idea.script.AbstractScriptConfigurationNavigationTest import org.jetbrains.kotlin.idea.slicer.AbstractSlicerLeafGroupingTest +import org.jetbrains.kotlin.idea.slicer.AbstractSlicerNullnessGroupingTest import org.jetbrains.kotlin.idea.slicer.AbstractSlicerTreeTest import org.jetbrains.kotlin.idea.structureView.AbstractKotlinFileStructureTest import org.jetbrains.kotlin.idea.stubs.AbstractMultiFileHighlightingTest @@ -727,6 +728,10 @@ fun main(args: Array) { testClass { model("slicer/inflow", 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 c4e7a808095..02b5486af51 100644 --- a/idea/src/org/jetbrains/kotlin/idea/slicer/KotlinSliceProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/slicer/KotlinSliceProvider.kt @@ -16,15 +16,24 @@ package org.jetbrains.kotlin.idea.slicer +import com.intellij.codeInspection.dataFlow.Nullness import com.intellij.ide.util.treeView.AbstractTreeStructure import com.intellij.openapi.actionSystem.DefaultActionGroup import com.intellij.psi.PsiElement import com.intellij.slicer.* +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.descriptors.CallableDescriptor +import org.jetbrains.kotlin.idea.caches.resolve.analyzeAndGetResult +import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny +import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.guessTypes 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 +import org.jetbrains.kotlin.types.TypeUtils +import org.jetbrains.kotlin.types.isError +import org.jetbrains.kotlin.types.isNullabilityFlexible class KotlinSliceProvider : SliceLanguageSupportProvider { companion object { @@ -33,7 +42,32 @@ class KotlinSliceProvider : SliceLanguageSupportProvider { } } + class KotlinGroupByNullnessAction(treeBuilder: SliceTreeBuilder) : GroupByNullnessActionBase(treeBuilder) { + override fun isAvailable() = true + } + val leafAnalyzer by lazy { SliceLeafAnalyzer(LEAF_ELEMENT_EQUALITY, this) } + val nullnessAnalyzer: SliceNullnessAnalyzerBase by lazy { + object : SliceNullnessAnalyzerBase(LEAF_ELEMENT_EQUALITY, this) { + override fun checkNullness(element: PsiElement?): Nullness { + val types = when (element) { + is KtCallableDeclaration -> listOfNotNull((element.resolveToDescriptorIfAny() as? CallableDescriptor)?.returnType) + is KtDeclaration -> emptyList() + is KtExpression -> { + val (bindingContext, moduleDescriptor) = element.analyzeAndGetResult() + element.guessTypes(bindingContext, moduleDescriptor).toList() + } + else -> emptyList() + } + return when { + types.isEmpty() -> return Nullness.UNKNOWN + types.all { KotlinBuiltIns.isNullableNothing(it) } -> Nullness.NULLABLE + types.any { it.isError || TypeUtils.isNullableType(it) || it.isNullabilityFlexible() } -> Nullness.UNKNOWN + else -> Nullness.NOT_NULL + } + } + } + } override fun createRootUsage(element: PsiElement, params: SliceAnalysisParams) = KotlinSliceUsage(element, params) @@ -67,12 +101,13 @@ class KotlinSliceProvider : SliceLanguageSupportProvider { } override fun startAnalyzeNullness(structure: AbstractTreeStructure, finalRunnable: Runnable) { - + nullnessAnalyzer.startAnalyzeNullness(structure, finalRunnable) } override fun registerExtraPanelActions(group: DefaultActionGroup, builder: SliceTreeBuilder) { if (builder.dataFlowToThis) { group.add(GroupByLeavesAction(builder)) + group.add(KotlinGroupByNullnessAction(builder)) } } } \ No newline at end of file diff --git a/idea/testData/slicer/inflow/anonymousFunBodyExpression.nullnessGroups.txt b/idea/testData/slicer/inflow/anonymousFunBodyExpression.nullnessGroups.txt new file mode 100644 index 00000000000..23c43517aa3 --- /dev/null +++ b/idea/testData/slicer/inflow/anonymousFunBodyExpression.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +8 val x = foo(fun(n: Int) = n) +8 val x = foo(fun(n: Int) = n) diff --git a/idea/testData/slicer/inflow/anonymousFunReturnExpression.nullnessGroups.txt b/idea/testData/slicer/inflow/anonymousFunReturnExpression.nullnessGroups.txt new file mode 100644 index 00000000000..1638e6e88e7 --- /dev/null +++ b/idea/testData/slicer/inflow/anonymousFunReturnExpression.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +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.nullnessGroups.txt b/idea/testData/slicer/inflow/cast.nullnessGroups.txt new file mode 100644 index 00000000000..36d8ed95749 --- /dev/null +++ b/idea/testData/slicer/inflow/cast.nullnessGroups.txt @@ -0,0 +1,4 @@ +[NotNull Values] +4 val x = o as String +4 val x = o as String + diff --git a/idea/testData/slicer/inflow/compositeAssignments.nullnessGroups.txt b/idea/testData/slicer/inflow/compositeAssignments.nullnessGroups.txt new file mode 100644 index 00000000000..e9a2d0cdeb4 --- /dev/null +++ b/idea/testData/slicer/inflow/compositeAssignments.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +3 fun assignmentWithSum(n: Int): Int { +3 fun assignmentWithSum(n: Int): Int { diff --git a/idea/testData/slicer/inflow/defaultGetterFieldInSetter.nullnessGroups.txt b/idea/testData/slicer/inflow/defaultGetterFieldInSetter.nullnessGroups.txt new file mode 100644 index 00000000000..194af3317cb --- /dev/null +++ b/idea/testData/slicer/inflow/defaultGetterFieldInSetter.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +10 val x = foo +10 val x = foo diff --git a/idea/testData/slicer/inflow/delegateGetter.nullnessGroups.txt b/idea/testData/slicer/inflow/delegateGetter.nullnessGroups.txt new file mode 100644 index 00000000000..d2294fea665 --- /dev/null +++ b/idea/testData/slicer/inflow/delegateGetter.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +12 val x = foo +12 val x = foo diff --git a/idea/testData/slicer/inflow/diamondHierarchyMiddleClassFun.nullnessGroups.txt b/idea/testData/slicer/inflow/diamondHierarchyMiddleClassFun.nullnessGroups.txt new file mode 100644 index 00000000000..edaa10b75b9 --- /dev/null +++ b/idea/testData/slicer/inflow/diamondHierarchyMiddleClassFun.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +21 val y = b.foo() +21 val y = b.foo() diff --git a/idea/testData/slicer/inflow/diamondHierarchyMiddleInterfaceFun.nullnessGroups.txt b/idea/testData/slicer/inflow/diamondHierarchyMiddleInterfaceFun.nullnessGroups.txt new file mode 100644 index 00000000000..80a6e554090 --- /dev/null +++ b/idea/testData/slicer/inflow/diamondHierarchyMiddleInterfaceFun.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +22 val z = c.foo() +22 val z = c.foo() diff --git a/idea/testData/slicer/inflow/diamondHierarchyRootInterfaceFun.nullnessGroups.txt b/idea/testData/slicer/inflow/diamondHierarchyRootInterfaceFun.nullnessGroups.txt new file mode 100644 index 00000000000..3d1897a89b2 --- /dev/null +++ b/idea/testData/slicer/inflow/diamondHierarchyRootInterfaceFun.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +20 val x = a.foo() +20 val x = a.foo() diff --git a/idea/testData/slicer/inflow/doubleLambdaResult.nullnessGroups.txt b/idea/testData/slicer/inflow/doubleLambdaResult.nullnessGroups.txt new file mode 100644 index 00000000000..05968947054 --- /dev/null +++ b/idea/testData/slicer/inflow/doubleLambdaResult.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +8 val x = foo(1, 2) { { it } } +8 val x = foo(1, 2) { { it } } diff --git a/idea/testData/slicer/inflow/funParamerer.nullnessGroups.txt b/idea/testData/slicer/inflow/funParamerer.nullnessGroups.txt new file mode 100644 index 00000000000..b884f9ebf40 --- /dev/null +++ b/idea/testData/slicer/inflow/funParamerer.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +3 fun foo(n: Int, s: String = "???") { +3 fun foo(n: Int, s: String = "???") { diff --git a/idea/testData/slicer/inflow/funParamererWithDefault.nullnessGroups.txt b/idea/testData/slicer/inflow/funParamererWithDefault.nullnessGroups.txt new file mode 100644 index 00000000000..fa0600bde6d --- /dev/null +++ b/idea/testData/slicer/inflow/funParamererWithDefault.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +3 fun foo(n: Int, s: String = "???") { +3 fun foo(n: Int, s: String = "???") { diff --git a/idea/testData/slicer/inflow/funResultViaCallableRef.nullnessGroups.txt b/idea/testData/slicer/inflow/funResultViaCallableRef.nullnessGroups.txt new file mode 100644 index 00000000000..fc81d14c64b --- /dev/null +++ b/idea/testData/slicer/inflow/funResultViaCallableRef.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +9 val x = foo(::bar) +9 val x = foo(::bar) diff --git a/idea/testData/slicer/inflow/funResultViaCallableRefWithAssignment.nullnessGroups.txt b/idea/testData/slicer/inflow/funResultViaCallableRefWithAssignment.nullnessGroups.txt new file mode 100644 index 00000000000..41b66205857 --- /dev/null +++ b/idea/testData/slicer/inflow/funResultViaCallableRefWithAssignment.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +10 val x = foo(f) +10 val x = foo(f) diff --git a/idea/testData/slicer/inflow/funResultViaCallableRefWithDirectCall.nullnessGroups.txt b/idea/testData/slicer/inflow/funResultViaCallableRefWithDirectCall.nullnessGroups.txt new file mode 100644 index 00000000000..8910ec7b060 --- /dev/null +++ b/idea/testData/slicer/inflow/funResultViaCallableRefWithDirectCall.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +5 val x = (::bar)(1) +5 val x = (::bar)(1) diff --git a/idea/testData/slicer/inflow/funWithExpressionBody.nullnessGroups.txt b/idea/testData/slicer/inflow/funWithExpressionBody.nullnessGroups.txt new file mode 100644 index 00000000000..580e77a9b8a --- /dev/null +++ b/idea/testData/slicer/inflow/funWithExpressionBody.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +3 fun foo(n: Int) = n + 1 +3 fun foo(n: Int) = n + 1 diff --git a/idea/testData/slicer/inflow/funWithReturnExpressions.nullnessGroups.txt b/idea/testData/slicer/inflow/funWithReturnExpressions.nullnessGroups.txt new file mode 100644 index 00000000000..10f73f79008 --- /dev/null +++ b/idea/testData/slicer/inflow/funWithReturnExpressions.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +3 fun foo(n: Int): Int { +3 fun foo(n: Int): Int { diff --git a/idea/testData/slicer/inflow/getterAndSetterUsingField.nullnessGroups.txt b/idea/testData/slicer/inflow/getterAndSetterUsingField.nullnessGroups.txt new file mode 100644 index 00000000000..20caa224a23 --- /dev/null +++ b/idea/testData/slicer/inflow/getterAndSetterUsingField.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +11 val x = foo +11 val x = foo diff --git a/idea/testData/slicer/inflow/getterExpressionBody.nullnessGroups.txt b/idea/testData/slicer/inflow/getterExpressionBody.nullnessGroups.txt new file mode 100644 index 00000000000..142739bce11 --- /dev/null +++ b/idea/testData/slicer/inflow/getterExpressionBody.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +7 val x = foo +7 val x = foo diff --git a/idea/testData/slicer/inflow/getterReturnExpression.nullnessGroups.txt b/idea/testData/slicer/inflow/getterReturnExpression.nullnessGroups.txt new file mode 100644 index 00000000000..841a24d157e --- /dev/null +++ b/idea/testData/slicer/inflow/getterReturnExpression.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +9 val x = foo +9 val x = foo diff --git a/idea/testData/slicer/inflow/ifExpression.nullnessGroups.txt b/idea/testData/slicer/inflow/ifExpression.nullnessGroups.txt new file mode 100644 index 00000000000..ffbb4d2f89e --- /dev/null +++ b/idea/testData/slicer/inflow/ifExpression.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +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.nullnessGroups.txt b/idea/testData/slicer/inflow/lambdaResult.nullnessGroups.txt new file mode 100644 index 00000000000..3f515c99360 --- /dev/null +++ b/idea/testData/slicer/inflow/lambdaResult.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +8 val x = foo { it } +8 val x = foo { it } diff --git a/idea/testData/slicer/inflow/lambdaResultWithAssignments.nullnessGroups.txt b/idea/testData/slicer/inflow/lambdaResultWithAssignments.nullnessGroups.txt new file mode 100644 index 00000000000..01e17527b94 --- /dev/null +++ b/idea/testData/slicer/inflow/lambdaResultWithAssignments.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +9 val y = foo { it } +9 val y = foo { it } diff --git a/idea/testData/slicer/inflow/lambdaResultWithDirectCall.nullnessGroups.txt b/idea/testData/slicer/inflow/lambdaResultWithDirectCall.nullnessGroups.txt new file mode 100644 index 00000000000..cf4cf72dbda --- /dev/null +++ b/idea/testData/slicer/inflow/lambdaResultWithDirectCall.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +4 val x = { 1 }() +4 val x = { 1 }() diff --git a/idea/testData/slicer/inflow/lambdaResultWithDirectCallViaAssignment.nullnessGroups.txt b/idea/testData/slicer/inflow/lambdaResultWithDirectCallViaAssignment.nullnessGroups.txt new file mode 100644 index 00000000000..617998f7071 --- /dev/null +++ b/idea/testData/slicer/inflow/lambdaResultWithDirectCallViaAssignment.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +5 val x = f() +5 val x = f() diff --git a/idea/testData/slicer/inflow/localVal.nullnessGroups.txt b/idea/testData/slicer/inflow/localVal.nullnessGroups.txt new file mode 100644 index 00000000000..317d74197e7 --- /dev/null +++ b/idea/testData/slicer/inflow/localVal.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +4 val x = n +4 val x = n diff --git a/idea/testData/slicer/inflow/localVar.nullnessGroups.txt b/idea/testData/slicer/inflow/localVar.nullnessGroups.txt new file mode 100644 index 00000000000..eedeaacafd9 --- /dev/null +++ b/idea/testData/slicer/inflow/localVar.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +4 var x = n +4 var x = n diff --git a/idea/testData/slicer/inflow/memberValWithInitializer.nullnessGroups.txt b/idea/testData/slicer/inflow/memberValWithInitializer.nullnessGroups.txt new file mode 100644 index 00000000000..97a1f3ea0ee --- /dev/null +++ b/idea/testData/slicer/inflow/memberValWithInitializer.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +4 val x: Int = 1 +4 val x: Int = 1 diff --git a/idea/testData/slicer/inflow/memberValWithSplitInitializer.nullnessGroups.txt b/idea/testData/slicer/inflow/memberValWithSplitInitializer.nullnessGroups.txt new file mode 100644 index 00000000000..bfd2028d63f --- /dev/null +++ b/idea/testData/slicer/inflow/memberValWithSplitInitializer.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +4 val x: Int +4 val x: Int diff --git a/idea/testData/slicer/inflow/memberVarWithInitializer.nullnessGroups.txt b/idea/testData/slicer/inflow/memberVarWithInitializer.nullnessGroups.txt new file mode 100644 index 00000000000..3ca6c06eb06 --- /dev/null +++ b/idea/testData/slicer/inflow/memberVarWithInitializer.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +4 var x: Int = 1 +4 var x: Int = 1 diff --git a/idea/testData/slicer/inflow/memberVarWithSplitInitializer.nullnessGroups.txt b/idea/testData/slicer/inflow/memberVarWithSplitInitializer.nullnessGroups.txt new file mode 100644 index 00000000000..93846fb0e63 --- /dev/null +++ b/idea/testData/slicer/inflow/memberVarWithSplitInitializer.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +4 var x: Int +4 var x: Int diff --git a/idea/testData/slicer/inflow/noFieldInGetter.nullnessGroups.txt b/idea/testData/slicer/inflow/noFieldInGetter.nullnessGroups.txt new file mode 100644 index 00000000000..20caa224a23 --- /dev/null +++ b/idea/testData/slicer/inflow/noFieldInGetter.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +11 val x = foo +11 val x = foo diff --git a/idea/testData/slicer/inflow/nonLocalReturn.nullnessGroups.txt b/idea/testData/slicer/inflow/nonLocalReturn.nullnessGroups.txt new file mode 100644 index 00000000000..e1218e3dd54 --- /dev/null +++ b/idea/testData/slicer/inflow/nonLocalReturn.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +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.nullnessGroups.txt b/idea/testData/slicer/inflow/notNullAssertion.nullnessGroups.txt new file mode 100644 index 00000000000..6a3a2fae051 --- /dev/null +++ b/idea/testData/slicer/inflow/notNullAssertion.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +4 val x = s!! +4 val x = s!! diff --git a/idea/testData/slicer/inflow/nullsAndNotNulls.kt b/idea/testData/slicer/inflow/nullsAndNotNulls.kt new file mode 100644 index 00000000000..eb8a497be20 --- /dev/null +++ b/idea/testData/slicer/inflow/nullsAndNotNulls.kt @@ -0,0 +1,10 @@ +// FLOW: IN + +fun test(n: Int): String { + var s = when { + n > 0 -> "+" + n < 0 -> "-" + else -> null + } + return s +} \ No newline at end of file diff --git a/idea/testData/slicer/inflow/nullsAndNotNulls.leafGroups.txt b/idea/testData/slicer/inflow/nullsAndNotNulls.leafGroups.txt new file mode 100644 index 00000000000..9ec6507667d --- /dev/null +++ b/idea/testData/slicer/inflow/nullsAndNotNulls.leafGroups.txt @@ -0,0 +1,17 @@ +7 else -> null +9 return s +4 var s = when { +4 var s = when { +7 else -> null + +6 n < 0 -> "-" +9 return s +4 var s = when { +4 var s = when { +6 n < 0 -> "-" + +5 n > 0 -> "+" +9 return s +4 var s = when { +4 var s = when { +5 n > 0 -> "+" diff --git a/idea/testData/slicer/inflow/nullsAndNotNulls.nullnessGroups.txt b/idea/testData/slicer/inflow/nullsAndNotNulls.nullnessGroups.txt new file mode 100644 index 00000000000..70410530241 --- /dev/null +++ b/idea/testData/slicer/inflow/nullsAndNotNulls.nullnessGroups.txt @@ -0,0 +1,18 @@ +[Null Values] +7 else -> null +9 return s +4 var s = when { +4 var s = when { +7 else -> null + +[NotNull Values] +6 n < 0 -> "-" +9 return s +4 var s = when { +4 var s = when { +6 n < 0 -> "-" +5 n > 0 -> "+" +9 return s +4 var s = when { +4 var s = when { +5 n > 0 -> "+" diff --git a/idea/testData/slicer/inflow/nullsAndNotNulls.results.txt b/idea/testData/slicer/inflow/nullsAndNotNulls.results.txt new file mode 100644 index 00000000000..9a334b9d9e7 --- /dev/null +++ b/idea/testData/slicer/inflow/nullsAndNotNulls.results.txt @@ -0,0 +1,6 @@ +9 return s +4 var s = when { +4 var s = when { +5 n > 0 -> "+" +6 n < 0 -> "-" +7 else -> null diff --git a/idea/testData/slicer/inflow/overridingFunctionResult.nullnessGroups.txt b/idea/testData/slicer/inflow/overridingFunctionResult.nullnessGroups.txt new file mode 100644 index 00000000000..b6ab3a27912 --- /dev/null +++ b/idea/testData/slicer/inflow/overridingFunctionResult.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +17 val y = b.foo() +17 val y = b.foo() diff --git a/idea/testData/slicer/inflow/overridingParameter.nullnessGroups.txt b/idea/testData/slicer/inflow/overridingParameter.nullnessGroups.txt new file mode 100644 index 00000000000..4c2636dfb3f --- /dev/null +++ b/idea/testData/slicer/inflow/overridingParameter.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +15 val y = b.foo +15 val y = b.foo diff --git a/idea/testData/slicer/inflow/overridingPropertyGetterResult.nullnessGroups.txt b/idea/testData/slicer/inflow/overridingPropertyGetterResult.nullnessGroups.txt new file mode 100644 index 00000000000..893088d2aa8 --- /dev/null +++ b/idea/testData/slicer/inflow/overridingPropertyGetterResult.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +20 val y = b.foo +20 val y = b.foo diff --git a/idea/testData/slicer/inflow/overridingPropertyResult.nullnessGroups.txt b/idea/testData/slicer/inflow/overridingPropertyResult.nullnessGroups.txt new file mode 100644 index 00000000000..074eced5db8 --- /dev/null +++ b/idea/testData/slicer/inflow/overridingPropertyResult.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +17 val y = b.foo +17 val y = b.foo diff --git a/idea/testData/slicer/inflow/primaryConstructorParameter.nullnessGroups.txt b/idea/testData/slicer/inflow/primaryConstructorParameter.nullnessGroups.txt new file mode 100644 index 00000000000..63648612e2e --- /dev/null +++ b/idea/testData/slicer/inflow/primaryConstructorParameter.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +3 open class A(n: Int, s: String = "???") +3 open class A(n: Int, s: String = "???") diff --git a/idea/testData/slicer/inflow/primaryConstructorParameterWithDefault.nullnessGroups.txt b/idea/testData/slicer/inflow/primaryConstructorParameterWithDefault.nullnessGroups.txt new file mode 100644 index 00000000000..51db0b7733b --- /dev/null +++ b/idea/testData/slicer/inflow/primaryConstructorParameterWithDefault.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +3 open class A(n: Int, s: String = "???") +3 open class A(n: Int, s: String = "???") diff --git a/idea/testData/slicer/inflow/qualifiedAssignmentsForQualifiedRef.nullnessGroups.txt b/idea/testData/slicer/inflow/qualifiedAssignmentsForQualifiedRef.nullnessGroups.txt new file mode 100644 index 00000000000..54dbefbbb34 --- /dev/null +++ b/idea/testData/slicer/inflow/qualifiedAssignmentsForQualifiedRef.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +15 println("Now my name is '${a.name}'") +15 println("Now my name is '${a.name}'") diff --git a/idea/testData/slicer/inflow/qualifiedAssignmentsForSimpleRef.nullnessGroups.txt b/idea/testData/slicer/inflow/qualifiedAssignmentsForSimpleRef.nullnessGroups.txt new file mode 100644 index 00000000000..17320da76c0 --- /dev/null +++ b/idea/testData/slicer/inflow/qualifiedAssignmentsForSimpleRef.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +8 println("And now my name is '$name'") +8 println("And now my name is '$name'") diff --git a/idea/testData/slicer/inflow/safeCast.nullnessGroups.txt b/idea/testData/slicer/inflow/safeCast.nullnessGroups.txt new file mode 100644 index 00000000000..32e5d9b9633 --- /dev/null +++ b/idea/testData/slicer/inflow/safeCast.nullnessGroups.txt @@ -0,0 +1,6 @@ +[NotNull Values] +4 val x = o as? String +4 val x = o as? String +4 val x = o as? String +4 val x = o as? String + diff --git a/idea/testData/slicer/inflow/secondaryConstructorParameter.nullnessGroups.txt b/idea/testData/slicer/inflow/secondaryConstructorParameter.nullnessGroups.txt new file mode 100644 index 00000000000..6b5730b5237 --- /dev/null +++ b/idea/testData/slicer/inflow/secondaryConstructorParameter.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +4 constructor(n: Int, s: String = "???") +4 constructor(n: Int, s: String = "???") diff --git a/idea/testData/slicer/inflow/secondaryConstructorParameterWithDefault.nullnessGroups.txt b/idea/testData/slicer/inflow/secondaryConstructorParameterWithDefault.nullnessGroups.txt new file mode 100644 index 00000000000..636ca3a1ebf --- /dev/null +++ b/idea/testData/slicer/inflow/secondaryConstructorParameterWithDefault.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +4 constructor(n: Int, s: String = "???") +4 constructor(n: Int, s: String = "???") diff --git a/idea/testData/slicer/inflow/settersViaDelegateForQualifiedRef.nullnessGroups.txt b/idea/testData/slicer/inflow/settersViaDelegateForQualifiedRef.nullnessGroups.txt new file mode 100644 index 00000000000..56e41c7ae5b --- /dev/null +++ b/idea/testData/slicer/inflow/settersViaDelegateForQualifiedRef.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +25 println("My name is '${a.name}'") +25 println("My name is '${a.name}'") diff --git a/idea/testData/slicer/inflow/settersViaDelegateForSimpleRef.nullnessGroups.txt b/idea/testData/slicer/inflow/settersViaDelegateForSimpleRef.nullnessGroups.txt new file mode 100644 index 00000000000..fc530508727 --- /dev/null +++ b/idea/testData/slicer/inflow/settersViaDelegateForSimpleRef.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +19 println("Now my name is '$name'") +19 println("Now my name is '$name'") diff --git a/idea/testData/slicer/inflow/topLevelVal.nullnessGroups.txt b/idea/testData/slicer/inflow/topLevelVal.nullnessGroups.txt new file mode 100644 index 00000000000..a7aa6d8fdd7 --- /dev/null +++ b/idea/testData/slicer/inflow/topLevelVal.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +3 val foo: Int = 1 +3 val foo: Int = 1 diff --git a/idea/testData/slicer/inflow/topLevelVar.nullnessGroups.txt b/idea/testData/slicer/inflow/topLevelVar.nullnessGroups.txt new file mode 100644 index 00000000000..d5b7c8122e0 --- /dev/null +++ b/idea/testData/slicer/inflow/topLevelVar.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +3 var foo: Int = 1 +3 var foo: Int = 1 diff --git a/idea/testData/slicer/inflow/valParameter.nullnessGroups.txt b/idea/testData/slicer/inflow/valParameter.nullnessGroups.txt new file mode 100644 index 00000000000..52ad6775d94 --- /dev/null +++ b/idea/testData/slicer/inflow/valParameter.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +3 open class A(val n: Int) +3 open class A(val n: Int) diff --git a/idea/testData/slicer/inflow/varParameter.nullnessGroups.txt b/idea/testData/slicer/inflow/varParameter.nullnessGroups.txt new file mode 100644 index 00000000000..309fcdd6e23 --- /dev/null +++ b/idea/testData/slicer/inflow/varParameter.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +3 open class A(var n: Int) { +3 open class A(var n: Int) { diff --git a/idea/testData/slicer/inflow/whenExpression.nullnessGroups.txt b/idea/testData/slicer/inflow/whenExpression.nullnessGroups.txt new file mode 100644 index 00000000000..eb6e467940b --- /dev/null +++ b/idea/testData/slicer/inflow/whenExpression.nullnessGroups.txt @@ -0,0 +1,3 @@ +[NotNull Values] +4 val x = when (m) { +4 val x = when (m) { diff --git a/idea/tests/org/jetbrains/kotlin/idea/slicer/AbstractSlicerNullnessGroupingTest.kt b/idea/tests/org/jetbrains/kotlin/idea/slicer/AbstractSlicerNullnessGroupingTest.kt new file mode 100644 index 00000000000..060843e7b29 --- /dev/null +++ b/idea/tests/org/jetbrains/kotlin/idea/slicer/AbstractSlicerNullnessGroupingTest.kt @@ -0,0 +1,39 @@ +/* + * 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.SliceNullnessAnalyzerBase +import com.intellij.slicer.SliceRootNode +import org.jetbrains.kotlin.test.KotlinTestUtils +import java.io.File + +abstract class AbstractSlicerNullnessGroupingTest : AbstractSlicerTest() { + override fun doTest(path: String, sliceProvider: KotlinSliceProvider, rootNode: SliceRootNode) { + val treeStructure = SliceTreeStructure(rootNode) + val analyzer = sliceProvider.nullnessAnalyzer + val nullnessByNode = SliceNullnessAnalyzerBase.createMap() + val nullness = analyzer.calcNullableLeaves(rootNode, treeStructure, nullnessByNode) + val newRootNode = analyzer.createNewTree(nullness, rootNode, nullnessByNode) + val renderedForest = buildString { + for (groupRootNode in newRootNode.children) { + append(buildTreeRepresentation(groupRootNode)) + append("\n") + } + } + KotlinTestUtils.assertEqualsToFile(File(path.replace(".kt", ".nullnessGroups.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 58539af8dc3..59d9f7cde41 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/slicer/AbstractSlicerTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/slicer/AbstractSlicerTest.kt @@ -56,11 +56,13 @@ abstract class AbstractSlicerTest : KotlinLightCodeInsightFixtureTestCase() { return text } + fun SliceNode.isSliceLeafValueClassNode() = javaClass.name == "com.intellij.slicer.SliceLeafValueClassNode" + fun process(node: SliceNode, indent: Int): String { - val usage = node.element!!.value as KotlinSliceUsage + val usage = node.element!!.value node.calculateDupNode() - val isDuplicated = node.duplicate != null + val isDuplicated = !node.isSliceLeafValueClassNode() && node.duplicate != null return buildString { when { @@ -68,6 +70,8 @@ abstract class AbstractSlicerTest : KotlinLightCodeInsightFixtureTestCase() { node.children.forEach { append(process(it, indent)) } return@buildString } + // SliceLeafValueClassNode is package-private + node.isSliceLeafValueClassNode() -> append("[${node.nodeText}]\n") else -> { val chunks = usage.text append(chunks.first().render() + " ") @@ -75,7 +79,9 @@ abstract class AbstractSlicerTest : KotlinLightCodeInsightFixtureTestCase() { if (usage is KotlinSliceDereferenceUsage) { append("DEREFERENCE: ") } - append("[LAMBDA] ".repeat(usage.lambdaLevel)) + if (usage is KotlinSliceUsage) { + append("[LAMBDA] ".repeat(usage.lambdaLevel)) + } chunks.slice(1..chunks.size - 1).joinTo( this, separator = "", diff --git a/idea/tests/org/jetbrains/kotlin/idea/slicer/SlicerLeafGroupingTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/slicer/SlicerLeafGroupingTestGenerated.java index 00cde0b5549..d57c3323771 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/slicer/SlicerLeafGroupingTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/slicer/SlicerLeafGroupingTestGenerated.java @@ -240,6 +240,12 @@ public class SlicerLeafGroupingTestGenerated extends AbstractSlicerLeafGroupingT doTest(fileName); } + @TestMetadata("nullsAndNotNulls.kt") + public void testInflow_NullsAndNotNulls() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/nullsAndNotNulls.kt"); + doTest(fileName); + } + @TestMetadata("overridingFunctionResult.kt") public void testInflow_OverridingFunctionResult() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/overridingFunctionResult.kt"); diff --git a/idea/tests/org/jetbrains/kotlin/idea/slicer/SlicerNullnessGroupingTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/slicer/SlicerNullnessGroupingTestGenerated.java new file mode 100644 index 00000000000..e159e67cf4d --- /dev/null +++ b/idea/tests/org/jetbrains/kotlin/idea/slicer/SlicerNullnessGroupingTestGenerated.java @@ -0,0 +1,356 @@ +/* + * 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 SlicerNullnessGroupingTestGenerated extends AbstractSlicerNullnessGroupingTest { + 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("nullsAndNotNulls.kt") + public void testInflow_NullsAndNotNulls() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/nullsAndNotNulls.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/SlicerTreeTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/slicer/SlicerTreeTestGenerated.java index d02d2fa928b..c3931950567 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/slicer/SlicerTreeTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/slicer/SlicerTreeTestGenerated.java @@ -229,6 +229,12 @@ public class SlicerTreeTestGenerated extends AbstractSlicerTreeTest { doTest(fileName); } + @TestMetadata("inflow/nullsAndNotNulls.kt") + public void testInflow_NullsAndNotNulls() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/nullsAndNotNulls.kt"); + doTest(fileName); + } + @TestMetadata("inflow/overridingFunctionResult.kt") public void testInflow_OverridingFunctionResult() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/slicer/inflow/overridingFunctionResult.kt");