JS: Avoid declaration skeleton body generation in case of external class or object
This commit is contained in:
committed by
Dmitry Jemerov
parent
15e392bbd1
commit
46ce9a6946
+6
@@ -459,7 +459,13 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
|
||||
val body = when {
|
||||
callableInfo.kind == CallableKind.SECONDARY_CONSTRUCTOR -> ""
|
||||
callableInfo.isAbstract -> ""
|
||||
containingElement is KtClass && containingElement.hasModifier(KtTokens.EXTERNAL_KEYWORD) -> ""
|
||||
containingElement is KtObjectDeclaration && containingElement.hasModifier(KtTokens.EXTERNAL_KEYWORD) -> ""
|
||||
containingElement is KtObjectDeclaration && containingElement.isCompanion()
|
||||
&& containingElement.parent.parent is KtClass
|
||||
&& (containingElement.parent.parent as KtClass).hasModifier(KtTokens.EXTERNAL_KEYWORD) -> ""
|
||||
else -> "{}"
|
||||
|
||||
}
|
||||
@Suppress("USELESS_CAST") // KT-10755
|
||||
if (callableInfo is FunctionInfo) {
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Create member function 'A.Companion.foo'" "true"
|
||||
// JS
|
||||
|
||||
external class A {
|
||||
companion object
|
||||
}
|
||||
|
||||
fun test() {
|
||||
A.<caret>foo()
|
||||
}
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
// "Create member function 'A.Companion.foo'" "true"
|
||||
// JS
|
||||
|
||||
external class A {
|
||||
companion object {
|
||||
fun foo()
|
||||
}
|
||||
}
|
||||
|
||||
fun test() {
|
||||
A.foo()
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Create member function 'A.foo'" "true"
|
||||
// JS
|
||||
|
||||
external class A
|
||||
|
||||
fun test() {
|
||||
A().<caret>foo()
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Create member function 'A.foo'" "true"
|
||||
// JS
|
||||
|
||||
external class A {
|
||||
fun foo()
|
||||
}
|
||||
|
||||
fun test() {
|
||||
A().foo()
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Create member function 'A.foo'" "true"
|
||||
// JS
|
||||
|
||||
external object A
|
||||
|
||||
fun test() {
|
||||
A.<caret>foo()
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Create member function 'A.foo'" "true"
|
||||
// JS
|
||||
|
||||
external object A {
|
||||
fun foo()
|
||||
}
|
||||
|
||||
fun test() {
|
||||
A.foo()
|
||||
}
|
||||
@@ -6529,6 +6529,24 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("funPlacementOnCompanionObjectJsRuntime.kt")
|
||||
public void testFunPlacementOnCompanionObjectJsRuntime() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/migration/jsExternal/funPlacementOnCompanionObjectJsRuntime.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("funPlacementOnExternalClassJsRuntime.kt")
|
||||
public void testFunPlacementOnExternalClassJsRuntime() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/migration/jsExternal/funPlacementOnExternalClassJsRuntime.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("funPlacementOnExternalObjectJsRuntime.kt")
|
||||
public void testFunPlacementOnExternalObjectJsRuntime() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/migration/jsExternal/funPlacementOnExternalObjectJsRuntime.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("nativeExtensionFunBlockBodyJsRuntime.kt")
|
||||
public void testNativeExtensionFunBlockBodyJsRuntime() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/migration/jsExternal/nativeExtensionFunBlockBodyJsRuntime.kt");
|
||||
|
||||
Reference in New Issue
Block a user