Fix minor bugs for UL methods and parameters representation
Remove INSTANCE field for local object declarations Remove private suspend functions create from UL Add correct extension function parameter name Add support for setparam annotation modifier
This commit is contained in:
@@ -13,7 +13,6 @@ import com.intellij.psi.impl.light.LightMethodBuilder
|
|||||||
import com.intellij.psi.util.CachedValue
|
import com.intellij.psi.util.CachedValue
|
||||||
import com.intellij.psi.util.CachedValueProvider
|
import com.intellij.psi.util.CachedValueProvider
|
||||||
import com.intellij.psi.util.CachedValuesManager
|
import com.intellij.psi.util.CachedValuesManager
|
||||||
import org.jetbrains.kotlin.asJava.UltraLightClassModifierExtension
|
|
||||||
import org.jetbrains.kotlin.asJava.builder.LightClassData
|
import org.jetbrains.kotlin.asJava.builder.LightClassData
|
||||||
import org.jetbrains.kotlin.asJava.elements.KtLightField
|
import org.jetbrains.kotlin.asJava.elements.KtLightField
|
||||||
import org.jetbrains.kotlin.asJava.elements.KtLightMethod
|
import org.jetbrains.kotlin.asJava.elements.KtLightMethod
|
||||||
@@ -226,7 +225,7 @@ open class KtUltraLightClass(classOrObject: KtClassOrObject, internal val suppor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNamedObject()) {
|
if (isNamedObject() && !this.classOrObject.isLocal) {
|
||||||
result.add(
|
result.add(
|
||||||
KtUltraLightFieldForSourceDeclaration(
|
KtUltraLightFieldForSourceDeclaration(
|
||||||
this.classOrObject,
|
this.classOrObject,
|
||||||
|
|||||||
+21
-6
@@ -18,10 +18,8 @@ import org.jetbrains.kotlin.asJava.elements.convertToLightAnnotationMemberValue
|
|||||||
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper
|
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotated
|
import org.jetbrains.kotlin.descriptors.annotations.Annotated
|
||||||
import org.jetbrains.kotlin.extensions.DeclarationAttributeAltererExtension
|
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens
|
import org.jetbrains.kotlin.lexer.KtTokens
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens.EXTERNAL_KEYWORD
|
import org.jetbrains.kotlin.lexer.KtTokens.*
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens.REIFIED_KEYWORD
|
|
||||||
import org.jetbrains.kotlin.load.java.JvmAbi
|
import org.jetbrains.kotlin.load.java.JvmAbi
|
||||||
import org.jetbrains.kotlin.load.kotlin.TypeMappingMode
|
import org.jetbrains.kotlin.load.kotlin.TypeMappingMode
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
@@ -29,7 +27,7 @@ import org.jetbrains.kotlin.name.SpecialNames
|
|||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.hasExpectModifier
|
import org.jetbrains.kotlin.psi.psiUtil.hasExpectModifier
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.hasSuspendModifier
|
import org.jetbrains.kotlin.psi.psiUtil.hasSuspendModifier
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.isObjectLiteral
|
import org.jetbrains.kotlin.psi.psiUtil.isPrivate
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isPublishedApi
|
import org.jetbrains.kotlin.resolve.descriptorUtil.isPublishedApi
|
||||||
@@ -120,6 +118,11 @@ internal class UltraLightMembersCreator(
|
|||||||
ktFunction.hasExpectModifier()
|
ktFunction.hasExpectModifier()
|
||||||
) return emptyList()
|
) return emptyList()
|
||||||
|
|
||||||
|
|
||||||
|
if (ktFunction.modifierList?.hasSuspendModifier() == true && ktFunction.isPrivate()) {
|
||||||
|
return emptyList()
|
||||||
|
}
|
||||||
|
|
||||||
val basicMethod = asJavaMethod(ktFunction, forceStatic, forcePrivate)
|
val basicMethod = asJavaMethod(ktFunction, forceStatic, forcePrivate)
|
||||||
|
|
||||||
val result = mutableListOf(basicMethod)
|
val result = mutableListOf(basicMethod)
|
||||||
@@ -465,9 +468,21 @@ internal class UltraLightMembersCreator(
|
|||||||
val setterParameter = ktSetter?.parameter
|
val setterParameter = ktSetter?.parameter
|
||||||
setterPrototype.addParameter(
|
setterPrototype.addParameter(
|
||||||
if (setterParameter != null)
|
if (setterParameter != null)
|
||||||
KtUltraLightParameterForSource(propertyName, setterParameter, support, setterWrapper, declaration)
|
KtUltraLightParameterForSource(
|
||||||
|
name = setterParameter.name ?: propertyName,
|
||||||
|
kotlinOrigin = setterParameter,
|
||||||
|
support = support,
|
||||||
|
method = setterWrapper,
|
||||||
|
containingDeclaration = declaration
|
||||||
|
)
|
||||||
else
|
else
|
||||||
KtUltraLightParameterForSetterParameter(propertyName, declaration, support, setterWrapper, declaration)
|
KtUltraLightParameterForSetterParameter(
|
||||||
|
name = propertyName,
|
||||||
|
property = declaration,
|
||||||
|
support = support,
|
||||||
|
method = setterWrapper,
|
||||||
|
containingDeclaration = declaration
|
||||||
|
)
|
||||||
)
|
)
|
||||||
result.add(setterWrapper)
|
result.add(setterWrapper)
|
||||||
}
|
}
|
||||||
|
|||||||
+23
-3
@@ -13,11 +13,17 @@ import org.jetbrains.annotations.NonNls
|
|||||||
import org.jetbrains.kotlin.asJava.elements.*
|
import org.jetbrains.kotlin.asJava.elements.*
|
||||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||||
import org.jetbrains.kotlin.builtins.isSuspendFunctionType
|
import org.jetbrains.kotlin.builtins.isSuspendFunctionType
|
||||||
|
import org.jetbrains.kotlin.codegen.AsmUtil
|
||||||
import org.jetbrains.kotlin.codegen.coroutines.SUSPEND_FUNCTION_COMPLETION_PARAMETER_NAME
|
import org.jetbrains.kotlin.codegen.coroutines.SUSPEND_FUNCTION_COMPLETION_PARAMETER_NAME
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.load.kotlin.TypeMappingMode
|
import org.jetbrains.kotlin.load.kotlin.TypeMappingMode
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.KtCallableDeclaration
|
||||||
|
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||||
|
import org.jetbrains.kotlin.psi.KtFunction
|
||||||
|
import org.jetbrains.kotlin.psi.KtParameter
|
||||||
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
import org.jetbrains.kotlin.codegen.AsmUtil.LABELED_THIS_PARAMETER
|
||||||
|
import org.jetbrains.kotlin.codegen.AsmUtil.RECEIVER_PARAMETER_NAME
|
||||||
|
|
||||||
internal class KtUltraLightSuspendContinuationParameter(
|
internal class KtUltraLightSuspendContinuationParameter(
|
||||||
private val ktFunction: KtFunction,
|
private val ktFunction: KtFunction,
|
||||||
@@ -182,6 +188,13 @@ internal class KtUltraLightParameterForSetterParameter(
|
|||||||
|
|
||||||
override fun tryGetKotlinType(): KotlinType? = property.getKotlinType()
|
override fun tryGetKotlinType(): KotlinType? = property.getKotlinType()
|
||||||
|
|
||||||
|
override val givenAnnotations: List<KtLightAbstractAnnotation>?
|
||||||
|
get() = (property.resolve() as? PropertyDescriptor)
|
||||||
|
?.setter
|
||||||
|
?.valueParameters
|
||||||
|
?.firstOrNull()
|
||||||
|
?.obtainLightAnnotations(support, this)
|
||||||
|
|
||||||
override fun isVarArgs(): Boolean = false
|
override fun isVarArgs(): Boolean = false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,7 +202,14 @@ internal class KtUltraLightReceiverParameter(
|
|||||||
containingDeclaration: KtCallableDeclaration,
|
containingDeclaration: KtCallableDeclaration,
|
||||||
support: KtUltraLightSupport,
|
support: KtUltraLightSupport,
|
||||||
method: KtUltraLightMethod
|
method: KtUltraLightMethod
|
||||||
) : KtAbstractUltraLightParameterForDeclaration("\$self", null, support, method, containingDeclaration) {
|
) : KtAbstractUltraLightParameterForDeclaration(
|
||||||
|
/** @see org.jetbrains.kotlin.codegen.AsmUtil.getNameForReceiverParameter */
|
||||||
|
name = AsmUtil.getLabeledThisName(method.name, LABELED_THIS_PARAMETER, RECEIVER_PARAMETER_NAME),
|
||||||
|
kotlinOrigin = null,
|
||||||
|
support = support,
|
||||||
|
method = method,
|
||||||
|
containingDeclaration = containingDeclaration
|
||||||
|
) {
|
||||||
|
|
||||||
override fun isVarArgs(): Boolean = false
|
override fun isVarArgs(): Boolean = false
|
||||||
|
|
||||||
|
|||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
|
||||||
|
public abstract @interface Anno /* Anno*/ {
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class TestClass /* TestClass*/ {
|
||||||
|
private int hello;
|
||||||
|
|
||||||
|
@null()
|
||||||
|
public TestClass(int);
|
||||||
|
|
||||||
|
public final int getHello();
|
||||||
|
|
||||||
|
public final void setHello(@Anno() int);
|
||||||
|
|
||||||
|
}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
annotation class Anno
|
||||||
|
|
||||||
|
class TestClass(@setparam:Anno var hello: Int)
|
||||||
@@ -3,6 +3,10 @@ class Foo {
|
|||||||
suspend fun doSomething(foo: Foo): Bar {}
|
suspend fun doSomething(foo: Foo): Bar {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Boo {
|
||||||
|
private suspend fun doSomething(foo: Foo): Bar {}
|
||||||
|
}
|
||||||
|
|
||||||
class Bar {
|
class Bar {
|
||||||
fun <T> async(block: suspend () -> T)
|
fun <T> async(block: suspend () -> T)
|
||||||
}
|
}
|
||||||
|
|||||||
-27
@@ -7,9 +7,6 @@ public final class Prop /* Prop*/ {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final class null /* null*/ {
|
final class null /* null*/ {
|
||||||
@null()
|
|
||||||
public static final java.lang.Object INSTANCE;
|
|
||||||
|
|
||||||
private ();
|
private ();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -23,9 +20,6 @@ public final class Fun /* Fun*/ {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final class null /* null*/ {
|
final class null /* null*/ {
|
||||||
@null()
|
|
||||||
public static final java.lang.Object INSTANCE;
|
|
||||||
|
|
||||||
private ();
|
private ();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -42,9 +36,6 @@ public final class ArrayOfAnonymous /* ArrayOfAnonymous*/ {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final class null /* null*/ {
|
final class null /* null*/ {
|
||||||
@null()
|
|
||||||
public static final java.lang.Object INSTANCE;
|
|
||||||
|
|
||||||
private static final java.lang.String fy = "text" /* initializer type: java.lang.String */ /* constant value text */;
|
private static final java.lang.String fy = "text" /* initializer type: java.lang.String */ /* constant value text */;
|
||||||
|
|
||||||
@org.jetbrains.annotations.NotNull()
|
@org.jetbrains.annotations.NotNull()
|
||||||
@@ -70,9 +61,6 @@ final class C /* C*/ {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final class null /* null*/ {
|
final class null /* null*/ {
|
||||||
@null()
|
|
||||||
public static final java.lang.Object INSTANCE;
|
|
||||||
|
|
||||||
@org.jetbrains.annotations.NotNull()
|
@org.jetbrains.annotations.NotNull()
|
||||||
public java.lang.String toString();
|
public java.lang.String toString();
|
||||||
|
|
||||||
@@ -101,9 +89,6 @@ public final class Sub /* Sub*/ extends Super {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final class null /* null*/ {
|
final class null /* null*/ {
|
||||||
@null()
|
|
||||||
public static final java.lang.Object INSTANCE;
|
|
||||||
|
|
||||||
private static final java.lang.String fy = "text" /* initializer type: java.lang.String */ /* constant value text */;
|
private static final java.lang.String fy = "text" /* initializer type: java.lang.String */ /* constant value text */;
|
||||||
|
|
||||||
@org.jetbrains.annotations.NotNull()
|
@org.jetbrains.annotations.NotNull()
|
||||||
@@ -128,9 +113,6 @@ public final class ValidPublicSupertype /* ValidPublicSupertype*/ {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final class null /* null*/ implements java.lang.Runnable {
|
final class null /* null*/ implements java.lang.Runnable {
|
||||||
@null()
|
|
||||||
public static final java.lang.Runnable INSTANCE;
|
|
||||||
|
|
||||||
private ();
|
private ();
|
||||||
|
|
||||||
public void run();
|
public void run();
|
||||||
@@ -138,9 +120,6 @@ final class null /* null*/ implements java.lang.Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final class null /* null*/ implements java.lang.Runnable {
|
final class null /* null*/ implements java.lang.Runnable {
|
||||||
@null()
|
|
||||||
public static final java.lang.Runnable INSTANCE;
|
|
||||||
|
|
||||||
private ();
|
private ();
|
||||||
|
|
||||||
public void run();
|
public void run();
|
||||||
@@ -165,9 +144,6 @@ public final class InvalidPublicSupertype /* InvalidPublicSupertype*/ {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final class null /* null*/ implements I, java.lang.Runnable {
|
final class null /* null*/ implements I, java.lang.Runnable {
|
||||||
@null()
|
|
||||||
public static final java.lang.Runnable INSTANCE;
|
|
||||||
|
|
||||||
private ();
|
private ();
|
||||||
|
|
||||||
public void run();
|
public void run();
|
||||||
@@ -175,9 +151,6 @@ final class null /* null*/ implements I, java.lang.Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final class null /* null*/ implements I, java.lang.Runnable {
|
final class null /* null*/ implements I, java.lang.Runnable {
|
||||||
@null()
|
|
||||||
public static final java.lang.Runnable INSTANCE;
|
|
||||||
|
|
||||||
private ();
|
private ();
|
||||||
|
|
||||||
public void run();
|
public void run();
|
||||||
|
|||||||
+5
@@ -28,6 +28,11 @@ public class UltraLightClassLoadingTestGenerated extends AbstractUltraLightClass
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/asJava/ultraLightClasses"), Pattern.compile("^(.+)\\.(kt|kts)$"), true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/asJava/ultraLightClasses"), Pattern.compile("^(.+)\\.(kt|kts)$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("annotationWithSetParamPropertyModifier.kt")
|
||||||
|
public void testAnnotationWithSetParamPropertyModifier() throws Exception {
|
||||||
|
runTest("compiler/testData/asJava/ultraLightClasses/annotationWithSetParamPropertyModifier.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("annotations.kt")
|
@TestMetadata("annotations.kt")
|
||||||
public void testAnnotations() throws Exception {
|
public void testAnnotations() throws Exception {
|
||||||
runTest("compiler/testData/asJava/ultraLightClasses/annotations.kt");
|
runTest("compiler/testData/asJava/ultraLightClasses/annotations.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user