diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/KotlinAbstractUElement.kt.172 b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/KotlinAbstractUElement.kt.172 index d4b54824946..38096536a40 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/KotlinAbstractUElement.kt.172 +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/KotlinAbstractUElement.kt.172 @@ -17,14 +17,12 @@ package org.jetbrains.uast.kotlin import com.intellij.psi.PsiElement -import org.jetbrains.kotlin.asJava.LightClassUtil import org.jetbrains.kotlin.asJava.toLightGetter import org.jetbrains.kotlin.asJava.toLightSetter import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType -import org.jetbrains.kotlin.psi.psiUtil.isPropertyParameter import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf import org.jetbrains.uast.* import org.jetbrains.uast.kotlin.expressions.KotlinUElvisExpression @@ -53,15 +51,6 @@ abstract class KotlinAbstractUElement(private val givenParent: UElement?) : UEle parent = (parentUnwrapped as? KtProperty)?.setter ?: (parentUnwrapped as? KtParameter)?.toLightSetter() ?: parent - AnnotationUseSiteTarget.FIELD -> - parent = (parentUnwrapped as? KtProperty) - ?: (parentUnwrapped as? KtParameter) - ?.takeIf { it.isPropertyParameter() } - ?.let(LightClassUtil::getLightClassBackingField) - ?: parent - AnnotationUseSiteTarget.SETTER_PARAMETER -> - parent = (parentUnwrapped as? KtParameter) - ?.toLightSetter()?.parameterList?.parameters?.firstOrNull() ?: parent } } if (psi is UastKotlinPsiVariable && parent != null) { diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/declarations/KotlinUVariable.kt.172 b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/declarations/KotlinUVariable.kt.172 index 00fc2b11aaf..69b0d6afb1c 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/declarations/KotlinUVariable.kt.172 +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/declarations/KotlinUVariable.kt.172 @@ -17,26 +17,19 @@ package org.jetbrains.uast.kotlin import com.intellij.psi.* -import com.intellij.psi.search.GlobalSearchScope -import org.jetbrains.annotations.NotNull -import org.jetbrains.annotations.Nullable import org.jetbrains.kotlin.asJava.classes.KtLightClass import org.jetbrains.kotlin.asJava.elements.KtLightElement -import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget import org.jetbrains.kotlin.psi.* -import org.jetbrains.kotlin.psi.psiUtil.getParentOfType -import org.jetbrains.kotlin.resolve.calls.callUtil.getType -import org.jetbrains.kotlin.types.KotlinType -import org.jetbrains.kotlin.types.typeUtil.TypeNullability -import org.jetbrains.kotlin.types.typeUtil.nullability -import org.jetbrains.kotlin.utils.SmartList import org.jetbrains.uast.* import org.jetbrains.uast.internal.acceptList import org.jetbrains.uast.java.JavaAbstractUExpression +import org.jetbrains.uast.java.JavaUAnnotation +import org.jetbrains.uast.java.annotations import org.jetbrains.uast.kotlin.declarations.UastLightIdentifier import org.jetbrains.uast.kotlin.internal.KotlinUElementWithComments import org.jetbrains.uast.kotlin.psi.UastKotlinPsiParameter import org.jetbrains.uast.kotlin.psi.UastKotlinPsiVariable +import org.jetbrains.uast.visitor.UastTypedVisitor import org.jetbrains.uast.visitor.UastVisitor abstract class AbstractKotlinUVariable(givenParent: UElement?) @@ -79,19 +72,7 @@ abstract class AbstractKotlinUVariable(givenParent: UElement?) override fun getContainingFile(): PsiFile = unwrapFakeFileForLightClass(psi.containingFile) - override val annotations by lz { - val sourcePsi = sourcePsi ?: return@lz psi.annotations.map { WrappedUAnnotation(it, this) } - val annotations = SmartList(KotlinNullabilityUAnnotation(sourcePsi, this)) - if (sourcePsi is KtModifierListOwner) { - sourcePsi.annotationEntries. - filter { acceptsAnnotationTarget(it.useSiteTarget?.getAnnotationUseSiteTarget()) }. - mapTo(annotations) { KotlinUAnnotation(it, this) } - } - annotations - } - - - abstract protected fun acceptsAnnotationTarget(target: AnnotationUseSiteTarget?): Boolean + override val annotations: List by lz { psi.annotations.map { WrappedUAnnotation(it, this) } } override val typeReference by lz { getLanguagePlugin().convertOpt(psi.typeElement, this) } @@ -141,8 +122,6 @@ class KotlinUVariable( override val typeReference by lz { getLanguagePlugin().convertOpt(psi.typeElement, this) } - override fun acceptsAnnotationTarget(target: AnnotationUseSiteTarget?): Boolean = true - override fun getInitializer(): PsiExpression? { return super.getInitializer() } @@ -163,28 +142,14 @@ class KotlinUVariable( open class KotlinUParameter( psi: PsiParameter, - final override val sourcePsi: KtElement?, + override val sourcePsi: KtElement?, givenParent: UElement? ) : AbstractKotlinUVariable(givenParent), UParameter, PsiParameter by psi { - final override val javaPsi = unwrap(psi) + override val javaPsi = unwrap(psi) override val psi = javaPsi - private val isLightConstructorParam by lz { psi.getParentOfType(true)?.isConstructor } - - private val isKtConstructorParam by lz { sourcePsi?.getParentOfType(true)?.let { it is KtConstructor<*> } } - - override fun acceptsAnnotationTarget(target: AnnotationUseSiteTarget?): Boolean { - if (sourcePsi !is KtParameter) return false - if (isKtConstructorParam == isLightConstructorParam && target == null) return true - when (target) { - AnnotationUseSiteTarget.CONSTRUCTOR_PARAMETER -> return isLightConstructorParam == true - AnnotationUseSiteTarget.SETTER_PARAMETER -> return isLightConstructorParam != true - else -> return false - } - } - override fun getInitializer(): PsiExpression? { return super.getInitializer() } @@ -202,67 +167,16 @@ open class KotlinUParameter( } } -class KotlinNullabilityUAnnotation(val annotatedElement: PsiElement, override val uastParent: UElement) : UAnnotation, JvmDeclarationUElement { - - private fun getTargetType(annotatedElement: PsiElement): KotlinType? { - if (annotatedElement is KtCallableDeclaration) { - annotatedElement.typeReference?.getType()?.let { return it } - } - if (annotatedElement is KtProperty) { - annotatedElement.initializer?.let { it.getType(it.analyze()) }?.let { return it } - annotatedElement.delegateExpression?.let { it.getType(it.analyze())?.arguments?.firstOrNull()?.type }?.let { return it } - } - annotatedElement.getParentOfType(false)?.let { - it.typeReference?.getType() ?: it.initializer?.let { it.getType(it.analyze()) } - }?.let { return it } - return null - } - - val nullability by lz { getTargetType(annotatedElement)?.nullability() } - - override val attributeValues: List - get() = emptyList() - override val psi: PsiElement? - get() = null - override val javaPsi: PsiAnnotation? - get() = null - override val sourcePsi: PsiElement? - get() = null - override val qualifiedName: String? - get() = when (nullability) { - TypeNullability.NOT_NULL -> NotNull::class.qualifiedName - TypeNullability.NULLABLE -> Nullable::class.qualifiedName - TypeNullability.FLEXIBLE -> null - null -> null - } - - override fun findAttributeValue(name: String?): UExpression? = null - - override fun findDeclaredAttributeValue(name: String?): UExpression? = null - - override fun resolve(): PsiClass? = qualifiedName?.let { - val project = annotatedElement.project - JavaPsiFacade.getInstance(project).findClass(it, GlobalSearchScope.allScope(project)) - } - -} - open class KotlinUField( psi: PsiField, override val sourcePsi: KtElement?, givenParent: UElement? ) : AbstractKotlinUVariable(givenParent), UField, PsiField by psi { - override fun getSourceElement() = sourcePsi ?: this override val javaPsi = unwrap(psi) override val psi = javaPsi - override fun acceptsAnnotationTarget(target: AnnotationUseSiteTarget?): Boolean = - target == AnnotationUseSiteTarget.FIELD || - target == AnnotationUseSiteTarget.PROPERTY_DELEGATE_FIELD || - (sourcePsi is KtProperty) && (target == null || target == AnnotationUseSiteTarget.PROPERTY) - override fun getInitializer(): PsiExpression? { return super.getInitializer() } @@ -300,8 +214,6 @@ open class KotlinULocalVariable( override val javaPsi = unwrap(psi) - override fun acceptsAnnotationTarget(target: AnnotationUseSiteTarget?): Boolean = true - override val psi = javaPsi override fun getInitializer(): PsiExpression? { @@ -355,8 +267,6 @@ open class KotlinUEnumConstant( override val psi = javaPsi - override fun acceptsAnnotationTarget(target: AnnotationUseSiteTarget?): Boolean = true - override fun getContainingFile(): PsiFile { return super.getContainingFile() } diff --git a/plugins/uast-kotlin/testData/DefaultParameterValues.log.txt.172 b/plugins/uast-kotlin/testData/DefaultParameterValues.log.txt.172 new file mode 100644 index 00000000000..d2f13973781 --- /dev/null +++ b/plugins/uast-kotlin/testData/DefaultParameterValues.log.txt.172 @@ -0,0 +1,10 @@ +UFile (package = ) + UClass (name = DefaultParameterValuesKt) + UAnnotationMethod (name = foo) + UParameter (name = a) + UAnnotation (fqName = null) + ULiteralExpression (value = 1) + UParameter (name = foo) + UAnnotation (fqName = org.jetbrains.annotations.Nullable) + ULiteralExpression (value = null) + UBlockExpression diff --git a/plugins/uast-kotlin/testData/DefaultParameterValues.render.txt.172 b/plugins/uast-kotlin/testData/DefaultParameterValues.render.txt.172 new file mode 100644 index 00000000000..9ce163e3ad2 --- /dev/null +++ b/plugins/uast-kotlin/testData/DefaultParameterValues.render.txt.172 @@ -0,0 +1,4 @@ +public final class DefaultParameterValuesKt { + public static final fun foo(@null a: int, @org.jetbrains.annotations.Nullable foo: java.lang.String) : void { + } +} diff --git a/plugins/uast-kotlin/testData/DestructuringDeclaration.log.txt.172 b/plugins/uast-kotlin/testData/DestructuringDeclaration.log.txt.172 new file mode 100644 index 00000000000..aa299050640 --- /dev/null +++ b/plugins/uast-kotlin/testData/DestructuringDeclaration.log.txt.172 @@ -0,0 +1,21 @@ +UFile (package = ) + UClass (name = DestructuringDeclarationKt) + UAnnotationMethod (name = foo) + UBlockExpression + UDeclarationsExpression + ULocalVariable (name = var268d4034) + UBinaryExpression (operator = ) + ULiteralExpression (value = "foo") + ULiteralExpression (value = 1) + ULocalVariable (name = a) + UQualifiedReferenceExpression + USimpleNameReferenceExpression (identifier = var268d4034) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) + UIdentifier (Identifier (component1)) + USimpleNameReferenceExpression (identifier = ) + ULocalVariable (name = b) + UQualifiedReferenceExpression + USimpleNameReferenceExpression (identifier = var268d4034) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) + UIdentifier (Identifier (component2)) + USimpleNameReferenceExpression (identifier = ) diff --git a/plugins/uast-kotlin/testData/DestructuringDeclaration.render.txt.172 b/plugins/uast-kotlin/testData/DestructuringDeclaration.render.txt.172 new file mode 100644 index 00000000000..1517c3ae90e --- /dev/null +++ b/plugins/uast-kotlin/testData/DestructuringDeclaration.render.txt.172 @@ -0,0 +1,7 @@ +public final class DestructuringDeclarationKt { + public static final fun foo() : void { + var var268d4034: = "foo" 1 + var a: java.lang.String = var268d4034.() + var b: int = var268d4034.() + } +} diff --git a/plugins/uast-kotlin/testData/Elvis.log.txt.172 b/plugins/uast-kotlin/testData/Elvis.log.txt.172 new file mode 100644 index 00000000000..a277ac953b6 --- /dev/null +++ b/plugins/uast-kotlin/testData/Elvis.log.txt.172 @@ -0,0 +1,46 @@ +UFile (package = ) + UClass (name = ElvisKt) + UAnnotationMethod (name = foo) + UParameter (name = bar) + UAnnotation (fqName = org.jetbrains.annotations.NotNull) + UBlockExpression + UReturnExpression + ULiteralExpression (value = null) + UAnnotationMethod (name = bar) + UBlockExpression + UReturnExpression + ULiteralExpression (value = 42) + UAnnotationMethod (name = baz) + UBlockExpression + UReturnExpression + UExpressionList (elvis) + UDeclarationsExpression + ULocalVariable (name = var243c51a0) + UExpressionList (elvis) + UDeclarationsExpression + ULocalVariable (name = varc4aef569) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) + UIdentifier (Identifier (foo)) + USimpleNameReferenceExpression (identifier = foo) + ULiteralExpression (value = "Lorem ipsum") + UIfExpression + UBinaryExpression (operator = !=) + USimpleNameReferenceExpression (identifier = varc4aef569) + ULiteralExpression (value = null) + USimpleNameReferenceExpression (identifier = varc4aef569) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) + UIdentifier (Identifier (foo)) + USimpleNameReferenceExpression (identifier = foo) + ULiteralExpression (value = "dolor sit amet") + UIfExpression + UBinaryExpression (operator = !=) + USimpleNameReferenceExpression (identifier = var243c51a0) + ULiteralExpression (value = null) + USimpleNameReferenceExpression (identifier = var243c51a0) + UQualifiedReferenceExpression + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) + UIdentifier (Identifier (bar)) + USimpleNameReferenceExpression (identifier = bar) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) + UIdentifier (Identifier (toString)) + USimpleNameReferenceExpression (identifier = toString) diff --git a/plugins/uast-kotlin/testData/Elvis.render.txt.172 b/plugins/uast-kotlin/testData/Elvis.render.txt.172 new file mode 100644 index 00000000000..2554f7d42fa --- /dev/null +++ b/plugins/uast-kotlin/testData/Elvis.render.txt.172 @@ -0,0 +1,17 @@ +public final class ElvisKt { + public static final fun foo(@org.jetbrains.annotations.NotNull bar: java.lang.String) : java.lang.String { + return null + } + public static final fun bar() : int { + return 42 + } + public static final fun baz() : java.lang.String { + return elvis { + var var243c51a0: java.lang.String = elvis { + var varc4aef569: java.lang.String = foo("Lorem ipsum") + if (varc4aef569 != null) varc4aef569 else foo("dolor sit amet") + } + if (var243c51a0 != null) var243c51a0 else bar().toString() + } + } +} diff --git a/plugins/uast-kotlin/testData/EnumValueMembers.log.txt.172 b/plugins/uast-kotlin/testData/EnumValueMembers.log.txt.172 new file mode 100644 index 00000000000..4a55c203622 --- /dev/null +++ b/plugins/uast-kotlin/testData/EnumValueMembers.log.txt.172 @@ -0,0 +1,17 @@ +UFile (package = ) + UClass (name = Style) + UEnumConstant (name = SHEET) + USimpleNameReferenceExpression (identifier = Style) + UClass (name = null) + UAnnotationMethod (name = getExitAnimation) + UBlockExpression + UReturnExpression + ULiteralExpression (value = "bar") + UAnnotationMethod (name = SHEET) + UField (name = value) + UAnnotation (fqName = org.jetbrains.annotations.NotNull) + UAnnotationMethod (name = getExitAnimation) + UAnnotationMethod (name = getValue) + UAnnotationMethod (name = Style) + UParameter (name = value) + UAnnotation (fqName = org.jetbrains.annotations.NotNull) diff --git a/plugins/uast-kotlin/testData/EnumValueMembers.render.txt.172 b/plugins/uast-kotlin/testData/EnumValueMembers.render.txt.172 new file mode 100644 index 00000000000..9544478939e --- /dev/null +++ b/plugins/uast-kotlin/testData/EnumValueMembers.render.txt.172 @@ -0,0 +1,10 @@ +public enum Style { + SHEET { + public fun getExitAnimation() : java.lang.String = "bar" + fun SHEET() = UastEmptyExpression + } + @org.jetbrains.annotations.NotNull private final var value: java.lang.String + public abstract fun getExitAnimation() : java.lang.String = UastEmptyExpression + public final fun getValue() : java.lang.String = UastEmptyExpression + protected fun Style(@org.jetbrains.annotations.NotNull value: java.lang.String) = UastEmptyExpression +} diff --git a/plugins/uast-kotlin/testData/InnerClasses.log.txt.172 b/plugins/uast-kotlin/testData/InnerClasses.log.txt.172 new file mode 100644 index 00000000000..729981260a9 --- /dev/null +++ b/plugins/uast-kotlin/testData/InnerClasses.log.txt.172 @@ -0,0 +1,27 @@ +UFile (package = ) + UClass (name = Foo) + UAnnotationMethod (name = Foo) + UClass (name = Bar) + UField (name = a) + UAnnotation (fqName = null) + UField (name = b) + UAnnotation (fqName = null) + UAnnotationMethod (name = getAPlusB) + UBlockExpression + UReturnExpression + UBinaryExpression (operator = +) + USimpleNameReferenceExpression (identifier = a) + USimpleNameReferenceExpression (identifier = b) + UAnnotationMethod (name = getA) + UAnnotationMethod (name = getB) + UAnnotationMethod (name = Bar) + UParameter (name = a) + UAnnotation (fqName = null) + UParameter (name = b) + UAnnotation (fqName = null) + UClass (name = Baz) + UAnnotationMethod (name = doNothing) + UBlockExpression + UReturnExpression + USimpleNameReferenceExpression (identifier = Unit) + UAnnotationMethod (name = Baz) diff --git a/plugins/uast-kotlin/testData/InnerClasses.render.txt.172 b/plugins/uast-kotlin/testData/InnerClasses.render.txt.172 new file mode 100644 index 00000000000..8d5cfd523a0 --- /dev/null +++ b/plugins/uast-kotlin/testData/InnerClasses.render.txt.172 @@ -0,0 +1,15 @@ +public final class Foo { + public fun Foo() = UastEmptyExpression + public static final class Bar { + @null private final var a: int + @null private final var b: int + public final fun getAPlusB() : int = a + b + public final fun getA() : int = UastEmptyExpression + public final fun getB() : int = UastEmptyExpression + public fun Bar(@null a: int, @null b: int) = UastEmptyExpression + public static final class Baz { + public final fun doNothing() : void = Unit + public fun Baz() = UastEmptyExpression + } + } +} diff --git a/plugins/uast-kotlin/testData/LocalDeclarations.log.txt.172 b/plugins/uast-kotlin/testData/LocalDeclarations.log.txt.172 new file mode 100644 index 00000000000..9dadf83072a --- /dev/null +++ b/plugins/uast-kotlin/testData/LocalDeclarations.log.txt.172 @@ -0,0 +1,33 @@ +UFile (package = ) + UClass (name = LocalDeclarationsKt) + UAnnotationMethod (name = foo) + UBlockExpression + UDeclarationsExpression + UClass (name = Local) + UAnnotationMethod (name = LocalDeclarationsKt$foo$Local) + UDeclarationsExpression + UVariable (name = bar) + ULambdaExpression + UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0)) + UIdentifier (Identifier (Local)) + USimpleNameReferenceExpression (identifier = ) + UDeclarationsExpression + ULocalVariable (name = baz) + ULambdaExpression + UBlockExpression + UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0)) + UIdentifier (Identifier (Local)) + USimpleNameReferenceExpression (identifier = ) + UDeclarationsExpression + UVariable (name = someLocalFun) + ULambdaExpression + UParameter (name = text) + ULiteralExpression (value = 42) + UReturnExpression + UBinaryExpression (operator = ==) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) + UIdentifier (Identifier (bar)) + USimpleNameReferenceExpression (identifier = bar) + UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0)) + UIdentifier (Identifier (Local)) + USimpleNameReferenceExpression (identifier = ) diff --git a/plugins/uast-kotlin/testData/LocalDeclarations.render.txt.172 b/plugins/uast-kotlin/testData/LocalDeclarations.render.txt.172 new file mode 100644 index 00000000000..8768433111f --- /dev/null +++ b/plugins/uast-kotlin/testData/LocalDeclarations.render.txt.172 @@ -0,0 +1,17 @@ +public final class LocalDeclarationsKt { + public static final fun foo() : boolean { + public static final class Local { + public fun LocalDeclarationsKt$foo$Local() = UastEmptyExpression + } + var bar: = fun () { + () + } + var baz: kotlin.jvm.functions.Function0 = fun () { + () + } + var someLocalFun: kotlin.jvm.functions.Function2 = fun (var text: java.lang.String) { + 42 + } + return bar() == () + } +} diff --git a/plugins/uast-kotlin/testData/LocalDeclarations.types.txt.172 b/plugins/uast-kotlin/testData/LocalDeclarations.types.txt.172 new file mode 100644 index 00000000000..2d879604d74 --- /dev/null +++ b/plugins/uast-kotlin/testData/LocalDeclarations.types.txt.172 @@ -0,0 +1,33 @@ +UFile (package = ) [public final class LocalDeclarationsKt {...] + UClass (name = LocalDeclarationsKt) [public final class LocalDeclarationsKt {...}] + UAnnotationMethod (name = foo) [public static final fun foo() : boolean {...}] + UBlockExpression [{...}] : PsiType:Void + UDeclarationsExpression [public static final class Local {...}] + UClass (name = Local) [public static final class Local {...}] + UAnnotationMethod (name = LocalDeclarationsKt$foo$Local) [public fun LocalDeclarationsKt$foo$Local() = UastEmptyExpression] + UDeclarationsExpression [var bar: = fun () {...}] + UVariable (name = bar) [var bar: = fun () {...}] + ULambdaExpression [fun () {...}] + UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0)) [()] : PsiType: + UIdentifier (Identifier (Local)) [UIdentifier (Identifier (Local))] + USimpleNameReferenceExpression (identifier = ) [] : PsiType: + UDeclarationsExpression [var baz: kotlin.jvm.functions.Function0 = fun () {...}] + ULocalVariable (name = baz) [var baz: kotlin.jvm.functions.Function0 = fun () {...}] + ULambdaExpression [fun () {...}] + UBlockExpression [{...}] : PsiType: + UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0)) [()] : PsiType: + UIdentifier (Identifier (Local)) [UIdentifier (Identifier (Local))] + USimpleNameReferenceExpression (identifier = ) [] : PsiType: + UDeclarationsExpression [var someLocalFun: kotlin.jvm.functions.Function2 = fun (var text: java.lang.String) {...}] + UVariable (name = someLocalFun) [var someLocalFun: kotlin.jvm.functions.Function2 = fun (var text: java.lang.String) {...}] + ULambdaExpression [fun (var text: java.lang.String) {...}] + UParameter (name = text) [var text: java.lang.String] + ULiteralExpression (value = 42) [42] : PsiType:int + UReturnExpression [return bar() == ()] : PsiType:Void + UBinaryExpression (operator = ==) [bar() == ()] : PsiType:boolean + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) [bar()] : PsiType: + UIdentifier (Identifier (bar)) [UIdentifier (Identifier (bar))] + USimpleNameReferenceExpression (identifier = bar) [bar] : PsiType: + UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0)) [()] : PsiType: + UIdentifier (Identifier (Local)) [UIdentifier (Identifier (Local))] + USimpleNameReferenceExpression (identifier = ) [] : PsiType: diff --git a/plugins/uast-kotlin/testData/LocalDeclarations.values.txt.172 b/plugins/uast-kotlin/testData/LocalDeclarations.values.txt.172 new file mode 100644 index 00000000000..d4f166a086e --- /dev/null +++ b/plugins/uast-kotlin/testData/LocalDeclarations.values.txt.172 @@ -0,0 +1,33 @@ +UFile (package = ) [public final class LocalDeclarationsKt {...] + UClass (name = LocalDeclarationsKt) [public final class LocalDeclarationsKt {...}] + UAnnotationMethod (name = foo) [public static final fun foo() : boolean {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [public static final class Local {...}] = Undetermined + UClass (name = Local) [public static final class Local {...}] + UAnnotationMethod (name = LocalDeclarationsKt$foo$Local) [public fun LocalDeclarationsKt$foo$Local() = UastEmptyExpression] + UDeclarationsExpression [var bar: = fun () {...}] = Undetermined + UVariable (name = bar) [var bar: = fun () {...}] + ULambdaExpression [fun () {...}] = Undetermined + UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0)) [()] = external ()() + UIdentifier (Identifier (Local)) [UIdentifier (Identifier (Local))] + USimpleNameReferenceExpression (identifier = ) [] = external ()() + UDeclarationsExpression [var baz: kotlin.jvm.functions.Function0 = fun () {...}] = Undetermined + ULocalVariable (name = baz) [var baz: kotlin.jvm.functions.Function0 = fun () {...}] + ULambdaExpression [fun () {...}] = Undetermined + UBlockExpression [{...}] = external ()() + UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0)) [()] = external ()() + UIdentifier (Identifier (Local)) [UIdentifier (Identifier (Local))] + USimpleNameReferenceExpression (identifier = ) [] = external ()() + UDeclarationsExpression [var someLocalFun: kotlin.jvm.functions.Function2 = fun (var text: java.lang.String) {...}] = Undetermined + UVariable (name = someLocalFun) [var someLocalFun: kotlin.jvm.functions.Function2 = fun (var text: java.lang.String) {...}] + ULambdaExpression [fun (var text: java.lang.String) {...}] = Undetermined + UParameter (name = text) [var text: java.lang.String] + ULiteralExpression (value = 42) [42] = 42 + UReturnExpression [return bar() == ()] = Nothing + UBinaryExpression (operator = ==) [bar() == ()] = Undetermined + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) [bar()] = external bar()() + UIdentifier (Identifier (bar)) [UIdentifier (Identifier (bar))] + USimpleNameReferenceExpression (identifier = bar) [bar] = external bar()() + UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0)) [()] = external ()() + UIdentifier (Identifier (Local)) [UIdentifier (Identifier (Local))] + USimpleNameReferenceExpression (identifier = ) [] = external ()() diff --git a/plugins/uast-kotlin/testData/ParameterPropertyWithAnnotation.log.txt.172 b/plugins/uast-kotlin/testData/ParameterPropertyWithAnnotation.log.txt.172 new file mode 100644 index 00000000000..69573a72273 --- /dev/null +++ b/plugins/uast-kotlin/testData/ParameterPropertyWithAnnotation.log.txt.172 @@ -0,0 +1,31 @@ +UFile (package = ) + UClass (name = MyAnnotation) + UClass (name = MyAnnotation2) + UClass (name = MyAnnotation3) + UClass (name = MyAnnotation4) + UClass (name = MyAnnotation5) + UClass (name = Test1) + UField (name = bar) + UAnnotation (fqName = null) + UAnnotationMethod (name = getBar) + UAnnotationMethod (name = setBar) + UParameter (name = p) + UAnnotation (fqName = null) + UAnnotationMethod (name = Test1) + UParameter (name = bar) + UAnnotation (fqName = MyAnnotation) + UAnnotation (fqName = null) + UClass (name = Test2) + UField (name = bar) + UAnnotation (fqName = MyAnnotation5) + UAnnotation (fqName = null) + UAnnotationMethod (name = getBar) + UAnnotation (fqName = MyAnnotation) + UAnnotationMethod (name = setBar) + UAnnotation (fqName = MyAnnotation2) + UParameter (name = p) + UAnnotation (fqName = MyAnnotation3) + UAnnotation (fqName = null) + UAnnotationMethod (name = Test2) + UParameter (name = bar) + UAnnotation (fqName = null) diff --git a/plugins/uast-kotlin/testData/ParameterPropertyWithAnnotation.render.txt.172 b/plugins/uast-kotlin/testData/ParameterPropertyWithAnnotation.render.txt.172 new file mode 100644 index 00000000000..efd21da3642 --- /dev/null +++ b/plugins/uast-kotlin/testData/ParameterPropertyWithAnnotation.render.txt.172 @@ -0,0 +1,30 @@ +public abstract annotation MyAnnotation { +} + +public abstract annotation MyAnnotation2 { +} + +public abstract annotation MyAnnotation3 { +} + +public abstract annotation MyAnnotation4 { +} + +public abstract annotation MyAnnotation5 { +} + +public final class Test1 { + @null private var bar: int + public final fun getBar() : int = UastEmptyExpression + public final fun setBar(@null p: int) : void = UastEmptyExpression + public fun Test1(@MyAnnotation @null bar: int) = UastEmptyExpression +} + +public final class Test2 { + @MyAnnotation5 @null private var bar: int + @MyAnnotation + public final fun getBar() : int = UastEmptyExpression + @MyAnnotation2 + public final fun setBar(@MyAnnotation3 @null p: int) : void = UastEmptyExpression + public fun Test2(@null bar: int) = UastEmptyExpression +} diff --git a/plugins/uast-kotlin/testData/ParametersWithDefaultValues.log.txt.172 b/plugins/uast-kotlin/testData/ParametersWithDefaultValues.log.txt.172 new file mode 100644 index 00000000000..325d638ff65 --- /dev/null +++ b/plugins/uast-kotlin/testData/ParametersWithDefaultValues.log.txt.172 @@ -0,0 +1,14 @@ +UFile (package = ) + UClass (name = ParametersWithDefaultValuesKt) + UAnnotationMethod (name = foo) + UParameter (name = a) + UAnnotation (fqName = null) + UParameter (name = b) + UAnnotation (fqName = org.jetbrains.annotations.NotNull) + UParameter (name = c) + UAnnotation (fqName = null) + ULiteralExpression (value = 0) + UParameter (name = flag) + UAnnotation (fqName = null) + ULiteralExpression (value = false) + UBlockExpression diff --git a/plugins/uast-kotlin/testData/ParametersWithDefaultValues.render.txt.172 b/plugins/uast-kotlin/testData/ParametersWithDefaultValues.render.txt.172 new file mode 100644 index 00000000000..febae6d0326 --- /dev/null +++ b/plugins/uast-kotlin/testData/ParametersWithDefaultValues.render.txt.172 @@ -0,0 +1,4 @@ +public final class ParametersWithDefaultValuesKt { + public static final fun foo(@null a: int, @org.jetbrains.annotations.NotNull b: java.lang.String, @null c: int, @null flag: boolean) : void { + } +} diff --git a/plugins/uast-kotlin/testData/PropertyDelegate.kt.172 b/plugins/uast-kotlin/testData/PropertyDelegate.kt.172 new file mode 100644 index 00000000000..4cc642ec36f --- /dev/null +++ b/plugins/uast-kotlin/testData/PropertyDelegate.kt.172 @@ -0,0 +1,5 @@ +val sdCardPath by lazy { "/sdcard" } + +fun localPropertyTest() { + val sdCardPathLocal by lazy { "/sdcard" } +} \ No newline at end of file diff --git a/plugins/uast-kotlin/testData/PropertyDelegate.log.txt.172 b/plugins/uast-kotlin/testData/PropertyDelegate.log.txt.172 new file mode 100644 index 00000000000..04df9270c82 --- /dev/null +++ b/plugins/uast-kotlin/testData/PropertyDelegate.log.txt.172 @@ -0,0 +1,21 @@ +UFile (package = ) + UClass (name = PropertyDelegateKt) + UField (name = sdCardPath$delegate) + UAnnotation (fqName = org.jetbrains.annotations.NotNull) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) + UIdentifier (Identifier (lazy)) + USimpleNameReferenceExpression (identifier = lazy) + ULambdaExpression + UBlockExpression + ULiteralExpression (value = "/sdcard") + UAnnotationMethod (name = getSdCardPath) + UAnnotationMethod (name = localPropertyTest) + UBlockExpression + UDeclarationsExpression + ULocalVariable (name = sdCardPathLocal) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) + UIdentifier (Identifier (lazy)) + USimpleNameReferenceExpression (identifier = lazy) + ULambdaExpression + UBlockExpression + ULiteralExpression (value = "/sdcard") diff --git a/plugins/uast-kotlin/testData/PropertyDelegate.render.txt.172 b/plugins/uast-kotlin/testData/PropertyDelegate.render.txt.172 new file mode 100644 index 00000000000..d496ac695d7 --- /dev/null +++ b/plugins/uast-kotlin/testData/PropertyDelegate.render.txt.172 @@ -0,0 +1,7 @@ +public final class PropertyDelegateKt { + @org.jetbrains.annotations.NotNull private static final var sdCardPath$delegate: kotlin.Lazy + public static final fun getSdCardPath() : java.lang.String = UastEmptyExpression + public static final fun localPropertyTest() : void { + var sdCardPathLocal: java.lang.String + } +} diff --git a/plugins/uast-kotlin/testData/PropertyWithAnnotation.log.txt.172 b/plugins/uast-kotlin/testData/PropertyWithAnnotation.log.txt.172 new file mode 100644 index 00000000000..c9edf363f64 --- /dev/null +++ b/plugins/uast-kotlin/testData/PropertyWithAnnotation.log.txt.172 @@ -0,0 +1,27 @@ +UFile (package = ) + UClass (name = PropertyWithAnnotationKt) + UField (name = prop1) + UAnnotation (fqName = null) + ULiteralExpression (value = 0) + UField (name = prop3) + UAnnotation (fqName = null) + ULiteralExpression (value = 0) + UAnnotationMethod (name = getProp1) + UAnnotationMethod (name = getProp2) + UAnnotation (fqName = TestAnnotation) + UBlockExpression + UReturnExpression + ULiteralExpression (value = 0) + UAnnotationMethod (name = getProp3) + UBlockExpression + UReturnExpression + ULiteralExpression (value = 0) + UAnnotationMethod (name = setProp3) + UAnnotation (fqName = TestAnnotation) + UParameter (name = value) + UAnnotation (fqName = null) + UBlockExpression + UBinaryExpression (operator = =) + USimpleNameReferenceExpression (identifier = field) + USimpleNameReferenceExpression (identifier = value) + UClass (name = TestAnnotation) diff --git a/plugins/uast-kotlin/testData/PropertyWithAnnotation.render.txt.172 b/plugins/uast-kotlin/testData/PropertyWithAnnotation.render.txt.172 new file mode 100644 index 00000000000..2cadfac1ccf --- /dev/null +++ b/plugins/uast-kotlin/testData/PropertyWithAnnotation.render.txt.172 @@ -0,0 +1,19 @@ +public final class PropertyWithAnnotationKt { + @null private static final var prop1: int = 0 + @null private static var prop3: int = 0 + public static final fun getProp1() : int = UastEmptyExpression + @TestAnnotation + public static final fun getProp2() : int { + return 0 + } + public static final fun getProp3() : int { + return 0 + } + @TestAnnotation + public static final fun setProp3(@null value: int) : void { + field = value + } +} + +public abstract annotation TestAnnotation { +} diff --git a/plugins/uast-kotlin/testData/SimpleAnnotated.kt.172 b/plugins/uast-kotlin/testData/SimpleAnnotated.kt.172 new file mode 100644 index 00000000000..e69de29bb2d diff --git a/plugins/uast-kotlin/testData/SimpleScript.log.txt.172 b/plugins/uast-kotlin/testData/SimpleScript.log.txt.172 new file mode 100644 index 00000000000..bed93896f9a --- /dev/null +++ b/plugins/uast-kotlin/testData/SimpleScript.log.txt.172 @@ -0,0 +1,51 @@ +UFile (package = ) + UClass (name = SimpleScript) + UAnnotationMethod (name = getBarOrNull) + UParameter (name = flag) + UAnnotation (fqName = null) + UBlockExpression + UReturnExpression + UIfExpression + USimpleNameReferenceExpression (identifier = flag) + UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1)) + UIdentifier (Identifier (Bar)) + USimpleNameReferenceExpression (identifier = ) + ULiteralExpression (value = 42) + ULiteralExpression (value = null) + UAnnotationMethod (name = SimpleScript) + UParameter (name = p) + UAnnotation (fqName = null) + UBlockExpression + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) + UIdentifier (Identifier (println)) + USimpleNameReferenceExpression (identifier = println) + ULiteralExpression (value = "Hello World!") + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) + UIdentifier (Identifier (getBarOrNull)) + USimpleNameReferenceExpression (identifier = getBarOrNull) + ULiteralExpression (value = true) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) + UIdentifier (Identifier (println)) + USimpleNameReferenceExpression (identifier = println) + ULiteralExpression (value = "Goodbye World!") + UClass (name = Bar) + UField (name = b) + UAnnotation (fqName = null) + ULiteralExpression (value = 0) + UField (name = a) + UAnnotation (fqName = null) + UAnnotationMethod (name = getB) + UAnnotationMethod (name = getAPlusB) + UBlockExpression + UReturnExpression + UBinaryExpression (operator = +) + USimpleNameReferenceExpression (identifier = a) + USimpleNameReferenceExpression (identifier = b) + UAnnotationMethod (name = getA) + UAnnotationMethod (name = Bar) + UParameter (name = a) + UAnnotation (fqName = null) + UClass (name = Baz) + UAnnotationMethod (name = doSomething) + UBlockExpression + UAnnotationMethod (name = Baz) diff --git a/plugins/uast-kotlin/testData/SimpleScript.render.txt.172 b/plugins/uast-kotlin/testData/SimpleScript.render.txt.172 index 8f780ccfcbf..892fe3dad7d 100644 --- a/plugins/uast-kotlin/testData/SimpleScript.render.txt.172 +++ b/plugins/uast-kotlin/testData/SimpleScript.render.txt.172 @@ -1,5 +1,5 @@ public class SimpleScript : kotlin.script.templates.standard.ScriptTemplateWithArgs { - public final fun getBarOrNull(@org.jetbrains.annotations.NotNull flag: boolean) : SimpleScript.Bar { + public final fun getBarOrNull(@null flag: boolean) : SimpleScript.Bar { return if (flag) (42) else null } public fun SimpleScript(@null p: java.lang.String[]) { @@ -8,14 +8,14 @@ public class SimpleScript : kotlin.script.templates.standard.ScriptTemplateWithA println("Goodbye World!") } public static final class Bar { - @org.jetbrains.annotations.NotNull private final var b: int = 0 - @org.jetbrains.annotations.NotNull private final var a: int + @null private final var b: int = 0 + @null private final var a: int public final fun getB() : int = UastEmptyExpression public final fun getAPlusB() : int { return a + b } public final fun getA() : int = UastEmptyExpression - public fun Bar(@org.jetbrains.annotations.NotNull a: int) = UastEmptyExpression + public fun Bar(@null a: int) = UastEmptyExpression public static final class Baz { public final fun doSomething() : void { } diff --git a/plugins/uast-kotlin/testData/StringTemplateComplex.log.txt.172 b/plugins/uast-kotlin/testData/StringTemplateComplex.log.txt.172 new file mode 100644 index 00000000000..1d3c41687a0 --- /dev/null +++ b/plugins/uast-kotlin/testData/StringTemplateComplex.log.txt.172 @@ -0,0 +1,70 @@ +UFile (package = ) + UClass (name = StringTemplateComplexKt) + UField (name = muchRecur) + UAnnotation (fqName = org.jetbrains.annotations.NotNull) + ULiteralExpression (value = "abc") + UField (name = case4) + UAnnotation (fqName = org.jetbrains.annotations.NotNull) + UPolyadicExpression (operator = +) + ULiteralExpression (value = "a ") + ULiteralExpression (value = "literal") + ULiteralExpression (value = " z") + UField (name = case5) + UAnnotation (fqName = org.jetbrains.annotations.NotNull) + UPolyadicExpression (operator = +) + ULiteralExpression (value = "a ") + ULiteralExpression (value = "literal") + ULiteralExpression (value = " ") + ULiteralExpression (value = "literal") + ULiteralExpression (value = " z") + UField (name = literalInLiteral) + UAnnotation (fqName = org.jetbrains.annotations.NotNull) + UPolyadicExpression (operator = +) + ULiteralExpression (value = "a ") + UPolyadicExpression (operator = +) + ULiteralExpression (value = "literal") + USimpleNameReferenceExpression (identifier = case4) + ULiteralExpression (value = " z") + UField (name = literalInLiteral2) + UAnnotation (fqName = org.jetbrains.annotations.NotNull) + UPolyadicExpression (operator = +) + ULiteralExpression (value = "a ") + UQualifiedReferenceExpression + UPolyadicExpression (operator = +) + ULiteralExpression (value = "literal") + USimpleNameReferenceExpression (identifier = case4) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) + UIdentifier (Identifier (repeat)) + USimpleNameReferenceExpression (identifier = repeat) + ULiteralExpression (value = 4) + ULiteralExpression (value = " z") + UAnnotationMethod (name = getMuchRecur) + UAnnotationMethod (name = getCase4) + UAnnotationMethod (name = getCase5) + UAnnotationMethod (name = getLiteralInLiteral) + UAnnotationMethod (name = getLiteralInLiteral2) + UAnnotationMethod (name = simpleForTemplate) + UParameter (name = i) + UAnnotation (fqName = null) + ULiteralExpression (value = 0) + UBlockExpression + UReturnExpression + USimpleNameReferenceExpression (identifier = i) + UAnnotationMethod (name = foo) + UBlockExpression + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) + UIdentifier (Identifier (println)) + USimpleNameReferenceExpression (identifier = println) + USimpleNameReferenceExpression (identifier = baz) + UDeclarationsExpression + ULocalVariable (name = template1) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) + UIdentifier (Identifier (simpleForTemplate)) + USimpleNameReferenceExpression (identifier = simpleForTemplate) + UDeclarationsExpression + ULocalVariable (name = template2) + UPolyadicExpression (operator = +) + ULiteralExpression (value = ".") + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) + UIdentifier (Identifier (simpleForTemplate)) + USimpleNameReferenceExpression (identifier = simpleForTemplate) diff --git a/plugins/uast-kotlin/testData/StringTemplateComplex.render.txt.172 b/plugins/uast-kotlin/testData/StringTemplateComplex.render.txt.172 new file mode 100644 index 00000000000..f6ddce4f5a4 --- /dev/null +++ b/plugins/uast-kotlin/testData/StringTemplateComplex.render.txt.172 @@ -0,0 +1,18 @@ +public final class StringTemplateComplexKt { + @org.jetbrains.annotations.NotNull private static final var muchRecur: java.lang.String = "abc" + @org.jetbrains.annotations.NotNull private static final var case4: java.lang.String = "a " + "literal" + " z" + @org.jetbrains.annotations.NotNull private static final var case5: java.lang.String = "a " + "literal" + " " + "literal" + " z" + @org.jetbrains.annotations.NotNull private static final var literalInLiteral: java.lang.String = "a " + "literal" + case4 + " z" + @org.jetbrains.annotations.NotNull private static final var literalInLiteral2: java.lang.String = "a " + "literal" + case4.repeat(4) + " z" + public static final fun getMuchRecur() : java.lang.String = UastEmptyExpression + public static final fun getCase4() : java.lang.String = UastEmptyExpression + public static final fun getCase5() : java.lang.String = UastEmptyExpression + public static final fun getLiteralInLiteral() : java.lang.String = UastEmptyExpression + public static final fun getLiteralInLiteral2() : java.lang.String = UastEmptyExpression + public static final fun simpleForTemplate(@null i: int) : java.lang.String = i + public static final fun foo() : void { + println(baz) + var template1: java.lang.String = simpleForTemplate() + var template2: java.lang.String = "." + simpleForTemplate() + } +} diff --git a/plugins/uast-kotlin/testData/SuperCalls.log.txt.172 b/plugins/uast-kotlin/testData/SuperCalls.log.txt.172 new file mode 100644 index 00000000000..72f6c3fd797 --- /dev/null +++ b/plugins/uast-kotlin/testData/SuperCalls.log.txt.172 @@ -0,0 +1,109 @@ +UFile (package = ) + UClass (name = SuperCallsKt) + UField (name = anon) + UAnnotation (fqName = org.jetbrains.annotations.NotNull) + UObjectLiteralExpression + ULiteralExpression (value = "textForAnon") + UClass (name = null) + UAnnotationMethod (name = bar) + UBlockExpression + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) + UIdentifier (Identifier (cons)) + USimpleNameReferenceExpression (identifier = cons) + UObjectLiteralExpression + ULiteralExpression (value = "inner literal") + UClass (name = null) + UAnnotationMethod (name = SuperCallsKt$anon$1$bar$1) + UAnnotationMethod (name = SuperCallsKt$anon$1) + UClass (name = innerObject) + UField (name = INSTANCE) + UAnnotation (fqName = null) + UAnnotationMethod (name = innerObject) + UBlockExpression + UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1)) + UIdentifier (Identifier (A)) + USimpleNameReferenceExpression (identifier = ) + ULiteralExpression (value = "inner object") + UClass (name = InnerClass) + UAnnotationMethod (name = InnerClass) + UBlockExpression + UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1)) + UIdentifier (Identifier (A)) + USimpleNameReferenceExpression (identifier = ) + ULiteralExpression (value = "inner class") + UAnnotationMethod (name = getAnon) + UAnnotationMethod (name = cons) + UParameter (name = a) + UAnnotation (fqName = org.jetbrains.annotations.NotNull) + UBlockExpression + UClass (name = A) + UField (name = str) + UAnnotation (fqName = org.jetbrains.annotations.NotNull) + UAnnotationMethod (name = foo) + UParameter (name = a) + UAnnotation (fqName = null) + UBlockExpression + UAnnotationMethod (name = getStr) + UAnnotationMethod (name = A) + UParameter (name = str) + UAnnotation (fqName = org.jetbrains.annotations.NotNull) + UAnnotationMethod (name = A) + UParameter (name = i) + UAnnotation (fqName = null) + UBlockExpression + UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1)) + UIdentifier (Identifier (this)) + USimpleNameReferenceExpression (identifier = ) + UQualifiedReferenceExpression + USimpleNameReferenceExpression (identifier = i) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) + UIdentifier (Identifier (toString)) + USimpleNameReferenceExpression (identifier = toString) + UClass (name = B) + UAnnotationMethod (name = B) + UParameter (name = param) + UAnnotation (fqName = org.jetbrains.annotations.NotNull) + UBlockExpression + UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1)) + UIdentifier (Identifier (A)) + USimpleNameReferenceExpression (identifier = ) + USimpleNameReferenceExpression (identifier = param) + UClass (name = C) + UAnnotationMethod (name = foo) + UParameter (name = a) + UAnnotation (fqName = null) + UBlockExpression + UQualifiedReferenceExpression + USuperExpression (label = null) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) + UIdentifier (Identifier (foo)) + USimpleNameReferenceExpression (identifier = foo) + USimpleNameReferenceExpression (identifier = a) + UAnnotationMethod (name = C) + UParameter (name = p) + UAnnotation (fqName = org.jetbrains.annotations.NotNull) + UBlockExpression + UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1)) + UIdentifier (Identifier (super)) + USimpleNameReferenceExpression (identifier = ) + USimpleNameReferenceExpression (identifier = p) + UAnnotationMethod (name = C) + UParameter (name = i) + UAnnotation (fqName = null) + UBlockExpression + UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1)) + UIdentifier (Identifier (super)) + USimpleNameReferenceExpression (identifier = ) + USimpleNameReferenceExpression (identifier = i) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) + UIdentifier (Identifier (println)) + USimpleNameReferenceExpression (identifier = println) + UClass (name = O) + UField (name = INSTANCE) + UAnnotation (fqName = null) + UAnnotationMethod (name = O) + UBlockExpression + UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1)) + UIdentifier (Identifier (A)) + USimpleNameReferenceExpression (identifier = ) + ULiteralExpression (value = "text") diff --git a/plugins/uast-kotlin/testData/SuperCalls.render.txt.172 b/plugins/uast-kotlin/testData/SuperCalls.render.txt.172 new file mode 100644 index 00000000000..b93fdf2fa81 --- /dev/null +++ b/plugins/uast-kotlin/testData/SuperCalls.render.txt.172 @@ -0,0 +1,51 @@ +public final class SuperCallsKt { + @org.jetbrains.annotations.NotNull private static final var anon: A = anonymous object : A("textForAnon") { + fun bar() { + cons(object : A("inner literal")) + } + + object innerObject : A("inner object") + + inner class InnerClass : A("inner class") + } + public static final fun getAnon() : A = UastEmptyExpression + public static final fun cons(@org.jetbrains.annotations.NotNull a: A) : void { + } +} + +public class A { + @org.jetbrains.annotations.NotNull private final var str: java.lang.String + public fun foo(@null a: long) : void { + } + public final fun getStr() : java.lang.String = UastEmptyExpression + public fun A(@org.jetbrains.annotations.NotNull str: java.lang.String) = UastEmptyExpression + public fun A(@null i: int) { + (i.toString()) + } +} + +public final class B : A { + public fun B(@org.jetbrains.annotations.NotNull param: java.lang.String) { + (param) + } +} + +public final class C : A { + public fun foo(@null a: long) : void { + super.foo(a) + } + public fun C(@org.jetbrains.annotations.NotNull p: java.lang.String) { + (p) + } + public fun C(@null i: int) { + (i) + println() + } +} + +public final class O : A { + @null public static final var INSTANCE: O + private fun O() { + ("text") + } +} diff --git a/plugins/uast-kotlin/testData/WhenAndDestructing.log.txt.172 b/plugins/uast-kotlin/testData/WhenAndDestructing.log.txt.172 new file mode 100644 index 00000000000..fe1b4642d28 --- /dev/null +++ b/plugins/uast-kotlin/testData/WhenAndDestructing.log.txt.172 @@ -0,0 +1,42 @@ +UFile (package = ) + UClass (name = WhenAndDestructingKt) + UAnnotationMethod (name = getElementsAdditionalResolve) + UParameter (name = string) + UAnnotation (fqName = org.jetbrains.annotations.NotNull) + UBlockExpression + UDeclarationsExpression + ULocalVariable (name = arr) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 2)) + UIdentifier (Identifier (listOf)) + USimpleNameReferenceExpression (identifier = listOf) + ULiteralExpression (value = "1") + ULiteralExpression (value = "2") + USwitchExpression + USimpleNameReferenceExpression (identifier = string) + UExpressionList (when) + USwitchClauseExpressionWithBody + ULiteralExpression (value = "aaaa") + UExpressionList (when_entry) + UReturnExpression + ULiteralExpression (value = "bindingContext") + UBreakExpression (label = null) + USwitchClauseExpressionWithBody + UExpressionList (when_entry) + UDeclarationsExpression + ULocalVariable (name = var837f1e82) + USimpleNameReferenceExpression (identifier = arr) + ULocalVariable (name = bindingContext) + UQualifiedReferenceExpression + USimpleNameReferenceExpression (identifier = var837f1e82) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) + UIdentifier (Identifier (component1)) + USimpleNameReferenceExpression (identifier = ) + ULocalVariable (name = statementFilter) + UQualifiedReferenceExpression + USimpleNameReferenceExpression (identifier = var837f1e82) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) + UIdentifier (Identifier (component2)) + USimpleNameReferenceExpression (identifier = ) + UReturnExpression + USimpleNameReferenceExpression (identifier = bindingContext) + UBreakExpression (label = null) diff --git a/plugins/uast-kotlin/testData/WhenAndDestructing.render.txt.172 b/plugins/uast-kotlin/testData/WhenAndDestructing.render.txt.172 new file mode 100644 index 00000000000..958e1b76605 --- /dev/null +++ b/plugins/uast-kotlin/testData/WhenAndDestructing.render.txt.172 @@ -0,0 +1,21 @@ +public final class WhenAndDestructingKt { + public static final fun getElementsAdditionalResolve(@org.jetbrains.annotations.NotNull string: java.lang.String) : java.lang.String { + var arr: java.util.List = listOf("1", "2") + switch (string) { + "aaaa" -> { + return "bindingContext" + break + } + + -> { + var var837f1e82: = arr + var bindingContext: java.lang.String = var837f1e82.() + var statementFilter: java.lang.String = var837f1e82.() + return bindingContext + break + } + + } + + } +} diff --git a/plugins/uast-kotlin/testData/WhenStringLiteral.log.txt.172 b/plugins/uast-kotlin/testData/WhenStringLiteral.log.txt.172 new file mode 100644 index 00000000000..af5adb2662f --- /dev/null +++ b/plugins/uast-kotlin/testData/WhenStringLiteral.log.txt.172 @@ -0,0 +1,33 @@ +UFile (package = ) + UClass (name = WhenStringLiteralKt) + UField (name = a) + UAnnotation (fqName = org.jetbrains.annotations.Nullable) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) + UIdentifier (Identifier (readLine)) + USimpleNameReferenceExpression (identifier = readLine) + UField (name = b) + UAnnotation (fqName = null) + USwitchExpression + USimpleNameReferenceExpression (identifier = a) + UExpressionList (when) + USwitchClauseExpressionWithBody + ULiteralExpression (value = "abc") + UExpressionList (when_entry) + ULiteralExpression (value = 1) + UBreakExpression (label = null) + USwitchClauseExpressionWithBody + ULiteralExpression (value = "def") + ULiteralExpression (value = "ghi") + UExpressionList (when_entry) + ULiteralExpression (value = 2) + UBreakExpression (label = null) + USwitchClauseExpressionWithBody + UExpressionList (when_entry) + ULiteralExpression (value = 3) + UBreakExpression (label = null) + UAnnotationMethod (name = getA) + UAnnotationMethod (name = getB) + UAnnotationMethod (name = ) + UBlockExpression + ULiteralExpression (value = "abc1") + ULiteralExpression (value = "def1") diff --git a/plugins/uast-kotlin/testData/WhenStringLiteral.render.txt.172 b/plugins/uast-kotlin/testData/WhenStringLiteral.render.txt.172 new file mode 100644 index 00000000000..2992788c0d5 --- /dev/null +++ b/plugins/uast-kotlin/testData/WhenStringLiteral.render.txt.172 @@ -0,0 +1,27 @@ +public final class WhenStringLiteralKt { + @org.jetbrains.annotations.Nullable private static final var a: java.lang.String = readLine() + @null private static final var b: int = switch (a) { + "abc" -> { + 1 + break + } + + "def", "ghi" -> { + 2 + break + } + + -> { + 3 + break + } + + } + + public static final fun getA() : java.lang.String = UastEmptyExpression + public static final fun getB() : int = UastEmptyExpression + public static final fun () : void { + "abc1" + "def1" + } +}