Fixed bug in reference shortening
This commit is contained in:
@@ -43,12 +43,12 @@ public object ShortenReferences {
|
||||
}
|
||||
|
||||
override fun visitJetElement(element : JetElement) {
|
||||
element.acceptChildren(this)
|
||||
acceptChildren(element)
|
||||
}
|
||||
|
||||
override fun visitUserType(userType: JetUserType) {
|
||||
val resultElement = processType(userType)
|
||||
resultElement.acceptChildren(this)
|
||||
acceptChildren(resultElement)
|
||||
}
|
||||
|
||||
private fun processType(userType: JetUserType): PsiElement {
|
||||
@@ -88,7 +88,7 @@ public object ShortenReferences {
|
||||
|
||||
override fun visitDotQualifiedExpression(expression: JetDotQualifiedExpression) {
|
||||
val resultElement = processDotQualifiedExpression(expression)
|
||||
resultElement.acceptChildren(this)
|
||||
acceptChildren(resultElement)
|
||||
}
|
||||
|
||||
private fun processDotQualifiedExpression(qualifiedExpression: JetDotQualifiedExpression): PsiElement {
|
||||
@@ -180,6 +180,16 @@ public object ShortenReferences {
|
||||
private fun addImportIfNeeded(descriptor : DeclarationDescriptor) {
|
||||
ImportInsertHelper.addImportDirectiveIfNeeded(DescriptorUtils.getFqNameSafe(descriptor), file)
|
||||
}
|
||||
|
||||
// we do not use standard PsiElement.acceptChildren because it won't work correctly if the element is replaced by the visitor
|
||||
private fun acceptChildren(element: PsiElement) {
|
||||
var child = element.getFirstChild()
|
||||
while(child != null) {
|
||||
val nextChild = child!!.getNextSibling()
|
||||
child!!.accept(this)
|
||||
child = nextChild
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun referenceExpression(selectorExpression: JetExpression) = if (selectorExpression is JetCallExpression)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// "Specify type explicitly" "true"
|
||||
import java.sql
|
||||
|
||||
fun getEntry() : Map.Entry<jet.Array<String>, java.sql.Array> {
|
||||
}
|
||||
|
||||
val x: Map.Entry<Array<String>, java.sql.Array> = getEntry()
|
||||
val x: Map.Entry<Array<String>, sql.Array> = getEntry()
|
||||
@@ -0,0 +1 @@
|
||||
val x: <selection>jet.Map.Entry<jet.Array<jet.String>, java.sql.Array></selection>
|
||||
@@ -0,0 +1,3 @@
|
||||
import java.sql
|
||||
|
||||
val x: Map.Entry<Array<String>, sql.Array>
|
||||
@@ -126,6 +126,11 @@ public class ShortenRefsTestGenerated extends AbstractShortenRefsTest {
|
||||
doTest("idea/testData/shortenRefs/type/GenericType2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("GenericType3.kt")
|
||||
public void testGenericType3() throws Exception {
|
||||
doTest("idea/testData/shortenRefs/type/GenericType3.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("LeaveQualified.kt")
|
||||
public void testLeaveQualified() throws Exception {
|
||||
doTest("idea/testData/shortenRefs/type/LeaveQualified.kt");
|
||||
|
||||
Reference in New Issue
Block a user