Completion: no qualified this for anonymous object + no keyword escaping for qualified this
This commit is contained in:
@@ -22,9 +22,6 @@ import org.jetbrains.jet.lang.descriptors.ReceiverParameterDescriptor
|
|||||||
import com.intellij.codeInsight.lookup.LookupElementBuilder
|
import com.intellij.codeInsight.lookup.LookupElementBuilder
|
||||||
import org.jetbrains.jet.renderer.DescriptorRenderer
|
import org.jetbrains.jet.renderer.DescriptorRenderer
|
||||||
import org.jetbrains.jet.lang.psi.JetFunctionLiteral
|
import org.jetbrains.jet.lang.psi.JetFunctionLiteral
|
||||||
import org.jetbrains.jet.lang.psi.JetFunctionLiteralExpression
|
|
||||||
import org.jetbrains.jet.lang.psi.JetObjectDeclaration
|
|
||||||
import org.jetbrains.jet.lang.psi.JetObjectLiteralExpression
|
|
||||||
import org.jetbrains.jet.lang.psi.JetValueArgument
|
import org.jetbrains.jet.lang.psi.JetValueArgument
|
||||||
import org.jetbrains.jet.lang.psi.JetValueArgumentList
|
import org.jetbrains.jet.lang.psi.JetValueArgumentList
|
||||||
import org.jetbrains.jet.lang.psi.JetCallExpression
|
import org.jetbrains.jet.lang.psi.JetCallExpression
|
||||||
@@ -33,6 +30,7 @@ import org.jetbrains.jet.lang.resolve.BindingContext
|
|||||||
import org.jetbrains.jet.plugin.completion.ExpectedInfo
|
import org.jetbrains.jet.plugin.completion.ExpectedInfo
|
||||||
import org.jetbrains.jet.plugin.util.makeNotNullable
|
import org.jetbrains.jet.plugin.util.makeNotNullable
|
||||||
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils
|
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils
|
||||||
|
import org.jetbrains.jet.lang.psi.JetFunctionLiteralExpression
|
||||||
|
|
||||||
class ThisItems(val bindingContext: BindingContext) {
|
class ThisItems(val bindingContext: BindingContext) {
|
||||||
public fun addToCollection(collection: MutableCollection<LookupElement>, context: JetExpression, expectedInfos: Collection<ExpectedInfo>) {
|
public fun addToCollection(collection: MutableCollection<LookupElement>, context: JetExpression, expectedInfos: Collection<ExpectedInfo>) {
|
||||||
@@ -65,20 +63,16 @@ class ThisItems(val bindingContext: BindingContext) {
|
|||||||
val descriptor = receiver.getContainingDeclaration()
|
val descriptor = receiver.getContainingDeclaration()
|
||||||
val name = descriptor.getName()
|
val name = descriptor.getName()
|
||||||
if (!name.isSpecial()) {
|
if (!name.isSpecial()) {
|
||||||
return DescriptorRenderer.SOURCE_CODE.renderName(name)
|
return name.asString()
|
||||||
}
|
}
|
||||||
|
|
||||||
val psiElement = DescriptorToSourceUtils.descriptorToDeclaration(descriptor)
|
val functionLiteral = DescriptorToSourceUtils.descriptorToDeclaration(descriptor) as? JetFunctionLiteral
|
||||||
val expression = when (psiElement) {
|
return (((((functionLiteral?.getParent() as? JetFunctionLiteralExpression)
|
||||||
is JetFunctionLiteral -> psiElement.getParent() as? JetFunctionLiteralExpression
|
?.getParent() as? JetValueArgument)
|
||||||
is JetObjectDeclaration -> psiElement.getParent() as? JetObjectLiteralExpression
|
?.getParent() as? JetValueArgumentList)
|
||||||
else -> null
|
?.getParent() as? JetCallExpression)
|
||||||
}
|
?.getCalleeExpression() as? JetSimpleNameExpression)
|
||||||
return ((((expression?.getParent() as? JetValueArgument)
|
?.getReferencedName()
|
||||||
?.getParent() as? JetValueArgumentList)
|
|
||||||
?.getParent() as? JetCallExpression)
|
|
||||||
?.getCalleeExpression() as? JetSimpleNameExpression)
|
|
||||||
?.getReferencedName()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
class `this` {
|
||||||
|
fun String.foo(){
|
||||||
|
val foo: `this` = <caret>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ELEMENT: "this@this"
|
||||||
|
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
class `this` {
|
||||||
|
fun String.foo(){
|
||||||
|
val foo: `this` = this@this<caret>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ELEMENT: "this@this"
|
||||||
|
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
fun `fun`(handler: String.() -> Unit){}
|
||||||
|
fun bar(handler: Int.() -> Unit){}
|
||||||
|
|
||||||
|
fun foo(){
|
||||||
|
`fun`({
|
||||||
|
bar({
|
||||||
|
val s: String = <caret>
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// ELEMENT: this@fun
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
fun `fun`(handler: String.() -> Unit){}
|
||||||
|
fun bar(handler: Int.() -> Unit){}
|
||||||
|
|
||||||
|
fun foo(){
|
||||||
|
`fun`({
|
||||||
|
bar({
|
||||||
|
val s: String = this@fun<caret>
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// ELEMENT: this@fun
|
||||||
+1
-1
@@ -12,4 +12,4 @@ fun bar() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// EXIST: this@foo
|
// ABSENT: this@foo
|
||||||
@@ -388,6 +388,11 @@ public class JvmSmartCompletionTestGenerated extends AbstractJvmSmartCompletionT
|
|||||||
doTest("idea/testData/completion/smart/NoPrivateOverload.kt");
|
doTest("idea/testData/completion/smart/NoPrivateOverload.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("NoQualifiedThisOfAnonymousObject.kt")
|
||||||
|
public void testNoQualifiedThisOfAnonymousObject() throws Exception {
|
||||||
|
doTest("idea/testData/completion/smart/NoQualifiedThisOfAnonymousObject.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("NoSillyAssignment.kt")
|
@TestMetadata("NoSillyAssignment.kt")
|
||||||
public void testNoSillyAssignment() throws Exception {
|
public void testNoSillyAssignment() throws Exception {
|
||||||
doTest("idea/testData/completion/smart/NoSillyAssignment.kt");
|
doTest("idea/testData/completion/smart/NoSillyAssignment.kt");
|
||||||
@@ -463,11 +468,6 @@ public class JvmSmartCompletionTestGenerated extends AbstractJvmSmartCompletionT
|
|||||||
doTest("idea/testData/completion/smart/QualifiedThis.kt");
|
doTest("idea/testData/completion/smart/QualifiedThis.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("QualifiedThisOfAnonymousObject.kt")
|
|
||||||
public void testQualifiedThisOfAnonymousObject() throws Exception {
|
|
||||||
doTest("idea/testData/completion/smart/QualifiedThisOfAnonymousObject.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("QualifiedThisOfExtensionFunction.kt")
|
@TestMetadata("QualifiedThisOfExtensionFunction.kt")
|
||||||
public void testQualifiedThisOfExtensionFunction() throws Exception {
|
public void testQualifiedThisOfExtensionFunction() throws Exception {
|
||||||
doTest("idea/testData/completion/smart/QualifiedThisOfExtensionFunction.kt");
|
doTest("idea/testData/completion/smart/QualifiedThisOfExtensionFunction.kt");
|
||||||
|
|||||||
+10
@@ -383,6 +383,16 @@ public class SmartCompletionHandlerTestGenerated extends AbstractSmartCompletion
|
|||||||
doTest("idea/testData/completion/handlers/smart/ObjectFromType.kt");
|
doTest("idea/testData/completion/handlers/smart/ObjectFromType.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("QualifiedThisKeywordName1.kt")
|
||||||
|
public void testQualifiedThisKeywordName1() throws Exception {
|
||||||
|
doTest("idea/testData/completion/handlers/smart/QualifiedThisKeywordName1.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("QualifiedThisKeywordName2.kt")
|
||||||
|
public void testQualifiedThisKeywordName2() throws Exception {
|
||||||
|
doTest("idea/testData/completion/handlers/smart/QualifiedThisKeywordName2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("SAMExpected1.kt")
|
@TestMetadata("SAMExpected1.kt")
|
||||||
public void testSAMExpected1() throws Exception {
|
public void testSAMExpected1() throws Exception {
|
||||||
doTest("idea/testData/completion/handlers/smart/SAMExpected1.kt");
|
doTest("idea/testData/completion/handlers/smart/SAMExpected1.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user