Completion of object's in type position - they can be used there
This commit is contained in:
-1
@@ -35,5 +35,4 @@ public class SamConstructorDescriptor(
|
|||||||
|
|
||||||
public object SamConstructorDescriptorKindExclude : DescriptorKindExclude {
|
public object SamConstructorDescriptorKindExclude : DescriptorKindExclude {
|
||||||
override fun matches(descriptor: DeclarationDescriptor) = descriptor is SamConstructorDescriptor
|
override fun matches(descriptor: DeclarationDescriptor) = descriptor is SamConstructorDescriptor
|
||||||
override fun toString() = this.javaClass.getSimpleName()
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -185,17 +185,20 @@ public class DescriptorKindFilter(
|
|||||||
public trait DescriptorKindExclude {
|
public trait DescriptorKindExclude {
|
||||||
public fun matches(descriptor: DeclarationDescriptor): Boolean
|
public fun matches(descriptor: DeclarationDescriptor): Boolean
|
||||||
|
|
||||||
|
override fun toString() = this.javaClass.getSimpleName()
|
||||||
|
|
||||||
public object Extensions : DescriptorKindExclude {
|
public object Extensions : DescriptorKindExclude {
|
||||||
override fun matches(descriptor: DeclarationDescriptor)
|
override fun matches(descriptor: DeclarationDescriptor)
|
||||||
= descriptor is CallableDescriptor && descriptor.getExtensionReceiverParameter() != null
|
= descriptor is CallableDescriptor && descriptor.getExtensionReceiverParameter() != null
|
||||||
|
|
||||||
override fun toString() = this.javaClass.getSimpleName()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public object NonExtensions : DescriptorKindExclude {
|
public object NonExtensions : DescriptorKindExclude {
|
||||||
override fun matches(descriptor: DeclarationDescriptor)
|
override fun matches(descriptor: DeclarationDescriptor)
|
||||||
= descriptor !is CallableDescriptor || descriptor.getExtensionReceiverParameter() == null
|
= descriptor !is CallableDescriptor || descriptor.getExtensionReceiverParameter() == null
|
||||||
|
}
|
||||||
|
|
||||||
override fun toString() = this.javaClass.getSimpleName()
|
public object EnumEntry : DescriptorKindExclude {
|
||||||
|
override fun matches(descriptor: DeclarationDescriptor)
|
||||||
|
= descriptor is ClassDescriptor && descriptor.getKind() == ClassKind.ENUM_ENTRY
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,6 @@ import com.intellij.psi.util.PsiTreeUtil
|
|||||||
import org.jetbrains.jet.lang.descriptors.*
|
import org.jetbrains.jet.lang.descriptors.*
|
||||||
import org.jetbrains.jet.lang.psi.*
|
import org.jetbrains.jet.lang.psi.*
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns
|
|
||||||
import org.jetbrains.jet.plugin.caches.resolve.*
|
import org.jetbrains.jet.plugin.caches.resolve.*
|
||||||
import org.jetbrains.jet.plugin.codeInsight.ReferenceVariantsHelper
|
import org.jetbrains.jet.plugin.codeInsight.ReferenceVariantsHelper
|
||||||
import org.jetbrains.jet.plugin.completion.smart.SmartCompletion
|
import org.jetbrains.jet.plugin.completion.smart.SmartCompletion
|
||||||
@@ -43,6 +42,7 @@ import org.jetbrains.jet.lang.psi.psiUtil.getStrictParentOfType
|
|||||||
import org.jetbrains.jet.plugin.util.makeNotNullable
|
import org.jetbrains.jet.plugin.util.makeNotNullable
|
||||||
import org.jetbrains.jet.plugin.util.CallType
|
import org.jetbrains.jet.plugin.util.CallType
|
||||||
import org.jetbrains.jet.plugin.completion.isVisible
|
import org.jetbrains.jet.plugin.completion.isVisible
|
||||||
|
import org.jetbrains.jet.lang.resolve.scopes.DescriptorKindExclude
|
||||||
|
|
||||||
class CompletionSessionConfiguration(
|
class CompletionSessionConfiguration(
|
||||||
val completeNonImportedDeclarations: Boolean,
|
val completeNonImportedDeclarations: Boolean,
|
||||||
@@ -187,18 +187,13 @@ class BasicCompletionSession(configuration: CompletionSessionConfiguration,
|
|||||||
val completeReference = jetReference != null && !isOnlyKeywordCompletion()
|
val completeReference = jetReference != null && !isOnlyKeywordCompletion()
|
||||||
val onlyTypes = completeReference && shouldRunOnlyTypeCompletion()
|
val onlyTypes = completeReference && shouldRunOnlyTypeCompletion()
|
||||||
|
|
||||||
val kindMask = if (onlyTypes)
|
val kindFilter = if (onlyTypes)
|
||||||
DescriptorKindFilter.NON_SINGLETON_CLASSIFIERS_MASK or DescriptorKindFilter.PACKAGES_MASK
|
DescriptorKindFilter(DescriptorKindFilter.CLASSIFIERS_MASK or DescriptorKindFilter.PACKAGES_MASK) exclude DescriptorKindExclude.EnumEntry
|
||||||
else
|
else
|
||||||
DescriptorKindFilter.ALL_KINDS_MASK
|
DescriptorKindFilter(DescriptorKindFilter.ALL_KINDS_MASK)
|
||||||
val kindFilter = DescriptorKindFilter(kindMask)
|
|
||||||
|
|
||||||
if (completeReference) {
|
if (completeReference) {
|
||||||
addReferenceVariants(kindFilter, shouldCastToRuntimeType = false)
|
addReferenceVariants(kindFilter, shouldCastToRuntimeType = false)
|
||||||
|
|
||||||
if (onlyTypes) {
|
|
||||||
collector.addDescriptorElements(listOf(KotlinBuiltIns.getInstance().getUnit()), false)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KeywordCompletion.complete(parameters, prefixMatcher.getPrefix(), collector)
|
KeywordCompletion.complete(parameters, prefixMatcher.getPrefix(), collector)
|
||||||
@@ -223,7 +218,7 @@ class BasicCompletionSession(configuration: CompletionSessionConfiguration,
|
|||||||
|
|
||||||
private fun addNonImported(onlyTypes: Boolean) {
|
private fun addNonImported(onlyTypes: Boolean) {
|
||||||
if (shouldRunTopLevelCompletion()) {
|
if (shouldRunTopLevelCompletion()) {
|
||||||
addAllClasses { if (onlyTypes) !it.isSingleton() else it != ClassKind.ENUM_ENTRY }
|
addAllClasses { it != ClassKind.ENUM_ENTRY }
|
||||||
|
|
||||||
if (!onlyTypes) {
|
if (!onlyTypes) {
|
||||||
collector.addDescriptorElements(getKotlinTopLevelCallables(), suppressAutoInsertion = true)
|
collector.addDescriptorElements(getKotlinTopLevelCallables(), suppressAutoInsertion = true)
|
||||||
|
|||||||
+1
-2
@@ -4,5 +4,4 @@ fun test() {
|
|||||||
val a : Named<caret>
|
val a : Named<caret>
|
||||||
}
|
}
|
||||||
|
|
||||||
// INVOCATION_COUNT: 2
|
// EXIST: NamedObject
|
||||||
// ABSENT: NamedObject
|
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
package ppp
|
||||||
|
|
||||||
|
object SomeObject
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
fun foo(): S<caret>
|
||||||
|
|
||||||
|
// INVOCATION_COUNT: 2
|
||||||
|
// EXIST: SomeObject
|
||||||
@@ -700,12 +700,6 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("NoObjectInTypePosition.kt")
|
|
||||||
public void testNoObjectInTypePosition() throws Exception {
|
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/NoObjectInTypePosition.kt");
|
|
||||||
doTest(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("NoPackageFacadeClasses.kt")
|
@TestMetadata("NoPackageFacadeClasses.kt")
|
||||||
public void testNoPackageFacadeClasses() throws Exception {
|
public void testNoPackageFacadeClasses() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/NoPackageFacadeClasses.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/NoPackageFacadeClasses.kt");
|
||||||
@@ -724,6 +718,12 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ObjectInTypePosition.kt")
|
||||||
|
public void testObjectInTypePosition() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/ObjectInTypePosition.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("ObjectRedeclaration1.kt")
|
@TestMetadata("ObjectRedeclaration1.kt")
|
||||||
public void testObjectRedeclaration1() throws Exception {
|
public void testObjectRedeclaration1() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/ObjectRedeclaration1.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/ObjectRedeclaration1.kt");
|
||||||
|
|||||||
@@ -700,12 +700,6 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("NoObjectInTypePosition.kt")
|
|
||||||
public void testNoObjectInTypePosition() throws Exception {
|
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/NoObjectInTypePosition.kt");
|
|
||||||
doTest(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("NoPackageFacadeClasses.kt")
|
@TestMetadata("NoPackageFacadeClasses.kt")
|
||||||
public void testNoPackageFacadeClasses() throws Exception {
|
public void testNoPackageFacadeClasses() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/NoPackageFacadeClasses.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/NoPackageFacadeClasses.kt");
|
||||||
@@ -724,6 +718,12 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ObjectInTypePosition.kt")
|
||||||
|
public void testObjectInTypePosition() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/ObjectInTypePosition.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("ObjectRedeclaration1.kt")
|
@TestMetadata("ObjectRedeclaration1.kt")
|
||||||
public void testObjectRedeclaration1() throws Exception {
|
public void testObjectRedeclaration1() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/ObjectRedeclaration1.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/ObjectRedeclaration1.kt");
|
||||||
|
|||||||
@@ -174,6 +174,12 @@ public class MultiFileJvmBasicCompletionTestGenerated extends AbstractMultiFileJ
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ObjectInTypePosition")
|
||||||
|
public void testObjectInTypePosition() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/multifile/ObjectInTypePosition/");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("TopLevelFunction")
|
@TestMetadata("TopLevelFunction")
|
||||||
public void testTopLevelFunction() throws Exception {
|
public void testTopLevelFunction() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/multifile/TopLevelFunction/");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/multifile/TopLevelFunction/");
|
||||||
|
|||||||
Reference in New Issue
Block a user