Synthetic extensions suggested in completion
This commit is contained in:
+12
-8
@@ -217,16 +217,20 @@ public class LookupElementFactory(
|
||||
|
||||
if (descriptor is CallableDescriptor) {
|
||||
if (descriptor.getExtensionReceiverParameter() != null) {
|
||||
val container = descriptor.getContainingDeclaration()
|
||||
val containerPresentation = if (container is ClassDescriptor) {
|
||||
DescriptorUtils.getFqNameFromTopLevelClass(container).toString()
|
||||
}
|
||||
else {
|
||||
DescriptorUtils.getFqName(container).toString()
|
||||
}
|
||||
val originalReceiver = descriptor.getOriginal().getExtensionReceiverParameter()!!
|
||||
val receiverPresentation = DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(originalReceiver.getType())
|
||||
element = element.appendTailText(" for $receiverPresentation in $containerPresentation", true)
|
||||
element = element.appendTailText(" for $receiverPresentation", true)
|
||||
|
||||
val container = descriptor.getContainingDeclaration()
|
||||
val containerPresentation = if (container is ClassDescriptor)
|
||||
DescriptorUtils.getFqNameFromTopLevelClass(container).toString()
|
||||
else if (container is PackageFragmentDescriptor)
|
||||
container.fqName.toString()
|
||||
else
|
||||
null
|
||||
if (containerPresentation != null) {
|
||||
element = element.appendTailText(" in $containerPresentation", true)
|
||||
}
|
||||
}
|
||||
else {
|
||||
val container = descriptor.getContainingDeclaration()
|
||||
|
||||
@@ -3,6 +3,8 @@ package a.b
|
||||
class Some {
|
||||
inner class Inner {
|
||||
fun foo() {
|
||||
fun String.localExtension() = 1
|
||||
|
||||
"".<caret>
|
||||
}
|
||||
|
||||
@@ -19,3 +21,4 @@ val String.extProp: Int get() = 1
|
||||
// EXIST: { lookupString: "extProp", itemText: "extProp", tailText: " for String in a.b", typeText: "Int" }
|
||||
// EXIST: { lookupString: "memberExtFun", itemText: "memberExtFun", tailText: "() for String in Some.Inner", typeText: "Unit" }
|
||||
// EXIST: { lookupString: "memberExtProp", itemText: "memberExtProp", tailText: " for String in Some", typeText: "Int" }
|
||||
// EXIST: { lookupString: "localExtension", itemText: "localExtension", tailText: "() for String", typeText: "Int" }
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import java.io.File
|
||||
|
||||
fun foo(file: File) {
|
||||
file.<caret>
|
||||
}
|
||||
|
||||
// EXIST_JAVA_ONLY: { lookupString: "absolutePath", itemText: "absolutePath", tailText: " for File", typeText: "String!" }
|
||||
@@ -0,0 +1,7 @@
|
||||
import java.io.File
|
||||
|
||||
fun File.foo() {
|
||||
<caret>
|
||||
}
|
||||
|
||||
// EXIST_JAVA_ONLY: { lookupString: "absolutePath", itemText: "absolutePath", tailText: " for File", typeText: "String!" }
|
||||
@@ -0,0 +1,7 @@
|
||||
import java.io.File
|
||||
|
||||
fun foo(file: File) {
|
||||
file.abs<caret>
|
||||
}
|
||||
|
||||
// ELEMENT: absolutePath
|
||||
@@ -0,0 +1,7 @@
|
||||
import java.io.File
|
||||
|
||||
fun foo(file: File) {
|
||||
file.absolutePath<caret>
|
||||
}
|
||||
|
||||
// ELEMENT: absolutePath
|
||||
+12
@@ -1209,6 +1209,18 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("SyntheticExtensions1.kt")
|
||||
public void testSyntheticExtensions1() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions1.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("SyntheticExtensions2.kt")
|
||||
public void testSyntheticExtensions2() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions2.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("WrongExplicitReceiver.kt")
|
||||
public void testWrongExplicitReceiver() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/WrongExplicitReceiver.kt");
|
||||
|
||||
+12
@@ -1209,6 +1209,18 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("SyntheticExtensions1.kt")
|
||||
public void testSyntheticExtensions1() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions1.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("SyntheticExtensions2.kt")
|
||||
public void testSyntheticExtensions2() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions2.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("WrongExplicitReceiver.kt")
|
||||
public void testWrongExplicitReceiver() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/WrongExplicitReceiver.kt");
|
||||
|
||||
+6
@@ -119,6 +119,12 @@ public class BasicCompletionHandlerTestGenerated extends AbstractBasicCompletion
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("SyntheticExtension.kt")
|
||||
public void testSyntheticExtension() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/SyntheticExtension.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("idea/idea-completion/testData/handlers/basic/exclChar")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
Reference in New Issue
Block a user