Fixed for companion object members

This commit is contained in:
Valentin Kipyatkov
2015-11-06 20:04:17 +03:00
parent d599b77ece
commit d3f04c6310
4 changed files with 26 additions and 5 deletions
@@ -57,11 +57,7 @@ class ImportMemberIntention : SelfTargetingOffsetIndependentIntention<KtNameRefe
val qualifiedExpressions = file.collectDescendantsOfType<KtDotQualifiedExpression> { qualifiedExpression ->
val selector = qualifiedExpression.getQualifiedElementSelector() as? KtNameReferenceExpression
?: return@collectDescendantsOfType false
val qualifierName = qualifiedExpression.receiverExpression.getQualifiedElementSelector() as? KtNameReferenceExpression
?: return@collectDescendantsOfType false
selector.getReferencedNameAsName() == fqName.shortName()
&& qualifierName.getReferencedNameAsName() == fqName.parent().shortName()
&& targetFqName(qualifiedExpression) == fqName
selector.getReferencedNameAsName() == fqName.shortName() && targetFqName(qualifiedExpression) == fqName
}
//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);
}
@TestMetadata("FromCompanionObject.kt")
public void testFromCompanionObject() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/importMember/FromCompanionObject.kt");
doTest(fileName);
}
@TestMetadata("NoTarget.kt")
public void testNoTarget() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/importMember/NoTarget.kt");