More information in log
This commit is contained in:
+4
-38
@@ -56,7 +56,7 @@ class ExpressionsOfTypeProcessor(
|
||||
private val typeToSearch: FuzzyType,
|
||||
private val searchScope: SearchScope,
|
||||
private val suspiciousExpressionHandler: (KtExpression) -> Unit,
|
||||
suspiciousScopeHandler: (SearchScope) -> Unit,
|
||||
private val suspiciousScopeHandler: (SearchScope) -> Unit,
|
||||
private val resolutionFacade: ResolutionFacade
|
||||
) {
|
||||
enum class Mode {
|
||||
@@ -88,11 +88,6 @@ class ExpressionsOfTypeProcessor(
|
||||
|
||||
private val project = resolutionFacade.project
|
||||
|
||||
private val plainSearchHandler: (SearchScope) -> Unit = { scope ->
|
||||
testLog?.add("Used plain search in ${scope.logPresentation()}")
|
||||
suspiciousScopeHandler(scope)
|
||||
}
|
||||
|
||||
// note: a Task must define equals & hashCode!
|
||||
private interface Task {
|
||||
fun perform()
|
||||
@@ -114,7 +109,7 @@ class ExpressionsOfTypeProcessor(
|
||||
|
||||
// for class from library always use plain search because we cannot search usages in compiled code (we could though)
|
||||
if (!ProjectRootsUtil.isInProjectSource(psiClass)) {
|
||||
plainSearchHandler(searchScope)
|
||||
suspiciousScopeHandler(searchScope)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -123,7 +118,7 @@ class ExpressionsOfTypeProcessor(
|
||||
processTasks()
|
||||
|
||||
val scopeElements = scopesToUsePlainSearch.values.flatMap { it }.toTypedArray()
|
||||
plainSearchHandler(LocalSearchScope(scopeElements))
|
||||
suspiciousScopeHandler(LocalSearchScope(scopeElements))
|
||||
}
|
||||
|
||||
private fun addTask(task: Task) {
|
||||
@@ -142,7 +137,7 @@ class ExpressionsOfTypeProcessor(
|
||||
private fun downShiftToPlainSearch() {
|
||||
tasks.clear()
|
||||
scopesToUsePlainSearch.clear()
|
||||
plainSearchHandler(searchScope)
|
||||
suspiciousScopeHandler(searchScope)
|
||||
}
|
||||
|
||||
private fun addClassToProcess(classToSearch: PsiClass) {
|
||||
@@ -620,33 +615,4 @@ class ExpressionsOfTypeProcessor(
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
private fun SearchScope.logPresentation(): String {
|
||||
return when (this) {
|
||||
searchScope -> "whole search scope"
|
||||
|
||||
is LocalSearchScope -> {
|
||||
scope
|
||||
.map { element ->
|
||||
" " + when (element) {
|
||||
is KtFunctionLiteral -> element.text
|
||||
is KtWhenEntry -> {
|
||||
if (element.isElse)
|
||||
"KtWhenEntry \"else\""
|
||||
else
|
||||
"KtWhenEntry \"" + element.conditions.joinToString(", ") { it.text } + "\""
|
||||
}
|
||||
is KtNamedDeclaration -> element.node.elementType.toString() + ":" + element.name
|
||||
else -> element.toString()
|
||||
}
|
||||
}
|
||||
.toList()
|
||||
.sorted()
|
||||
.joinToString("\n", "LocalSearchScope:\n")
|
||||
}
|
||||
|
||||
else -> this.displayName
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+31
@@ -171,6 +171,8 @@ abstract class OperatorReferenceSearcher<TReferenceElement : KtElement>(
|
||||
}
|
||||
|
||||
private fun doPlainSearch(scope: SearchScope) {
|
||||
testLog?.add("Used plain search of ${logPresentation(targetDeclaration)} in ${scope.logPresentation()}")
|
||||
|
||||
if (scope is LocalSearchScope) {
|
||||
for (element in scope.scope) {
|
||||
element.accept(object : PsiRecursiveElementWalkingVisitor() {
|
||||
@@ -209,4 +211,33 @@ abstract class OperatorReferenceSearcher<TReferenceElement : KtElement>(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun SearchScope.logPresentation(): String {
|
||||
return when (this) {
|
||||
searchScope -> "whole search scope"
|
||||
|
||||
is LocalSearchScope -> {
|
||||
scope
|
||||
.map { element ->
|
||||
" " + when (element) {
|
||||
is KtFunctionLiteral -> element.text
|
||||
is KtWhenEntry -> {
|
||||
if (element.isElse)
|
||||
"KtWhenEntry \"else\""
|
||||
else
|
||||
"KtWhenEntry \"" + element.conditions.joinToString(", ") { it.text } + "\""
|
||||
}
|
||||
is KtNamedDeclaration -> element.node.elementType.toString() + ":" + element.name
|
||||
else -> element.toString()
|
||||
}
|
||||
}
|
||||
.toList()
|
||||
.sorted()
|
||||
.joinToString("\n", "LocalSearchScope:\n")
|
||||
}
|
||||
|
||||
else -> this.displayName
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@ Resolved java class to descriptor: JavaSAM
|
||||
Searched references to JavaClass.takeSAM() in Kotlin files
|
||||
Searched references to JavaSAM in java files
|
||||
Searched references to pack.A
|
||||
Used plain search in LocalSearchScope:
|
||||
Used plain search of parameter a in A() in LocalSearchScope:
|
||||
CLASS:A
|
||||
{ val (x, y) = it }
|
||||
|
||||
+1
-1
@@ -12,5 +12,5 @@ Searched references to constructor in Kotlin files
|
||||
Searched references to f1() in Kotlin files
|
||||
Searched references to fun2 in Kotlin files
|
||||
Searched references to fun3 in Kotlin files
|
||||
Used plain search in LocalSearchScope:
|
||||
Used plain search of parameter a in A() in LocalSearchScope:
|
||||
CLASS:A
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
Searched references to A
|
||||
Used plain search in LocalSearchScope:
|
||||
Used plain search of parameter x in A() in LocalSearchScope:
|
||||
CLASS:A
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ Checked type of f()
|
||||
Resolved (x, y)
|
||||
Searched references to X
|
||||
Searched references to f() in Kotlin files
|
||||
Used plain search in LocalSearchScope:
|
||||
Used plain search of component1() in LocalSearchScope:
|
||||
CLASS:X
|
||||
FUN:component1
|
||||
FUN:component2
|
||||
+1
-1
@@ -3,7 +3,7 @@ Checked type of g()
|
||||
Resolved (x1, y1)
|
||||
Searched references to X
|
||||
Searched references to f() in Kotlin files
|
||||
Used plain search in LocalSearchScope:
|
||||
Used plain search of component1() in LocalSearchScope:
|
||||
CLASS:X
|
||||
FUN:component1
|
||||
FUN:component1
|
||||
|
||||
@@ -23,7 +23,7 @@ Searched references to pack.A
|
||||
Searched references to pack.X
|
||||
Searched references to parameter p1 in test2() in Kotlin files
|
||||
Searched references to parameter p2 in test2() in Kotlin files
|
||||
Used plain search in LocalSearchScope:
|
||||
Used plain search of parameter n in A() in LocalSearchScope:
|
||||
CLASS:A
|
||||
CLASS:X
|
||||
FUN:ext1
|
||||
|
||||
+1
-1
@@ -2,5 +2,5 @@ Checked type of a
|
||||
Resolved (x, y, z)
|
||||
Searched references to A
|
||||
Searched references to a in Kotlin files
|
||||
Used plain search in LocalSearchScope:
|
||||
Used plain search of parameter n in A() in LocalSearchScope:
|
||||
CLASS:A
|
||||
+1
-1
@@ -1 +1 @@
|
||||
Used plain search in whole search scope
|
||||
Used plain search of kotlin.Pair.component1() in whole search scope
|
||||
+5
-5
@@ -11,9 +11,9 @@ Searched references to a1 in Kotlin files
|
||||
Searched references to parameter a in B() in Kotlin files
|
||||
Searched references to parameter b in f() in Kotlin files
|
||||
Searched references to parameter c in f() in Kotlin files
|
||||
Used plain search in LocalSearchScope:
|
||||
CLASS:A
|
||||
Used plain search in LocalSearchScope:
|
||||
CLASS:B
|
||||
Used plain search in LocalSearchScope:
|
||||
Used plain search of C.component1() in LocalSearchScope:
|
||||
CLASS:C
|
||||
Used plain search of parameter a in B() in LocalSearchScope:
|
||||
CLASS:B
|
||||
Used plain search of parameter x in A() in LocalSearchScope:
|
||||
CLASS:A
|
||||
+1
-1
@@ -9,7 +9,7 @@ Searched references to Z2
|
||||
Searched references to f() in Kotlin files
|
||||
Searched references to parameter z1 in g() in Kotlin files
|
||||
Searched references to parameter z2 in g() in Kotlin files
|
||||
Used plain search in LocalSearchScope:
|
||||
Used plain search of component2() in LocalSearchScope:
|
||||
CLASS:X
|
||||
CLASS:Y
|
||||
CLASS:Z1
|
||||
|
||||
@@ -3,5 +3,5 @@ Resolved (x, y)
|
||||
Resolved (x, y, z)
|
||||
Searched references to A
|
||||
Searched references to parameter a in FOR in Kotlin files
|
||||
Used plain search in LocalSearchScope:
|
||||
CLASS:A
|
||||
Used plain search of parameter n in A() in LocalSearchScope:
|
||||
CLASS:A
|
||||
@@ -3,6 +3,6 @@ Resolved (x, y)
|
||||
Resolved (x1, y1)
|
||||
Searched references to A
|
||||
Searched references to list in Kotlin files
|
||||
Used plain search in LocalSearchScope:
|
||||
Used plain search of parameter x in A() in LocalSearchScope:
|
||||
CLASS:A
|
||||
FUN:x
|
||||
|
||||
@@ -11,7 +11,7 @@ Searched references to takeFun2() in Kotlin files
|
||||
Searched references to takeFun3() in Kotlin files
|
||||
Searched references to takeFuns() in Kotlin files
|
||||
Searched references to v in Kotlin files
|
||||
Used plain search in LocalSearchScope:
|
||||
Used plain search of parameter a in A() in LocalSearchScope:
|
||||
CLASS:A
|
||||
{ a, n -> val (x, y) = a!! }
|
||||
{ val (x, y ) = it }
|
||||
|
||||
+1
-1
@@ -6,6 +6,6 @@ Searched references to parameter a in x() in Kotlin files
|
||||
Searched references to parameter a in y1() in Kotlin files
|
||||
Searched references to parameter a in y2() in Kotlin files
|
||||
Searched references to parameter a in y3() in Kotlin files
|
||||
Used plain search in LocalSearchScope:
|
||||
Used plain search of parameter n in A() in LocalSearchScope:
|
||||
CLASS:A
|
||||
{ val (x2, y2) = this }
|
||||
+1
-1
@@ -10,7 +10,7 @@ Searched references to Z
|
||||
Searched references to f() in Kotlin files
|
||||
Searched references to g() in Kotlin files
|
||||
Searched references to h() in Kotlin files
|
||||
Used plain search in LocalSearchScope:
|
||||
Used plain search of X.component1() in LocalSearchScope:
|
||||
CLASS:X
|
||||
CLASS:Y
|
||||
CLASS:Z
|
||||
@@ -6,8 +6,8 @@ Searched references to parameter b1 in f() in Kotlin files
|
||||
Searched references to parameter b2 in f() in Kotlin files
|
||||
Searched references to parameter other in plus() in Kotlin files
|
||||
Searched references to plus() in Kotlin files
|
||||
Used plain search in LocalSearchScope:
|
||||
Used plain search of parameter x in A() in LocalSearchScope:
|
||||
CLASS:A
|
||||
Used plain search in LocalSearchScope:
|
||||
Used plain search of plus() in LocalSearchScope:
|
||||
CLASS:B
|
||||
FUN:plus
|
||||
+1
-1
@@ -4,5 +4,5 @@ Resolved (a2, n2)
|
||||
Searched references to A
|
||||
Searched references to parameter a in A() in Kotlin files
|
||||
Searched references to parameter a in f() in Kotlin files
|
||||
Used plain search in LocalSearchScope:
|
||||
Used plain search of parameter a in A() in LocalSearchScope:
|
||||
CLASS:A
|
||||
|
||||
+3
-3
@@ -7,7 +7,7 @@ Searched references to b in Kotlin files
|
||||
Searched references to parameter a in B() in Kotlin files
|
||||
Searched references to parameter a in f() in Kotlin files
|
||||
Searched references to parameter b in A() in Kotlin files
|
||||
Used plain search in LocalSearchScope:
|
||||
CLASS:A
|
||||
Used plain search in LocalSearchScope:
|
||||
Used plain search of parameter a in B() in LocalSearchScope:
|
||||
CLASS:B
|
||||
Used plain search of parameter b in A() in LocalSearchScope:
|
||||
CLASS:A
|
||||
@@ -1,5 +1,5 @@
|
||||
Searched references to A
|
||||
Used plain search in LocalSearchScope:
|
||||
Used plain search of parameter a in A() in LocalSearchScope:
|
||||
CLASS:A
|
||||
KtWhenEntry "else"
|
||||
KtWhenEntry "is A"
|
||||
|
||||
+1
-1
@@ -4,5 +4,5 @@ Resolved f(2)
|
||||
Resolved f(2)(2)
|
||||
Searched references to B
|
||||
Searched references to f() in Kotlin files
|
||||
Used plain search in LocalSearchScope:
|
||||
Used plain search of B.invoke() in LocalSearchScope:
|
||||
CLASS:B
|
||||
+2
-2
@@ -22,7 +22,7 @@ Searched references to a in Kotlin files
|
||||
Searched references to a in Kotlin files
|
||||
Searched references to parameter a in A.plus() in Kotlin files
|
||||
Searched references to parameter a in A.plus() in Kotlin files
|
||||
Used plain search in LocalSearchScope:
|
||||
Used plain search of A.plus() in LocalSearchScope:
|
||||
CLASS:A
|
||||
Used plain search in LocalSearchScope:
|
||||
Used plain search of A.plus() in LocalSearchScope:
|
||||
CLASS:A
|
||||
@@ -403,14 +403,15 @@ public abstract class AbstractFindUsagesTest extends KotlinLightCodeInsightFixtu
|
||||
|
||||
Collection<UsageInfo> usageInfos;
|
||||
String log = null;
|
||||
ArrayList<String> logList = new ArrayList<String>();
|
||||
try {
|
||||
ExpressionsOfTypeProcessor.Companion.setTestLog(new ArrayList<String>());
|
||||
if (ExpressionsOfTypeProcessor.Companion.getMode() != ExpressionsOfTypeProcessor.Mode.ALWAYS_PLAIN) {
|
||||
ExpressionsOfTypeProcessor.Companion.setTestLog(logList);
|
||||
}
|
||||
|
||||
usageInfos = findUsages(caretElement, options, highlightingMode);
|
||||
}
|
||||
finally {
|
||||
List<String> logList = ExpressionsOfTypeProcessor.Companion.getTestLog();
|
||||
assert logList != null;
|
||||
ExpressionsOfTypeProcessor.Companion.setTestLog(null);
|
||||
if (logList.size() > 0) {
|
||||
Collections.sort(logList);
|
||||
|
||||
Reference in New Issue
Block a user