Make ResolveSessionForBodies.resolveToDescriptor() work for local declarations (EA-56877)
Fix (EA-56877)
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2013 JetBrains s.r.o.
|
* Copyright 2010-2014 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -27,6 +27,7 @@ import org.jetbrains.jet.lang.descriptors.ModuleDescriptor;
|
|||||||
import org.jetbrains.jet.lang.descriptors.ScriptDescriptor;
|
import org.jetbrains.jet.lang.descriptors.ScriptDescriptor;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
|
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||||
import org.jetbrains.jet.lang.resolve.lazy.KotlinCodeAnalyzer;
|
import org.jetbrains.jet.lang.resolve.lazy.KotlinCodeAnalyzer;
|
||||||
import org.jetbrains.jet.lang.resolve.lazy.ResolveSession;
|
import org.jetbrains.jet.lang.resolve.lazy.ResolveSession;
|
||||||
import org.jetbrains.jet.lang.resolve.lazy.ScopeProvider;
|
import org.jetbrains.jet.lang.resolve.lazy.ScopeProvider;
|
||||||
@@ -78,7 +79,14 @@ public class ResolveSessionForBodies implements KotlinCodeAnalyzer, Modification
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public DeclarationDescriptor resolveToDescriptor(JetDeclaration declaration) {
|
public DeclarationDescriptor resolveToDescriptor(JetDeclaration declaration) {
|
||||||
return resolveSession.resolveToDescriptor(declaration);
|
if (!JetPsiUtil.isLocal(declaration)) {
|
||||||
|
return resolveSession.resolveToDescriptor(declaration);
|
||||||
|
}
|
||||||
|
|
||||||
|
BindingContext context = resolveElementCache.resolveToElement(declaration);
|
||||||
|
return BindingContextUtils.getNotNull(context, BindingContext.DECLARATION_TO_DESCRIPTOR, declaration,
|
||||||
|
"Descriptor wasn't found for declaration " + declaration.toString() + "\n" +
|
||||||
|
JetPsiUtil.getElementTextWithContext(declaration));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// "Make A.foo open" "true"
|
||||||
|
open class A {
|
||||||
|
open fun foo() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
val some = object : A() {
|
||||||
|
<caret>override fun foo() {}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// "Make A.foo open" "true"
|
||||||
|
open class A {
|
||||||
|
fun foo() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
val some = object : A() {
|
||||||
|
<caret>override fun foo() {}
|
||||||
|
}
|
||||||
|
}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
// "Add 'open fun f()' to 'A'" "true"
|
||||||
|
open class A {
|
||||||
|
open fun f() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
val some = object : A() {
|
||||||
|
<caret>override fun f() {}
|
||||||
|
}
|
||||||
|
}
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
// "Add 'open fun f()' to 'A'" "true"
|
||||||
|
open class A {
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
val some = object : A() {
|
||||||
|
<caret>override fun f() {}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1092,6 +1092,11 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
|||||||
doTest("idea/testData/quickfix/override/beforeOverridingFinalMethod.kt");
|
doTest("idea/testData/quickfix/override/beforeOverridingFinalMethod.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("beforeOverridingFinalMethodInLocal.kt")
|
||||||
|
public void testOverridingFinalMethodInLocal() throws Exception {
|
||||||
|
doTest("idea/testData/quickfix/override/beforeOverridingFinalMethodInLocal.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("beforeOverridingFinalProperty.kt")
|
@TestMetadata("beforeOverridingFinalProperty.kt")
|
||||||
public void testOverridingFinalProperty() throws Exception {
|
public void testOverridingFinalProperty() throws Exception {
|
||||||
doTest("idea/testData/quickfix/override/beforeOverridingFinalProperty.kt");
|
doTest("idea/testData/quickfix/override/beforeOverridingFinalProperty.kt");
|
||||||
@@ -1134,6 +1139,11 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
|||||||
doTest("idea/testData/quickfix/override/nothingToOverride/beforeAddFunctionAbstractClass.kt");
|
doTest("idea/testData/quickfix/override/nothingToOverride/beforeAddFunctionAbstractClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("beforeAddFunctionInLocalDeclaration.kt")
|
||||||
|
public void testAddFunctionInLocalDeclaration() throws Exception {
|
||||||
|
doTest("idea/testData/quickfix/override/nothingToOverride/beforeAddFunctionInLocalDeclaration.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("beforeAddFunctionNoBody.kt")
|
@TestMetadata("beforeAddFunctionNoBody.kt")
|
||||||
public void testAddFunctionNoBody() throws Exception {
|
public void testAddFunctionNoBody() throws Exception {
|
||||||
doTest("idea/testData/quickfix/override/nothingToOverride/beforeAddFunctionNoBody.kt");
|
doTest("idea/testData/quickfix/override/nothingToOverride/beforeAddFunctionNoBody.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user