Take into account refined applicability of dsl-marker in IDE

After the previous change, when being applied to a function type
with receiver it's assumed to work just as it's applied to receiver type

Thus, it's necessary to fix relevant IDE features relied on DSL markers

 #KT-23255 Fixed
This commit is contained in:
Denis Zharkov
2018-08-08 16:53:18 +07:00
parent 117abb04aa
commit 9f3a902ff3
10 changed files with 143 additions and 9 deletions
@@ -24,8 +24,7 @@ class DslMembersCompletion(
private val callTypeAndReceiver: CallTypeAndReceiver<*, *>
) {
private val nearestReceiver = receiverTypes?.firstOrNull()
private val nearestReceiverMarkers = nearestReceiver?.takeIf { it.implicit }
?.let { DslMarkerUtils.extractDslMarkerFqNames(it.type) }.orEmpty()
private val nearestReceiverMarkers = nearestReceiver?.takeIf { it.implicit }?.extractDslMarkers().orEmpty()
private val factory = object : AbstractLookupElementFactory {
override fun createLookupElement(
@@ -0,0 +1,41 @@
package bar
@DslMarker
annotation class Dsl
class R
fun r(body: @Dsl R.() -> Unit) {
}
fun foo1(i: Int) {
}
fun foo3() {
}
@Dsl
fun R.foo2() {}
@Dsl
fun R.foo4() {
}
@Dsl
fun R.fooloooooong() {
}
val R.fooval
get() = Unit
@Dsl
fun R.SomethingSomethingFooSomething() {
}
@@ -0,0 +1,20 @@
// RUNTIME
package test
import bar.r
import bar.foo3
fun main() {
val foo5 = 3
r {
foo<caret>
}
}
// ORDER: foo2
// ORDER: foo4
// ORDER: fooloooooong
// ORDER: foo3
// ORDER: foo5
// ORDER: fooval
// ORDER: foo1
@@ -69,6 +69,11 @@ public class BasicCompletionWeigherTestGenerated extends AbstractBasicCompletion
runTest("idea/idea-completion/testData/weighers/basic/DslCalls.kt");
}
@TestMetadata("DslCallsAnnotatedFunctionType.kt")
public void testDslCallsAnnotatedFunctionType() throws Exception {
runTest("idea/idea-completion/testData/weighers/basic/DslCallsAnnotatedFunctionType.kt");
}
@TestMetadata("DslCallsWithMultipleReceivers.kt")
public void testDslCallsWithMultipleReceivers() throws Exception {
runTest("idea/idea-completion/testData/weighers/basic/DslCallsWithMultipleReceivers.kt");