Fix bug in ShortenReferences visitor (do not skip PSI elements after modication)
This commit is contained in:
@@ -107,13 +107,17 @@ public object ShortenReferences {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ShortenQualifiedExpressionsVisitor(val file: JetFile, val resolveMap: Map<JetReferenceExpression, BindingContext>) : JetTreeVisitorVoid() {
|
private class ShortenQualifiedExpressionsVisitor(val file: JetFile, val resolveMap: Map<JetReferenceExpression, BindingContext>) : JetVisitorVoid() {
|
||||||
private val resolveSession : ResolveSessionForBodies
|
private val resolveSession : ResolveSessionForBodies
|
||||||
get() = AnalyzerFacadeWithCache.getLazyResolveSessionForFile(file)
|
get() = AnalyzerFacadeWithCache.getLazyResolveSessionForFile(file)
|
||||||
|
|
||||||
private fun bindingContext(expression: JetReferenceExpression): BindingContext
|
private fun bindingContext(expression: JetReferenceExpression): BindingContext
|
||||||
= resolveMap[expression] ?: resolveSession.resolveToElement(expression) // binding context can be absent in the map if some references have been shortened already
|
= resolveMap[expression] ?: resolveSession.resolveToElement(expression) // binding context can be absent in the map if some references have been shortened already
|
||||||
|
|
||||||
|
override fun visitJetElement(element: JetElement) {
|
||||||
|
acceptChildren(element)
|
||||||
|
}
|
||||||
|
|
||||||
override fun visitDotQualifiedExpression(expression: JetDotQualifiedExpression) {
|
override fun visitDotQualifiedExpression(expression: JetDotQualifiedExpression) {
|
||||||
val resultElement = processDotQualifiedExpression(expression)
|
val resultElement = processDotQualifiedExpression(expression)
|
||||||
acceptChildren(resultElement)
|
acceptChildren(resultElement)
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package p.q
|
||||||
|
|
||||||
|
<selection>fun foo(): Int {
|
||||||
|
p.q.MyClass.foo()
|
||||||
|
return p.q.MyClass.coProp + 10
|
||||||
|
}</selection>
|
||||||
|
|
||||||
|
class MyClass {
|
||||||
|
class object {
|
||||||
|
val coProp = 1
|
||||||
|
|
||||||
|
fun foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package p.q
|
||||||
|
|
||||||
|
fun foo(): Int {
|
||||||
|
MyClass.foo()
|
||||||
|
return MyClass.coProp + 10
|
||||||
|
}
|
||||||
|
|
||||||
|
class MyClass {
|
||||||
|
class object {
|
||||||
|
val coProp = 1
|
||||||
|
|
||||||
|
fun foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -37,6 +37,11 @@ public class ShortenRefsTestGenerated extends AbstractShortenRefsTest {
|
|||||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/shortenRefs"), Pattern.compile("^([^\\.]+)\\.kt$"), true);
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/shortenRefs"), Pattern.compile("^([^\\.]+)\\.kt$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("classObject.kt")
|
||||||
|
public void testClassObject() throws Exception {
|
||||||
|
doTest("idea/testData/shortenRefs/classObject.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("JavaStaticMethod.kt")
|
@TestMetadata("JavaStaticMethod.kt")
|
||||||
public void testJavaStaticMethod() throws Exception {
|
public void testJavaStaticMethod() throws Exception {
|
||||||
doTest("idea/testData/shortenRefs/JavaStaticMethod.kt");
|
doTest("idea/testData/shortenRefs/JavaStaticMethod.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user