Changes on code review

This commit is contained in:
Valentin Kipyatkov
2015-07-31 21:46:03 +03:00
parent 397e48a11d
commit c2c6ba59fd
5 changed files with 19 additions and 6 deletions
@@ -62,7 +62,7 @@ public abstract class AbstractJetParsingTest extends ParsingTestCase {
if (!methodName.startsWith("get") && !methodName.startsWith("find") || if (!methodName.startsWith("get") && !methodName.startsWith("find") ||
methodName.equals("getReference") || methodName.equals("getReference") ||
methodName.equals("getReferences") || methodName.equals("getReferences") ||
methodName.startsWith("getUseScope") || methodName.equals("getUseScope") ||
methodName.equals("getPresentation")) { methodName.equals("getPresentation")) {
continue; continue;
} }
@@ -49,10 +49,15 @@ public class KotlinReferencesSearcher : QueryExecutorBase<PsiReference, Referenc
val effectiveSearchScope = runReadAction { queryParameters.effectiveSearchScope } val effectiveSearchScope = runReadAction { queryParameters.effectiveSearchScope }
val refFilter: (PsiReference) -> Boolean = if (unwrappedElement is JetParameter)
({ ref: PsiReference -> !ref.isNamedArgumentReference()/* they are processed later*/ })
else
({true})
words.forEach { word -> words.forEach { word ->
queryParameters.optimizer.searchWord(word, effectiveSearchScope, queryParameters.optimizer.searchWord(word, effectiveSearchScope,
UsagesSearchLocation.EVERYWHERE.searchContext, true, unwrappedElement, UsagesSearchLocation.EVERYWHERE.searchContext, true, unwrappedElement,
MyRequestResultProcessor(unwrappedElement) { !it.isNamedArgumentReference()/* they are processed later*/ }) MyRequestResultProcessor(unwrappedElement, refFilter))
} }
if (unwrappedElement is JetParameter) { if (unwrappedElement is JetParameter) {
@@ -71,7 +76,7 @@ public class KotlinReferencesSearcher : QueryExecutorBase<PsiReference, Referenc
var namedArgsScope = function.useScope.intersectWith(queryParameters.scopeDeterminedByUser) var namedArgsScope = function.useScope.intersectWith(queryParameters.scopeDeterminedByUser)
if (namedArgsScope is GlobalSearchScope) { if (namedArgsScope is GlobalSearchScope) {
namedArgsScope = JetSourceFilterScope.kotlinSources(namedArgsScope, project) namedArgsScope = JetSourceFilterScope.kotlinSourcesAndLibraries(namedArgsScope, project)
val filesWithFunctionName = CacheManager.SERVICE.getInstance(project).getVirtualFilesWithWord( val filesWithFunctionName = CacheManager.SERVICE.getInstance(project).getVirtualFilesWithWord(
function.name!!, UsageSearchContext.IN_CODE, namedArgsScope, true) function.name!!, UsageSearchContext.IN_CODE, namedArgsScope, true)
@@ -268,14 +268,14 @@ class PropertyUsagesSearchHelper(
var scope = function.useScope and target.effectiveScope var scope = function.useScope and target.effectiveScope
if (scope is GlobalSearchScope) { if (scope is GlobalSearchScope) {
scope = JetSourceFilterScope.kotlinSources(scope, element.project) scope = JetSourceFilterScope.kotlinSourcesAndLibraries(scope, element.project)
} }
val additionalFilter1 = AdditionalFileFilter(element.name!!, KOTLIN_NAMED_ARGUMENT_SEARCH_CONTEXT, true) val additionalFilter1 = AdditionalFileFilter(element.name!!, KOTLIN_NAMED_ARGUMENT_SEARCH_CONTEXT, true)
val additionalFilter2 = AdditionalFileFilter(function.name!!, UsageSearchContext.IN_CODE, true) val additionalFilter2 = AdditionalFileFilter(function.name!!, UsageSearchContext.IN_CODE, true)
val namedArgsRequest = UsagesSearchRequestItem(target.withScope(scope), val namedArgsRequest = UsagesSearchRequestItem(target.withScope(scope),
listOf(element.name!!), listOf(element.name!!),
(PsiReference::isNamedArgumentUsage).searchFilter, (PsiReference::isNamedArgumentUsage).searchFilter and makeFilter(target),
additionalFileFilters = listOf(additionalFilter1, additionalFilter2)) additionalFileFilters = listOf(additionalFilter1, additionalFilter2))
return listOf(realUsagesRequest, namedArgsRequest) return listOf(realUsagesRequest, namedArgsRequest)
} }
@@ -5,6 +5,14 @@ fun foo<T>(<caret>t: T): T {
return t return t
} }
fun bar(t: String) {
print(t)
}
fun usage() { fun usage() {
foo(t = ":)") foo(t = ":)")
} }
fun falseUsage() {
bar(t = "")
}
@@ -1,3 +1,3 @@
Named argument (9: 9) foo(t = ":)") Named argument (13: 9) foo(t = ":)")
Value read (4: 13) println(t) Value read (4: 13) println(t)
Value read (5: 12) return t Value read (5: 12) return t