[AA LC] Compute nullability annotation for parameter for extension receiver
This commit is contained in:
+11
-7
@@ -91,6 +91,16 @@ internal fun KtAnnotatedSymbol.hasAnnotation(fqName: FqName, annotationUseSiteTa
|
||||
it.useSiteTarget == annotationUseSiteTarget && it.classId?.asSingleFqName() == fqName
|
||||
}
|
||||
|
||||
internal fun NullabilityType.computeNullabilityAnnotation(parent: PsiElement): SymbolLightSimpleAnnotation? {
|
||||
return when (this) {
|
||||
NullabilityType.NotNull -> NotNull::class.java
|
||||
NullabilityType.Nullable -> Nullable::class.java
|
||||
else -> null
|
||||
}?.let {
|
||||
SymbolLightSimpleAnnotation(it.name, parent)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun KtAnnotatedSymbol.computeAnnotations(
|
||||
parent: PsiElement,
|
||||
nullability: NullabilityType,
|
||||
@@ -98,13 +108,7 @@ internal fun KtAnnotatedSymbol.computeAnnotations(
|
||||
includeAnnotationsWithoutSite: Boolean = true
|
||||
): List<PsiAnnotation> {
|
||||
|
||||
val nullabilityAnnotation = when (nullability) {
|
||||
NullabilityType.NotNull -> NotNull::class.java
|
||||
NullabilityType.Nullable -> Nullable::class.java
|
||||
else -> null
|
||||
}?.let {
|
||||
SymbolLightSimpleAnnotation(it.name, parent)
|
||||
}
|
||||
val nullabilityAnnotation = nullability.computeNullabilityAnnotation(parent)
|
||||
|
||||
val parentIsAnnotation = (parent as? PsiClass)?.isAnnotationType == true
|
||||
|
||||
|
||||
+7
-2
@@ -19,9 +19,11 @@ import org.jetbrains.kotlin.analysis.api.types.KtType
|
||||
import org.jetbrains.kotlin.asJava.classes.lazyPub
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil
|
||||
import org.jetbrains.kotlin.light.classes.symbol.annotations.SymbolLightAnnotationForAnnotationCall
|
||||
import org.jetbrains.kotlin.light.classes.symbol.annotations.computeNullabilityAnnotation
|
||||
import org.jetbrains.kotlin.light.classes.symbol.methods.SymbolLightMethodBase
|
||||
import org.jetbrains.kotlin.light.classes.symbol.modifierLists.SymbolLightClassModifierList
|
||||
import org.jetbrains.kotlin.light.classes.symbol.nonExistentType
|
||||
import org.jetbrains.kotlin.light.classes.symbol.nullabilityType
|
||||
import org.jetbrains.kotlin.psi.KtParameter
|
||||
|
||||
context(KtAnalysisSession)
|
||||
@@ -66,8 +68,11 @@ internal class SymbolLightParameterForReceiver private constructor(
|
||||
override val kotlinOrigin: KtParameter? = null
|
||||
|
||||
private val _annotations: List<PsiAnnotation> by lazyPub {
|
||||
receiverType.annotations.map {
|
||||
SymbolLightAnnotationForAnnotationCall(it, this)
|
||||
buildList {
|
||||
receiverType.nullabilityType.computeNullabilityAnnotation(this@SymbolLightParameterForReceiver)?.let { add(it) }
|
||||
receiverType.annotations.mapTo(this) {
|
||||
SymbolLightAnnotationForAnnotationCall(it, this@SymbolLightParameterForReceiver)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
public final class Test /* Test*/ {
|
||||
@MyAnnotation5()
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
private java.lang.String bar;
|
||||
|
||||
@MyAnnotation()
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final java.lang.String getBar();// getBar()
|
||||
|
||||
@MyAnnotation2()
|
||||
public final void setBar(@MyAnnotation3() @org.jetbrains.annotations.NotNull() java.lang.String);// setBar(java.lang.String)
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final kotlin.Unit getFooP(@MyAnnotation7() @org.jetbrains.annotations.NotNull() int);// getFooP(int)
|
||||
|
||||
public Test(@MyAnnotation6() @org.jetbrains.annotations.NotNull() java.lang.String);// .ctor(java.lang.String)
|
||||
|
||||
public final void fooF(@MyAnnotation7() @org.jetbrains.annotations.NotNull() int);// fooF(int)
|
||||
|
||||
public final void setFooP(@MyAnnotation7() @org.jetbrains.annotations.NotNull() int, @org.jetbrains.annotations.NotNull() kotlin.Unit);// setFooP(int, kotlin.Unit)
|
||||
|
||||
}
|
||||
@@ -111,7 +111,7 @@ public final class Foo /* Foo*/ {
|
||||
public Foo(error.NonExistentClass);// .ctor(error.NonExistentClass)
|
||||
|
||||
@Anno()
|
||||
public final void f4(java.lang.String);// f4(java.lang.String)
|
||||
public final void f4(@org.jetbrains.annotations.NotNull() java.lang.String);// f4(java.lang.String)
|
||||
|
||||
@Anno()
|
||||
public final void setX(@org.jetbrains.annotations.Nullable() java.lang.String);// setX(java.lang.String)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
public abstract interface Base /* Base*/ {
|
||||
public abstract int foo(java.lang.String, @org.jetbrains.annotations.Nullable() java.lang.Object);// foo(java.lang.String, java.lang.Object)
|
||||
public abstract int foo(@org.jetbrains.annotations.NotNull() java.lang.String, @org.jetbrains.annotations.Nullable() java.lang.Object);// foo(java.lang.String, java.lang.Object)
|
||||
|
||||
public abstract int getX();// getX()
|
||||
|
||||
@@ -30,7 +30,7 @@ public final class BaseImpl /* BaseImpl*/ implements Base {
|
||||
|
||||
public final class Derived /* Derived*/ implements Base {
|
||||
@java.lang.Override()
|
||||
public int foo(java.lang.String, @org.jetbrains.annotations.Nullable() java.lang.Object);// foo(java.lang.String, java.lang.Object)
|
||||
public int foo(@org.jetbrains.annotations.NotNull() java.lang.String, @org.jetbrains.annotations.Nullable() java.lang.Object);// foo(java.lang.String, java.lang.Object)
|
||||
|
||||
@java.lang.Override()
|
||||
public void printMessage();// printMessage()
|
||||
|
||||
@@ -52,7 +52,7 @@ public abstract class C /* C*/<T> {
|
||||
|
||||
public C(@org.jetbrains.annotations.NotNull() java.util.List<? extends java.lang.CharSequence>);// .ctor(java.util.List<? extends java.lang.CharSequence>)
|
||||
|
||||
public final <Q extends T> Q getW(Q);// <Q extends T> getW(Q)
|
||||
public final <Q extends T> Q getW(@org.jetbrains.annotations.NotNull() Q);// <Q extends T> getW(Q)
|
||||
|
||||
public final <V, U extends V> T foo(V, @org.jetbrains.annotations.NotNull() C<V>, @org.jetbrains.annotations.NotNull() kotlin.sequences.Sequence<? extends V>);// <V, U extends V> foo(V, C<V>, kotlin.sequences.Sequence<? extends V>)
|
||||
|
||||
|
||||
@@ -33,13 +33,13 @@ public final class C /* C*/ {
|
||||
public static final class Companion /* C.Companion*/ {
|
||||
@kotlin.jvm.JvmStatic()
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final java.lang.String getC(I);// getC(I)
|
||||
public final java.lang.String getC(@org.jetbrains.annotations.NotNull() I);// getC(I)
|
||||
|
||||
@kotlin.jvm.JvmStatic()
|
||||
public final void foo();// foo()
|
||||
|
||||
@kotlin.jvm.JvmStatic()
|
||||
public final void setC(I, @org.jetbrains.annotations.NotNull() java.lang.String);// setC(I, java.lang.String)
|
||||
public final void setC(@org.jetbrains.annotations.NotNull() I, @org.jetbrains.annotations.NotNull() java.lang.String);// setC(I, java.lang.String)
|
||||
|
||||
@kotlin.jvm.JvmStatic()
|
||||
public final void setC1(@org.jetbrains.annotations.NotNull() java.lang.String);// setC1(java.lang.String)
|
||||
|
||||
@@ -161,7 +161,7 @@ public final class Foo /* Foo*/ {
|
||||
|
||||
public final int getF1();// getF1()
|
||||
|
||||
public final int getIntProp(int);// getIntProp(int)
|
||||
public final int getIntProp(@org.jetbrains.annotations.NotNull() int);// getIntProp(int)
|
||||
|
||||
public final int getInternalWithPrivateSet$light_idea_test_case();// getInternalWithPrivateSet$light_idea_test_case()
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
public final class Foo /* Foo*/ {
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final Foo onString(java.lang.String, @org.jetbrains.annotations.NotNull() kotlin.jvm.functions.Function1<? super java.lang.Integer, ? extends java.lang.Object>);// onString(java.lang.String, kotlin.jvm.functions.Function1<? super java.lang.Integer, ? extends java.lang.Object>)
|
||||
public final Foo onString(@org.jetbrains.annotations.NotNull() java.lang.String, @org.jetbrains.annotations.NotNull() kotlin.jvm.functions.Function1<? super java.lang.Integer, ? extends java.lang.Object>);// onString(java.lang.String, kotlin.jvm.functions.Function1<? super java.lang.Integer, ? extends java.lang.Object>)
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final Foo plus(int);// plus(int)
|
||||
|
||||
@@ -141,7 +141,7 @@ public final class PropertiesKt /* PropertiesKt*/ {
|
||||
|
||||
public static final int getInt2();// getInt2()
|
||||
|
||||
public static final int getIntProp(int);// getIntProp(int)
|
||||
public static final int getIntProp(@org.jetbrains.annotations.NotNull() int);// getIntProp(int)
|
||||
|
||||
public static final int getInternalWithPrivateSet();// getInternalWithPrivateSet()
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ public final class SimpleFunctionsKt /* SimpleFunctionsKt*/ {
|
||||
|
||||
public static final /* vararg */ void nullableVararg(@org.jetbrains.annotations.NotNull() java.lang.Object...);// nullableVararg(java.lang.Object[])
|
||||
|
||||
public static final error.NonExistentClass onString(java.lang.String, @org.jetbrains.annotations.NotNull() kotlin.jvm.functions.Function1<? super java.lang.Integer, ? extends java.lang.Object>);// onString(java.lang.String, kotlin.jvm.functions.Function1<? super java.lang.Integer, ? extends java.lang.Object>)
|
||||
public static final error.NonExistentClass onString(@org.jetbrains.annotations.NotNull() java.lang.String, @org.jetbrains.annotations.NotNull() kotlin.jvm.functions.Function1<? super java.lang.Integer, ? extends java.lang.Object>);// onString(java.lang.String, kotlin.jvm.functions.Function1<? super java.lang.Integer, ? extends java.lang.Object>)
|
||||
|
||||
public static final error.NonExistentClass plus(int);// plus(int)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user