Hiding getters and setters from completion
This commit is contained in:
@@ -61,11 +61,15 @@ import kotlin.properties.Delegates
|
||||
|
||||
class CompletionSessionConfiguration(
|
||||
val completeNonImportedDeclarations: Boolean,
|
||||
val completeNonAccessibleDeclarations: Boolean)
|
||||
val completeNonAccessibleDeclarations: Boolean,
|
||||
val filterOutJavaGettersAndSetters: Boolean
|
||||
)
|
||||
|
||||
fun CompletionSessionConfiguration(parameters: CompletionParameters) = CompletionSessionConfiguration(
|
||||
completeNonImportedDeclarations = parameters.getInvocationCount() >= 2,
|
||||
completeNonAccessibleDeclarations = parameters.getInvocationCount() >= 2)
|
||||
completeNonAccessibleDeclarations = parameters.getInvocationCount() >= 2,
|
||||
filterOutJavaGettersAndSetters = parameters.getInvocationCount() < 2
|
||||
)
|
||||
|
||||
abstract class CompletionSession(protected val configuration: CompletionSessionConfiguration,
|
||||
protected val parameters: CompletionParameters,
|
||||
@@ -208,7 +212,7 @@ abstract class CompletionSession(protected val configuration: CompletionSessionC
|
||||
protected val referenceVariants: Collection<DeclarationDescriptor> by Delegates.lazy {
|
||||
if (descriptorKindFilter != null) {
|
||||
val expression = reference!!.expression
|
||||
referenceVariantsHelper.getReferenceVariants(expression, descriptorKindFilter!!, prefixMatcher.asNameFilter())
|
||||
referenceVariantsHelper.getReferenceVariants(expression, descriptorKindFilter!!, prefixMatcher.asNameFilter(), filterOutJavaGettersAndSetters = configuration.filterOutJavaGettersAndSetters)
|
||||
.excludeNonInitializedVariable(expression)
|
||||
}
|
||||
else {
|
||||
|
||||
+2
-1
@@ -249,7 +249,8 @@ public class KotlinCompletionContributor : CompletionContributor() {
|
||||
if (!somethingAdded && parameters.getInvocationCount() < 2) {
|
||||
// Rerun completion if nothing was found
|
||||
val newConfiguration = CompletionSessionConfiguration(completeNonImportedDeclarations = true,
|
||||
completeNonAccessibleDeclarations = false)
|
||||
completeNonAccessibleDeclarations = false,
|
||||
filterOutJavaGettersAndSetters = false)
|
||||
BasicCompletionSession(newConfiguration, parameters, result).complete()
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
import java.io.File
|
||||
|
||||
fun File.foo(absolutePath: String) {
|
||||
<caret>
|
||||
}
|
||||
|
||||
// EXIST_JAVA_ONLY: getAbsolutePath
|
||||
// ABSENT: { itemText: "absolutePath", tailText: " for File" }
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
fun foo(thread: Thread) {
|
||||
thread.get<caret>
|
||||
}
|
||||
|
||||
// EXIST_JAVA_ONLY: getPriority
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
fun foo(thread: Thread) {
|
||||
thread.<caret>
|
||||
}
|
||||
|
||||
// INVOCATION_COUNT: 2
|
||||
// EXIST_JAVA_ONLY: { lookupString: "priority", itemText: "priority", tailText: " for Thread", typeText: "Int" }
|
||||
// EXIST_JAVA_ONLY: getPriority
|
||||
// EXIST_JAVA_ONLY: setPriority
|
||||
@@ -5,3 +5,4 @@ fun foo(file: File) {
|
||||
}
|
||||
|
||||
// EXIST_JAVA_ONLY: { lookupString: "absolutePath", itemText: "absolutePath", tailText: " for File", typeText: "String!" }
|
||||
// ABSENT: getAbsolutePath
|
||||
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
import java.io.File
|
||||
|
||||
fun File.foo() {
|
||||
fun Thread.foo() {
|
||||
<caret>
|
||||
}
|
||||
|
||||
// EXIST_JAVA_ONLY: { lookupString: "absolutePath", itemText: "absolutePath", tailText: " for File", typeText: "String!" }
|
||||
// EXIST_JAVA_ONLY: { lookupString: "priority", itemText: "priority", tailText: " for Thread", typeText: "Int" }
|
||||
// ABSENT: getPriority
|
||||
// ABSENT: setPriority
|
||||
|
||||
+1
@@ -5,3 +5,4 @@ fun foo(file: File?) {
|
||||
}
|
||||
|
||||
// EXIST_JAVA_ONLY: { lookupString: "absolutePath", itemText: "absolutePath", tailText: " for File", typeText: "String!" }
|
||||
// ABSENT: getAbsolutePath
|
||||
|
||||
+18
@@ -1107,6 +1107,12 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("DoNotHideGetterWhenExtensionCannotBeUsed.kt")
|
||||
public void testDoNotHideGetterWhenExtensionCannotBeUsed() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/DoNotHideGetterWhenExtensionCannotBeUsed.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ExtensionInExtendedClass.kt")
|
||||
public void testExtensionInExtendedClass() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/ExtensionInExtendedClass.kt");
|
||||
@@ -1209,6 +1215,18 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ShowGetMethodWhenNothingElseMatch.kt")
|
||||
public void testShowGetMethodWhenNothingElseMatch() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/ShowGetMethodWhenNothingElseMatch.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ShowGetSetOnSecondCompletion.kt")
|
||||
public void testShowGetSetOnSecondCompletion() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/ShowGetSetOnSecondCompletion.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("SyntheticExtensions1.kt")
|
||||
public void testSyntheticExtensions1() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions1.kt");
|
||||
|
||||
+18
@@ -1107,6 +1107,12 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("DoNotHideGetterWhenExtensionCannotBeUsed.kt")
|
||||
public void testDoNotHideGetterWhenExtensionCannotBeUsed() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/DoNotHideGetterWhenExtensionCannotBeUsed.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ExtensionInExtendedClass.kt")
|
||||
public void testExtensionInExtendedClass() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/ExtensionInExtendedClass.kt");
|
||||
@@ -1209,6 +1215,18 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ShowGetMethodWhenNothingElseMatch.kt")
|
||||
public void testShowGetMethodWhenNothingElseMatch() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/ShowGetMethodWhenNothingElseMatch.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ShowGetSetOnSecondCompletion.kt")
|
||||
public void testShowGetSetOnSecondCompletion() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/ShowGetSetOnSecondCompletion.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("SyntheticExtensions1.kt")
|
||||
public void testSyntheticExtensions1() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions1.kt");
|
||||
|
||||
Reference in New Issue
Block a user