More proper fix for KT-8137/EA-69470: avoiding failed assertion when searching usages of parameter of local class constructor
KT-8137 AE at JetSourceNavigationHelper.convertNamedClassOrObject() on function local class with several constructor parameters #KT-8137 fixed #EA-69470 fixed
This commit is contained in:
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.psi
|
||||
import com.intellij.lang.ASTNode
|
||||
import com.intellij.navigation.ItemPresentationProviders
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.search.SearchScope
|
||||
import com.intellij.util.IncorrectOperationException
|
||||
import org.jetbrains.kotlin.lexer.JetTokens
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
@@ -89,4 +90,8 @@ public abstract class JetConstructor<T : JetConstructor<T>> : JetDeclarationStub
|
||||
?: getValueParameterList()?.getTextOffset()
|
||||
?: super<JetDeclarationStub>.getTextOffset()
|
||||
}
|
||||
|
||||
override fun getUseScope(): SearchScope {
|
||||
return getContainingClassOrObject().getUseScope()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ public class JetParameter extends JetNamedDeclarationStub<KotlinParameterStub> i
|
||||
PsiElement parent = getParent();
|
||||
if (parent != null) {
|
||||
PsiElement grandparent = parent.getParent();
|
||||
if (grandparent instanceof JetNamedFunction) {
|
||||
if (grandparent instanceof JetFunction && !(grandparent instanceof JetFunctionLiteral)) {
|
||||
return grandparent.getUseScope();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -775,9 +775,9 @@ public class JetPsiUtil {
|
||||
else if (declaration instanceof JetParameter) {
|
||||
PsiElement parent = declaration.getParent();
|
||||
|
||||
// val/var parameter of primary constructor should not be considered as local
|
||||
// val/var parameter of primary constructor should be considered as local according to containing class
|
||||
if (((JetParameter) declaration).hasValOrVar() && parent != null && parent.getParent() instanceof JetPrimaryConstructor) {
|
||||
return null;
|
||||
return getEnclosingElementForLocalDeclaration(((JetPrimaryConstructor) parent.getParent()).getContainingClassOrObject(), skipParameters);
|
||||
}
|
||||
|
||||
else if (skipParameters && parent != null && parent.getParent() instanceof JetNamedFunction) {
|
||||
|
||||
Reference in New Issue
Block a user