Optimization of parameter usages search

This commit is contained in:
Valentin Kipyatkov
2015-07-30 12:18:02 +03:00
parent 1d1d834901
commit 9bb2fe9a67
7 changed files with 153 additions and 69 deletions
@@ -179,13 +179,24 @@ public class JetParameter extends JetNamedDeclarationStub<KotlinParameterStub> i
@NotNull
@Override
public SearchScope getUseScope() {
PsiElement parent = getParent();
if (parent != null) {
PsiElement grandparent = parent.getParent();
if (grandparent instanceof JetFunction && !(grandparent instanceof JetFunctionLiteral)) {
return grandparent.getUseScope();
}
JetDeclaration function = getOwnerFunction();
if (function != null && !(function instanceof JetFunctionLiteral)) {
return function.getUseScope();
}
return super.getUseScope();
}
@NotNull
public SearchScope getUseScopeExceptNamedArguments() {
return super.getUseScope();
}
@Nullable
public JetFunction getOwnerFunction() {
PsiElement parent = getParent();
if (parent == null) return null;
PsiElement grandparent = parent.getParent();
if (!(grandparent instanceof JetFunction)) return null;
return (JetFunction) grandparent;
}
}