Do not show doc-comment references in data flow
This commit is contained in:
@@ -6,8 +6,10 @@
|
||||
package org.jetbrains.kotlin.idea.slicer
|
||||
|
||||
import com.intellij.codeInsight.highlighting.ReadWriteAccessDetector.Access
|
||||
import com.intellij.psi.PsiComment
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiMethod
|
||||
import com.intellij.psi.util.parentOfType
|
||||
import com.intellij.usageView.UsageInfo
|
||||
import org.jetbrains.kotlin.builtins.isExtensionFunctionType
|
||||
import org.jetbrains.kotlin.builtins.isFunctionType
|
||||
@@ -95,7 +97,9 @@ class OutflowSlicer(
|
||||
fun processVariableAccess(usageInfo: UsageInfo) {
|
||||
val refElement = usageInfo.element ?: return
|
||||
if (refElement !is KtExpression) {
|
||||
refElement.passToProcessor()
|
||||
if (refElement.parentOfType<PsiComment>() == null) {
|
||||
refElement.passToProcessor()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -5,9 +5,11 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.slicer
|
||||
|
||||
import com.intellij.psi.PsiComment
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiMethod
|
||||
import com.intellij.psi.search.SearchScope
|
||||
import com.intellij.psi.util.parentOfType
|
||||
import com.intellij.slicer.JavaSliceUsage
|
||||
import com.intellij.usageView.UsageInfo
|
||||
import com.intellij.util.containers.addIfNotNull
|
||||
@@ -171,6 +173,7 @@ abstract class Slicer(
|
||||
is KtDeclaration -> {
|
||||
val usageProcessor: (UsageInfo) -> Unit = processor@ { usageInfo ->
|
||||
val element = usageInfo.element ?: return@processor
|
||||
if (element.parentOfType<PsiComment>() != null) return@processor
|
||||
val sliceUsage = KotlinSliceUsage(element, parentUsage, mode, false)
|
||||
sliceProducer.produceAndProcess(sliceUsage, mode, parentUsage, processor)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* @see KotlinClass#foo()
|
||||
*/
|
||||
class JavaClass {
|
||||
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// FLOW: OUT
|
||||
|
||||
class KotlinClass {
|
||||
fun <caret>foo(): Int = 10
|
||||
|
||||
/**
|
||||
* Uses [foo]
|
||||
*/
|
||||
fun bar() {
|
||||
val v = foo()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
4 fun <bold>foo(): Int = 10</bold>
|
||||
10 val v = <bold>foo()</bold>
|
||||
10 val <bold>v = foo()</bold>
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// FLOW: OUT
|
||||
|
||||
val String.<caret>foo: Int
|
||||
get() = 10
|
||||
|
||||
/**
|
||||
* Uses [foo]
|
||||
*/
|
||||
fun bar() {
|
||||
val v = "".foo
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
3 val String.<bold>foo: Int</bold>
|
||||
10 val v = "".<bold>foo</bold>
|
||||
10 val <bold>v = "".foo</bold>
|
||||
@@ -513,6 +513,16 @@ public class SlicerTreeTestGenerated extends AbstractSlicerTreeTest {
|
||||
runTest("idea/testData/slicer/outflow/diamondHierarchyMiddleInterfaceFun.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("docCommentRefs.kt")
|
||||
public void testDocCommentRefs() throws Exception {
|
||||
runTest("idea/testData/slicer/outflow/docCommentRefs.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("docCommentRefs2.kt")
|
||||
public void testDocCommentRefs2() throws Exception {
|
||||
runTest("idea/testData/slicer/outflow/docCommentRefs2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("doubleLambdaResult.kt")
|
||||
public void testDoubleLambdaResult() throws Exception {
|
||||
runTest("idea/testData/slicer/outflow/doubleLambdaResult.kt");
|
||||
|
||||
Reference in New Issue
Block a user