Fixed for companion object members
This commit is contained in:
@@ -57,11 +57,7 @@ class ImportMemberIntention : SelfTargetingOffsetIndependentIntention<KtNameRefe
|
|||||||
val qualifiedExpressions = file.collectDescendantsOfType<KtDotQualifiedExpression> { qualifiedExpression ->
|
val qualifiedExpressions = file.collectDescendantsOfType<KtDotQualifiedExpression> { qualifiedExpression ->
|
||||||
val selector = qualifiedExpression.getQualifiedElementSelector() as? KtNameReferenceExpression
|
val selector = qualifiedExpression.getQualifiedElementSelector() as? KtNameReferenceExpression
|
||||||
?: return@collectDescendantsOfType false
|
?: return@collectDescendantsOfType false
|
||||||
val qualifierName = qualifiedExpression.receiverExpression.getQualifiedElementSelector() as? KtNameReferenceExpression
|
selector.getReferencedNameAsName() == fqName.shortName() && targetFqName(qualifiedExpression) == fqName
|
||||||
?: return@collectDescendantsOfType false
|
|
||||||
selector.getReferencedNameAsName() == fqName.shortName()
|
|
||||||
&& qualifierName.getReferencedNameAsName() == fqName.parent().shortName()
|
|
||||||
&& targetFqName(qualifiedExpression) == fqName
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: not deep
|
//TODO: not deep
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
// INTENTION_TEXT: "Add import for 'kotlin.text.Regex.Companion.escape'"
|
||||||
|
// WITH_RUNTIME
|
||||||
|
|
||||||
|
import kotlin.text.Regex
|
||||||
|
|
||||||
|
fun foo() {
|
||||||
|
Regex.<caret>escape("")
|
||||||
|
Regex.Companion.escape("")
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// INTENTION_TEXT: "Add import for 'kotlin.text.Regex.Companion.escape'"
|
||||||
|
// WITH_RUNTIME
|
||||||
|
|
||||||
|
import kotlin.text.Regex
|
||||||
|
import kotlin.text.Regex.Companion.escape
|
||||||
|
|
||||||
|
fun foo() {
|
||||||
|
<caret>escape("")
|
||||||
|
escape("")
|
||||||
|
}
|
||||||
@@ -5112,6 +5112,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("FromCompanionObject.kt")
|
||||||
|
public void testFromCompanionObject() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/importMember/FromCompanionObject.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("NoTarget.kt")
|
@TestMetadata("NoTarget.kt")
|
||||||
public void testNoTarget() throws Exception {
|
public void testNoTarget() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/importMember/NoTarget.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/importMember/NoTarget.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user