diff --git a/plugins/lint/lint-checks/src/com/android/tools/klint/checks/CipherGetInstanceDetector.java b/plugins/lint/lint-checks/src/com/android/tools/klint/checks/CipherGetInstanceDetector.java index 39292c629da..d6ada1679a3 100644 --- a/plugins/lint/lint-checks/src/com/android/tools/klint/checks/CipherGetInstanceDetector.java +++ b/plugins/lint/lint-checks/src/com/android/tools/klint/checks/CipherGetInstanceDetector.java @@ -82,7 +82,7 @@ public class CipherGetInstanceDetector extends Detector implements UastScanner { UExpression expression = argumentList.get(0); if (expression instanceof ULiteralExpression) { ULiteralExpression argument = (ULiteralExpression)expression; - String parameter = argument.asString(); + String parameter = argument.renderString(); checkParameter(context, node, argument, parameter, false); } else if (expression instanceof UResolvable) { UDeclaration declaration = ((UResolvable)expression).resolve(context); diff --git a/plugins/lint/lint-checks/src/com/android/tools/klint/checks/JavaPerformanceDetector.java b/plugins/lint/lint-checks/src/com/android/tools/klint/checks/JavaPerformanceDetector.java index c73272d135e..b4eadc7f8f3 100644 --- a/plugins/lint/lint-checks/src/com/android/tools/klint/checks/JavaPerformanceDetector.java +++ b/plugins/lint/lint-checks/src/com/android/tools/klint/checks/JavaPerformanceDetector.java @@ -211,16 +211,22 @@ public class JavaPerformanceDetector extends Detector implements UastScanner { } if (mCheckValueOf) { + UType type = UastErrorType.INSTANCE; if (typeName == null) { - typeName = classReference.getIdentifier(); + UDeclaration resolvedDeclaration = classReference.resolve(mContext); + if (resolvedDeclaration instanceof UClass) { + type = ((UClass) resolvedDeclaration).getDefaultType(); + typeName = type.getName(); + } } - if ((typeName.equals(INTEGER) - || typeName.equals(BOOLEAN) - || typeName.equals(FLOAT) - || typeName.equals(CHARACTER) - || typeName.equals(LONG) - || typeName.equals(DOUBLE) - || typeName.equals(BYTE)) + if ((type.isInt() + || type.isBoolean() + || type.isFloat() + || type.isChar() + || type.isLong() + || type.isDouble() + || type.isShort() + || type.isByte()) && node.getValueArgumentCount() == 1) { String argument = node.getValueArguments().get(0).renderString(); mContext.report(USE_VALUE_OF, node, mContext.getLocation(node), getUseValueOfErrorMessage( diff --git a/plugins/uast-common/src/org/jetbrains/uast/declarations/UDeclaration.kt b/plugins/uast-common/src/org/jetbrains/uast/declarations/UDeclaration.kt index 31f8a295bde..d4d86c88a43 100644 --- a/plugins/uast-common/src/org/jetbrains/uast/declarations/UDeclaration.kt +++ b/plugins/uast-common/src/org/jetbrains/uast/declarations/UDeclaration.kt @@ -37,7 +37,7 @@ interface UDeclaration : UElement, UNamed { */ open fun matchesNameWithContaining(containingClassFqName: String, name: String): Boolean { if (!matchesName(name)) return false - val containingClass = parent as? UClass ?: return false + val containingClass = this.getContainingClass() ?: return false return containingClass.matchesFqName(containingClassFqName) } diff --git a/plugins/uast-common/src/org/jetbrains/uast/expressions/ULiteralExpression.kt b/plugins/uast-common/src/org/jetbrains/uast/expressions/ULiteralExpression.kt index 8e4f5048005..e0f59b99054 100644 --- a/plugins/uast-common/src/org/jetbrains/uast/expressions/ULiteralExpression.kt +++ b/plugins/uast-common/src/org/jetbrains/uast/expressions/ULiteralExpression.kt @@ -30,7 +30,8 @@ interface ULiteralExpression : UExpression { /** * Returns true if the literal is a `null`-literal, false otherwise. */ - val isNull: Boolean + open val isNull: Boolean + get() = value == null /** * Returns true if the literal is a [String] literal, false otherwise. @@ -44,24 +45,23 @@ interface ULiteralExpression : UExpression { val isBoolean: Boolean get() = evaluate() is Boolean - /** - * Returns the string representation of the literal expression. - * - * @return the string representation, or "null" if the literal is a "null"-literal. - */ - fun asString(): String { - val value = value - return if (value == null) - "null" - else - value.toString() - } - override fun accept(visitor: UastVisitor) { visitor.visitLiteralExpression(this) visitor.afterVisitLiteralExpression(this) } - override fun logString() = "ULiteralExpression (${asString()})" - override fun renderString() = if (value is String) "\"$value\"" else asString() + override fun renderString(): String { + val value = value + return when (value) { + null -> "null" + is Char -> "'$value'" + is String -> '"' + value.replace("\\", "\\\\") + .replace("\r", "\\r").replace("\n", "\\n") + .replace("\t", "\\t").replace("\b", "\\b") + .replace("\"", "\\\"") + '"' + else -> value.toString() + } + } + + override fun logString() = "ULiteralExpression (${renderString()})" } diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/declarations/JavaUVariable.kt b/plugins/uast-java/src/org/jetbrains/uast/java/declarations/JavaUVariable.kt index 6ade3016d25..e3b2035e8f5 100644 --- a/plugins/uast-java/src/org/jetbrains/uast/java/declarations/JavaUVariable.kt +++ b/plugins/uast-java/src/org/jetbrains/uast/java/declarations/JavaUVariable.kt @@ -16,6 +16,7 @@ package org.jetbrains.uast.java import com.intellij.psi.PsiField +import com.intellij.psi.PsiLocalVariable import com.intellij.psi.PsiVariable import org.jetbrains.uast.* import org.jetbrains.uast.psi.PsiElementBacked @@ -34,6 +35,7 @@ class JavaUVariable( override val kind = when (psi) { is PsiField -> UastVariableKind.MEMBER + is PsiLocalVariable -> UastVariableKind.LOCAL_VARIABLE else -> UastVariableKind.LOCAL_VARIABLE } diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaULiteralExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaULiteralExpression.kt index f96679fdca2..69b832b8372 100644 --- a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaULiteralExpression.kt +++ b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaULiteralExpression.kt @@ -15,7 +15,6 @@ */ package org.jetbrains.uast.java -import com.intellij.psi.PsiKeyword import com.intellij.psi.PsiLiteralExpression import org.jetbrains.uast.UElement import org.jetbrains.uast.ULiteralExpression @@ -25,10 +24,6 @@ class JavaULiteralExpression( override val psi: PsiLiteralExpression, override val parent: UElement ) : JavaAbstractUElement(), ULiteralExpression, PsiElementBacked, JavaUElementWithType { - override fun asString() = psi.text override fun evaluate() = psi.value override val value by lz { evaluate() } - - override val isNull: Boolean - get() = asString() == PsiKeyword.NULL } \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUPostfixExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUPostfixExpression.kt index dca782c2e76..0d16a1f5684 100644 --- a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUPostfixExpression.kt +++ b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUPostfixExpression.kt @@ -28,7 +28,7 @@ class JavaUPostfixExpression( ) : JavaAbstractUElement(), UPostfixExpression, PsiElementBacked, JavaUElementWithType, JavaEvaluatableUElement { override val operand by lz { JavaConverter.convertOrEmpty(psi.operand, this) } - override val operator = when (psi.operationSign) { + override val operator = when (psi.operationTokenType) { JavaTokenType.PLUSPLUS -> UastPostfixOperator.INC JavaTokenType.MINUSMINUS -> UastPostfixOperator.DEC else -> UastPostfixOperator.UNKNOWN diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUPrefixExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUPrefixExpression.kt index d9831ab5f58..475f36e0687 100644 --- a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUPrefixExpression.kt +++ b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUPrefixExpression.kt @@ -28,7 +28,7 @@ class JavaUPrefixExpression( ) : JavaAbstractUElement(), UPrefixExpression, PsiElementBacked, JavaUElementWithType, JavaEvaluatableUElement { override val operand by lz { JavaConverter.convertOrEmpty(psi.operand, this) } - override val operator = when (psi.operationSign) { + override val operator = when (psi.operationTokenType) { JavaTokenType.PLUS -> UastPrefixOperator.UNARY_PLUS JavaTokenType.MINUS -> UastPrefixOperator.UNARY_MINUS JavaTokenType.PLUSPLUS -> UastPrefixOperator.INC diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/internal/javaInternalUastUtils.kt b/plugins/uast-java/src/org/jetbrains/uast/java/internal/javaInternalUastUtils.kt index 8a35f8f9624..182b087ecd5 100644 --- a/plugins/uast-java/src/org/jetbrains/uast/java/internal/javaInternalUastUtils.kt +++ b/plugins/uast-java/src/org/jetbrains/uast/java/internal/javaInternalUastUtils.kt @@ -52,6 +52,7 @@ internal fun PsiModifierListOwner.getVisibility(): UastVisibility { if (hasModifierProperty(PsiModifier.PUBLIC)) return UastVisibility.PUBLIC if (hasModifierProperty(PsiModifier.PROTECTED)) return UastVisibility.PROTECTED if (hasModifierProperty(PsiModifier.PRIVATE)) return UastVisibility.PRIVATE + if (this is PsiLocalVariable) return UastVisibility.LOCAL return JavaUastVisibilities.PACKAGE_LOCAL } diff --git a/plugins/uast-java/testData/log/ControlStructures.txt b/plugins/uast-java/testData/log/ControlStructures.txt index d0457ed6aed..fb953e9b5de 100644 --- a/plugins/uast-java/testData/log/ControlStructures.txt +++ b/plugins/uast-java/testData/log/ControlStructures.txt @@ -1,4 +1,4 @@ -UFile (package = null) +UFile (package = ) UClass (_Dummy_, kind = class) UClass (ControlStructures, kind = class) UFunction (main, kind = function, paramCount = 1) @@ -10,8 +10,8 @@ UFile (package = null) USimpleReferenceExpression (length) ULiteralExpression (0) UBlockExpression - USpecialExpressionList (return) - + UReturnExpression + EmptyExpression UDeclarationsExpression UVariable (mode, kind = local) @@ -23,7 +23,9 @@ UFile (package = null) ULiteralExpression (1) ULiteralExpression ("singleArg") ULiteralExpression ("multiArgs") - UForEachExpression (arg) + UForEachExpression + UVariable (arg, kind = parameter) + USimpleReferenceExpression (args) UBlockExpression UQualifiedExpression @@ -79,7 +81,7 @@ UFile (package = null) USimpleReferenceExpression (i) UPostfixExpression (++) USimpleReferenceExpression (i) - UAssignmentExpression (=) + UBinaryExpression (=) USimpleReferenceExpression (i) ULiteralExpression (0) UDoWhileExpression @@ -96,6 +98,6 @@ UFile (package = null) UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) USimpleReferenceExpression (println) USimpleReferenceExpression (i) - UAssignmentExpression (+=) + UBinaryExpression (+=) USimpleReferenceExpression (i) ULiteralExpression (1) \ No newline at end of file diff --git a/plugins/uast-java/testData/log/Lambda.txt b/plugins/uast-java/testData/log/Lambda.txt index de7e743deda..7c3f559375b 100644 --- a/plugins/uast-java/testData/log/Lambda.txt +++ b/plugins/uast-java/testData/log/Lambda.txt @@ -1,4 +1,4 @@ -UFile (package = null) +UFile (package = ) UClass (_Dummy_, kind = class) UClass (Lambda, kind = class) UFunction (example, kind = function, paramCount = 0) @@ -27,4 +27,4 @@ UFile (package = null) USimpleReferenceExpression (arg) UClass (Job, kind = interface) UFunction (doJob, kind = function, paramCount = 1) - EmptyExpression \ No newline at end of file + \ No newline at end of file diff --git a/plugins/uast-java/testData/log/NestedClasses.txt b/plugins/uast-java/testData/log/NestedClasses.txt index 574500d9846..f2d81407599 100644 --- a/plugins/uast-java/testData/log/NestedClasses.txt +++ b/plugins/uast-java/testData/log/NestedClasses.txt @@ -1,4 +1,4 @@ -UFile (package = null) +UFile (package = ) UClass (_Dummy_, kind = class) UClass (NestedClasses, kind = class) UClass (Nested, kind = class) diff --git a/plugins/uast-java/testData/log/Simple.txt b/plugins/uast-java/testData/log/Simple.txt index a1a9d98476a..d9aac36dfbf 100644 --- a/plugins/uast-java/testData/log/Simple.txt +++ b/plugins/uast-java/testData/log/Simple.txt @@ -1,22 +1,22 @@ -UFile (package = null) +UFile (package = ) UClass (_Dummy_, kind = class) UClass (Simple, kind = class) UVariable (name, kind = member) EmptyExpression - UFunction (, kind = CONSTRUCTOR, paramCount = 1) + UFunction (, kind = constructor, paramCount = 1) UBlockExpression - UAssignmentExpression (=) + UBinaryExpression (=) UQualifiedExpression UThisExpression USimpleReferenceExpression (name) USimpleReferenceExpression (name) UFunction (getName, kind = function, paramCount = 0) UBlockExpression - USpecialExpressionList (return) + UReturnExpression USimpleReferenceExpression (name) UFunction (setName, kind = function, paramCount = 1) UBlockExpression - UAssignmentExpression (=) + UBinaryExpression (=) UQualifiedExpression UThisExpression USimpleReferenceExpression (name) diff --git a/plugins/uast-java/testData/log/SpecialExpressions.txt b/plugins/uast-java/testData/log/SpecialExpressions.txt index 6b9bc5154ec..230c9f77066 100644 --- a/plugins/uast-java/testData/log/SpecialExpressions.txt +++ b/plugins/uast-java/testData/log/SpecialExpressions.txt @@ -1,28 +1,27 @@ -UFile (package = null) +UFile (package = ) UClass (_Dummy_, kind = class) UClass (SpecialExpressions, kind = class) UFunction (test, kind = function, paramCount = 0) UBlockExpression - USpecialExpressionList (assert) + UFunctionCallExpression (UastCallKind(name='assert'), argCount = 1) + UBinaryExpression (>) ULiteralExpression (5) ULiteralExpression (3) - EmptyExpression - USpecialExpressionList (assert) + UFunctionCallExpression (UastCallKind(name='assert'), argCount = 2) + UBinaryExpression (>) ULiteralExpression (5) ULiteralExpression (3) ULiteralExpression ("Message") - USpecialExpressionList (synchronized) - UThisExpression - UBlockExpression + UBlockExpression + UQualifiedExpression UQualifiedExpression - UQualifiedExpression - USimpleReferenceExpression (System) - USimpleReferenceExpression (out) - UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) - USimpleReferenceExpression (println) - ULiteralExpression ("A") + USimpleReferenceExpression (System) + USimpleReferenceExpression (out) + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) + USimpleReferenceExpression (println) + ULiteralExpression ("A") UDeclarationsExpression UVariable (a, kind = local) ULiteralExpression (5) @@ -40,8 +39,7 @@ UFile (package = null) USimpleReferenceExpression (a) ULiteralExpression (3) UBlockExpression - USpecialExpressionList (break) - + UBreakExpression () EmptyExpression UIfExpression UBinaryExpression (===) @@ -50,8 +48,7 @@ UFile (package = null) ULiteralExpression (5) ULiteralExpression (0) UBlockExpression - USpecialExpressionList (continue) - + UContinueExpression () EmptyExpression UPostfixExpression (--) USimpleReferenceExpression (a) @@ -71,26 +68,25 @@ UFile (package = null) USwitchExpression USimpleReferenceExpression (a) UBlockExpression - UExpressionSwitchClauseExpression + USwitchClauseExpression ULiteralExpression (1) UBlockExpression - UAssignmentExpression (=) + UBinaryExpression (=) USimpleReferenceExpression (x) ULiteralExpression ("1") - USpecialExpressionList (break) - - UExpressionSwitchClauseExpression + UBreakExpression () + USwitchClauseExpression ULiteralExpression (3) - UAssignmentExpression (=) + UBinaryExpression (=) USimpleReferenceExpression (x) ULiteralExpression ("3") - UExpressionSwitchClauseExpression + USwitchClauseExpression ULiteralExpression (4) - UAssignmentExpression (=) + UBinaryExpression (=) USimpleReferenceExpression (x) ULiteralExpression ("4") - UDefaultSwitchClause - UAssignmentExpression (=) + DefaultUSwitchClauseExpression + UBinaryExpression (=) USimpleReferenceExpression (x) ULiteralExpression ("") UIfExpression @@ -105,7 +101,7 @@ UFile (package = null) USimpleReferenceExpression (equals) ULiteralExpression ("1") UBlockExpression - USpecialExpressionList (throw) + UThrowExpression UFunctionCallExpression (UastCallKind(name='constructor_call'), argCount = 1) ULiteralExpression ("Err") @@ -119,12 +115,12 @@ UFile (package = null) ULiteralExpression (1000) UCatchClause UBlockExpression UBlockExpression - UAssignmentExpression (=) + UBinaryExpression (=) USimpleReferenceExpression (a) ULiteralExpression (3) UBlockExpression - UAssignmentExpression (=) + UBinaryExpression (=) USimpleReferenceExpression (a) ULiteralExpression (5) - USpecialExpressionList (return) + UReturnExpression ULiteralExpression (true) \ No newline at end of file diff --git a/plugins/uast-java/testData/render/ControlStructures.txt b/plugins/uast-java/testData/render/ControlStructures.txt index 6d92c6d44a8..080655f6e4b 100644 --- a/plugins/uast-java/testData/render/ControlStructures.txt +++ b/plugins/uast-java/testData/render/ControlStructures.txt @@ -1,20 +1,20 @@ -default class _Dummy_ { - default class ControlStructures { - public fun main(args: String[]): void { +package_local class _Dummy_ { + package_local class ControlStructures { + public static fun main(args: String[]): void { if (args.length === 0) { return } - var mode: String = (args.length === 1) ? ("singleArg") : ("multiArgs") + local var mode: String = (args.length === 1) ? ("singleArg") : ("multiArgs") for (arg : args) { System.out.println(arg) } - for (var i: int = 0; i < args.length; ++i) { + for (local var i: int = 0; i < args.length; ++i) { System.out.println(i + ": " + args[i]) } - var i: int = 0 + local var i: int = 0 while (i < args.length) { System.out.println("Index " + i) i++ @@ -28,6 +28,5 @@ default class _Dummy_ { while (i < args.length) } - } } \ No newline at end of file diff --git a/plugins/uast-java/testData/render/Lambda.txt b/plugins/uast-java/testData/render/Lambda.txt index f3a04eb828a..6fc9bc93231 100644 --- a/plugins/uast-java/testData/render/Lambda.txt +++ b/plugins/uast-java/testData/render/Lambda.txt @@ -1,17 +1,17 @@ -default class _Dummy_ { - default class Lambda { - default fun example(): void { +package_local class _Dummy_ { + package_local class Lambda { + package_local fun example(): void { doJob({ arg: String -> arg + arg }, "Mary") } - default fun doJob(job: Job, arg: String): void { + package_local fun doJob(job: Job, arg: String): void { System.out.println(job.doJob(arg)) } - } - default abstract static interface Job { - public fun doJob(arg: String): String = EmptyExpression + + package_local abstract static interface Job { + public abstract fun doJob(arg: String): String } } \ No newline at end of file diff --git a/plugins/uast-java/testData/render/NestedClasses.txt b/plugins/uast-java/testData/render/NestedClasses.txt index 3a661e459ea..8384242f9bd 100644 --- a/plugins/uast-java/testData/render/NestedClasses.txt +++ b/plugins/uast-java/testData/render/NestedClasses.txt @@ -1,14 +1,13 @@ -default class _Dummy_ { - default class NestedClasses { +package_local class _Dummy_ { + package_local class NestedClasses { public static class Nested { - default fun func1(): void { + package_local fun func1(): void { } - } - public class Inner { - default fun func2(): void { - } + public class Inner { + package_local fun func2(): void { + } } } } \ No newline at end of file diff --git a/plugins/uast-java/testData/render/Simple.txt b/plugins/uast-java/testData/render/Simple.txt index ac9d4914508..a9bb5931765 100644 --- a/plugins/uast-java/testData/render/Simple.txt +++ b/plugins/uast-java/testData/render/Simple.txt @@ -1,6 +1,6 @@ -default class _Dummy_ { - default class Simple { - var name: String +package_local class _Dummy_ { + package_local class Simple { + private var name: String public fun (name: String) { this.name = name @@ -13,6 +13,5 @@ default class _Dummy_ { public fun setName(name: String): void { this.name = name } - } } \ No newline at end of file diff --git a/plugins/uast-java/testData/render/SpecialExpressions.txt b/plugins/uast-java/testData/render/SpecialExpressions.txt index fd66784c6cf..d7f37e021e4 100644 --- a/plugins/uast-java/testData/render/SpecialExpressions.txt +++ b/plugins/uast-java/testData/render/SpecialExpressions.txt @@ -1,15 +1,15 @@ -default class _Dummy_ { - default class SpecialExpressions { - default fun test(): boolean { - assert 5 > 3 : EmptyExpression - assert 5 > 3 : "Message" - synchronized this : { +package_local class _Dummy_ { + package_local class SpecialExpressions { + package_local fun test(): boolean { + (5 > 3) + (5 > 3, "Message") + { System.out.println("A") } - var a: int = 5 - var b: int = 7 - var c: int + local var a: int = 5 + local var b: int = 7 + local var c: int while (a > 0) { if (a === 3) { break @@ -24,7 +24,7 @@ default class _Dummy_ { this.test() super.hashCode() - var x: String + local var x: String switch (a) { 1 -> @@ -49,20 +49,16 @@ default class _Dummy_ { try { Thread.sleep(1000) } - catch (e) { } - finally { a = 3 } - { a = 5 } return true } - } } \ No newline at end of file diff --git a/plugins/uast-kotlin/src/org/jetbrains/kotlin/uast/KotlinUastLanguagePlugin.kt b/plugins/uast-kotlin/src/org/jetbrains/kotlin/uast/KotlinUastLanguagePlugin.kt index af68ba79ecc..5f632ef2c44 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/kotlin/uast/KotlinUastLanguagePlugin.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/kotlin/uast/KotlinUastLanguagePlugin.kt @@ -117,7 +117,7 @@ internal object KotlinConverter : UastConverter { is KtStringTemplateExpression -> { if (expression.entries.isEmpty()) - KotlinStringULiteralExpression(expression, parent) + KotlinStringULiteralExpression(expression, parent, "") else if (expression.entries.size == 1) convert(expression.entries[0], parent) else diff --git a/plugins/uast-kotlin/src/org/jetbrains/kotlin/uast/expressions/KotlinULiteralExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/kotlin/uast/expressions/KotlinULiteralExpression.kt index 2661dc1a65f..0dd7647565d 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/kotlin/uast/expressions/KotlinULiteralExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/kotlin/uast/expressions/KotlinULiteralExpression.kt @@ -39,8 +39,6 @@ class KotlinStringULiteralExpression( override val parent: UElement, val text: String? = null ) : KotlinAbstractUElement(), ULiteralExpression, PsiElementBacked, KotlinUElementWithType{ - override val isNull = false - override val value: String get() = text ?: StringUtil.unescapeStringCharacters(psi.text) diff --git a/plugins/uast-kotlin/src/org/jetbrains/kotlin/uast/extensions/PropertyAsCallAndroidUastVisitorExtension.kt b/plugins/uast-kotlin/src/org/jetbrains/kotlin/uast/extensions/PropertyAsCallAndroidUastVisitorExtension.kt index b69f524e2dc..da912aff55a 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/kotlin/uast/extensions/PropertyAsCallAndroidUastVisitorExtension.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/kotlin/uast/extensions/PropertyAsCallAndroidUastVisitorExtension.kt @@ -47,7 +47,7 @@ class PropertyAsCallAndroidUastVisitorExtension : UastVisitorExtension { else null - val callExpression: UCallExpression = object : UCallExpression, PsiElementBacked, SynthetizedUElement { + val callExpression: UCallExpression = object : UCallExpression, PsiElementBacked, SynthesizedUElement { override val parent = element.parent override val psi = ktElement diff --git a/plugins/uast-kotlin/src/org/jetbrains/kotlin/uast/internal/kotlinInternalUastUtils.kt b/plugins/uast-kotlin/src/org/jetbrains/kotlin/uast/internal/kotlinInternalUastUtils.kt index 470f9a679bc..4d5c5e09318 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/kotlin/uast/internal/kotlinInternalUastUtils.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/kotlin/uast/internal/kotlinInternalUastUtils.kt @@ -49,7 +49,8 @@ internal fun KtModifierListOwner.hasModifier(modifier: UastModifier): Boolean { if (this is KtClassOrObject && !hasModifier(KtTokens.INNER_KEYWORD)) { return true } - if (this is KtDeclaration && parent is KtObjectDeclaration) { + if (this is KtDeclaration && (parent is KtObjectDeclaration || + parent is KtClassBody && parent?.parent is KtObjectDeclaration)) { return true } return false diff --git a/plugins/uast-kotlin/test/org.jetbrains.kotlin.uast/AbstractKotlinUastStructureTest.kt b/plugins/uast-kotlin/test/org.jetbrains.kotlin.uast/AbstractKotlinUastStructureTest.kt index fcaf48d68aa..4d5eb303d5c 100644 --- a/plugins/uast-kotlin/test/org.jetbrains.kotlin.uast/AbstractKotlinUastStructureTest.kt +++ b/plugins/uast-kotlin/test/org.jetbrains.kotlin.uast/AbstractKotlinUastStructureTest.kt @@ -51,17 +51,17 @@ abstract class AbstractKotlinUastStructureTest : KotlinLightCodeInsightFixtureTe private fun genTree(node: UElement): String { val builder = StringBuilder() val visitor = object : AbstractUastVisitor() { - private tailrec fun getParentCount(node: UElement): Int { - val parent = node.parent ?: return 0 - return getParentCount(parent) + private tailrec fun height(node: UElement, current: Int): Int { + val parent = node.parent ?: return current + return height(parent, current + 1) } override fun visitElement(node: UElement): Boolean { - builder.appendln(" ".repeat(getParentCount(node)) + node.javaClass.name) + builder.appendln(" ".repeat(height(node, 0)) + node.javaClass.simpleName) return super.visitElement(node) } } - visitor.visitElement(node) + node.accept(visitor) return builder.toString() } diff --git a/plugins/uast-kotlin/testData/ControlStructures.kt b/plugins/uast-kotlin/testData/ControlStructures.kt index c460d37cdcb..532628120ad 100644 --- a/plugins/uast-kotlin/testData/ControlStructures.kt +++ b/plugins/uast-kotlin/testData/ControlStructures.kt @@ -4,104 +4,117 @@ class ControlStructures { fun nullFun(): String? = null fun test(): Boolean { - "" -// " " -// "Z Z" -// -// val qwe = 2 -// " $qwe " -// "5\n 2" -// "\t\t\t" + " " + "Z" + "Z Z" -// if (5 > 3) { -// println("5 > 3") -// } -// -// for (c in "ABC") { -// println(c) -// } -// -// for (c: Char in "DEF") { -// println(c.toByte()) -// } -// -// var i = 5 -// while (i > 0) { -// i-- -// if (i == 3) break -// if (i == 2) { -// continue -// } -// } -// -// "" is String -// ("" as Any) as String? -// -// super.equals(this) -// this.equals(this) -// -// this@ControlStructures.equals(this) -// -// ControlStructures::test -// ControlStructures::prop -// ControlStructures::class.java -// -// outer@ for (outerVal in 1..2) { -// inner@ for (innerVal in 3..4) { -// continue@outer -// } -// break@outer -// } -// -// nullFun()?.let { println(it) } -// -// i = 5 -// do { -// i -= 1 -// } while (i > 0) -// -// "ABC".forEach { println(it.toString()[0]) } -// -// "ABC".zip("DEF").forEach { println(it.first + " " + it.second) } -// -// val arr = arrayOf("A", "B", "C") -// println(arr[2]) -// -// val (a, b) = "ABC".zip("DEF") -// -// val value = if (5 > 3) "a" else "b" -// val list = listOf("A") -// val list2 = listOf("A") -// -// val type = when (value) { -// in list -> "inlist" -// !in list2 -> "notinlist2" -// is String -> "string" -// is CharSequence -> "cs" -// else -> "unknown" -// } -// -// val x = when { -// value == "b" -> "B" -// 5 % 2 == 0 -> { -// println("A") -// "Q" -// } -// false -> "!" -// else -> "A" -// } -// -// try { -// 5 + 1 -// throw Exception() -// } catch (e: Exception) { -// e.printStackTrace() -// } catch (thr: Throwable) { -// System.out.println("error!") -// } finally { -// System.out.println("finally") -// } -// -// return false + 'c' + 5 + 5.0 + 5.0f + -5 + +5 + 0.0 + -0.0 + 1E10 + 1E-10 + + val qwe = 2 + " $qwe " + "a\"b" + "a'b\r\n" + "5\n 2" + "\t\t\t" + + if (5 > 3) { + println("5 > 3") + } + + for (c in "ABC") { + println(c) + } + + for (c: Char in "DEF") { + println(c.toByte()) + } + + var i = 5 + while (i > 0) { + i-- + if (i == 3) break + if (i == 2) { + continue + } + } + + "" is String + ("" as Any) as String? + + super.equals(this) + this.equals(this) + + this@ControlStructures.equals(this) + + ControlStructures::test + ControlStructures::prop + ControlStructures::class.java + + outer@ for (outerVal in 1..2) { + inner@ for (innerVal in 3..4) { + continue@outer + } + break@outer + } + + nullFun()?.let { println(it) } + + i = 5 + do { + i -= 1 + } while (i > 0) + + "ABC".forEach { println(it.toString()[0]) } + + "ABC".zip("DEF").forEach { println(it.first + " " + it.second) } + + val arr = arrayOf("A", "B", "C") + println(arr[2]) + + val (a, b) = "ABC".zip("DEF") + + val value = if (5 > 3) "a" else "b" + val list = listOf("A") + val list2 = listOf("A") + + val type = when (value) { + in list -> "inlist" + !in list2 -> "notinlist2" + is String -> "string" + is CharSequence -> "cs" + else -> "unknown" + } + + val x = when { + value == "b" -> "B" + 5 % 2 == 0 -> { + println("A") + "Q" + } + false -> "!" + else -> "A" + } + + try { + 5 + 1 + throw Exception() + } catch (e: Exception) { + e.printStackTrace() + } catch (thr: Throwable) { + System.out.println("error!") + } finally { + System.out.println("finally") + } + + return false } } \ No newline at end of file diff --git a/plugins/uast-kotlin/testData/log/ControlStructures.txt b/plugins/uast-kotlin/testData/log/ControlStructures.txt index 456fde57d90..a66eed0aae2 100644 --- a/plugins/uast-kotlin/testData/log/ControlStructures.txt +++ b/plugins/uast-kotlin/testData/log/ControlStructures.txt @@ -1,9 +1,57 @@ -UFile (package = null) +UFile (package = ) UClass (ControlStructures, kind = class) - UFunction (, kind = CONSTRUCTOR, paramCount = 0) - EmptyExpression + UFunction (, kind = constructor, paramCount = 0) + + UVariable (prop, kind = member) + ULiteralExpression (3) + UFunction (nullFun, kind = function, paramCount = 0) + ULiteralExpression (null) UFunction (test, kind = function, paramCount = 0) UBlockExpression + ULiteralExpression (" ") + ULiteralExpression ("Z") + ULiteralExpression ("Z Z") + ULiteralExpression ('c') + ULiteralExpression (5) + ULiteralExpression (5.0) + ULiteralExpression (5.0) + UPrefixExpression (-) + ULiteralExpression (5) + UPrefixExpression (+) + ULiteralExpression (5) + ULiteralExpression (0.0) + UPrefixExpression (-) + ULiteralExpression (0.0) + ULiteralExpression (1.0E10) + ULiteralExpression (1.0E-10) + UDeclarationsExpression + UVariable (qwe, kind = local) + ULiteralExpression (2) + UBinaryExpression (+) + UBinaryExpression (+) + ULiteralExpression (" ") + USimpleReferenceExpression (qwe) + ULiteralExpression (" ") + UBinaryExpression (+) + UBinaryExpression (+) + ULiteralExpression ("a") + ULiteralExpression ("\"") + ULiteralExpression ("b") + UBinaryExpression (+) + UBinaryExpression (+) + ULiteralExpression ("a'b") + ULiteralExpression ("\r") + ULiteralExpression ("\n") + UBinaryExpression (+) + UBinaryExpression (+) + ULiteralExpression ("5") + ULiteralExpression ("\n") + ULiteralExpression (" 2") + UBinaryExpression (+) + UBinaryExpression (+) + ULiteralExpression ("\t") + ULiteralExpression ("\t") + ULiteralExpression ("\t") UIfExpression UBinaryExpression (>) ULiteralExpression (5) @@ -13,13 +61,17 @@ UFile (package = null) USimpleReferenceExpression (println) ULiteralExpression ("5 > 3") - UForEachExpression (c) + UForEachExpression + UVariable (c, kind = parameter) + ULiteralExpression ("ABC") UBlockExpression UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) USimpleReferenceExpression (println) USimpleReferenceExpression (c) - UForEachExpression (c) + UForEachExpression + UVariable (c, kind = parameter) + ULiteralExpression ("DEF") UBlockExpression UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) @@ -43,17 +95,71 @@ UFile (package = null) UBinaryExpression (==) USimpleReferenceExpression (i) ULiteralExpression (3) - USpecialExpressionList (break) - + UBreakExpression () UIfExpression UBinaryExpression (==) USimpleReferenceExpression (i) ULiteralExpression (2) UBlockExpression - USpecialExpressionList (continue) - + UContinueExpression () + UBinaryExpressionWithType (null, !is) + ULiteralExpression ("") + UBinaryExpressionWithType (null, as) + UParenthesizedExpression + UBinaryExpressionWithType (null, as) + ULiteralExpression ("") + UQualifiedExpression + USuperExpression + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) + USimpleReferenceExpression (equals) + UThisExpression + UQualifiedExpression + UThisExpression + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) + USimpleReferenceExpression (equals) + UThisExpression + UQualifiedExpression + UThisExpression + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) + USimpleReferenceExpression (equals) + UThisExpression + UCallableReferenceExpression + UCallableReferenceExpression + UQualifiedExpression + UClassLiteralExpression + USimpleReferenceExpression (java) + ULabeledExpression (outer) + UForEachExpression + UVariable (outerVal, kind = parameter) + + UBinaryExpression (..) + ULiteralExpression (1) + ULiteralExpression (2) + UBlockExpression + ULabeledExpression (inner) + UForEachExpression + UVariable (innerVal, kind = parameter) + + UBinaryExpression (..) + ULiteralExpression (3) + ULiteralExpression (4) + UBlockExpression + UContinueExpression (outer) + UBreakExpression (outer) + UQualifiedExpression + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 0) + USimpleReferenceExpression (nullFun) + + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) + USimpleReferenceExpression (let) + ULambdaExpression + + UBlockExpression + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) + USimpleReferenceExpression (println) + USimpleReferenceExpression (it) UBinaryExpression (=) USimpleReferenceExpression (i) ULiteralExpression (5) @@ -103,6 +209,18 @@ UFile (package = null) UQualifiedExpression USimpleReferenceExpression (it) USimpleReferenceExpression (second) + UDeclarationsExpression + UVariable (arr, kind = local) + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 3) + USimpleReferenceExpression (arrayOf) + ULiteralExpression ("A") + ULiteralExpression ("B") + ULiteralExpression ("C") + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) + USimpleReferenceExpression (println) + UArrayAccessExpression + USimpleReferenceExpression (arr) + ULiteralExpression (2) UDeclarationsExpression UVariable (var1496943053, kind = local) UQualifiedExpression @@ -145,58 +263,101 @@ UFile (package = null) USwitchExpression USimpleReferenceExpression (value) USpecialExpressionList (when) - KotlinUSwitchEntry + USwitchClauseExpressionWithBody + UBinaryExpression (in) + USimpleReferenceExpression (it) + USimpleReferenceExpression (list) USpecialExpressionList (when_entry) ULiteralExpression ("inlist") - USpecialExpressionList (break) - - KotlinUSwitchEntry + UBreakExpression () + USwitchClauseExpressionWithBody + UBinaryExpression (in) + USimpleReferenceExpression (it) + USimpleReferenceExpression (list2) USpecialExpressionList (when_entry) ULiteralExpression ("notinlist2") - USpecialExpressionList (break) - - KotlinUSwitchEntry + UBreakExpression () + USwitchClauseExpressionWithBody + UBinaryExpressionWithType (null, is) + USimpleReferenceExpression (it) USpecialExpressionList (when_entry) ULiteralExpression ("string") - USpecialExpressionList (break) - - KotlinUSwitchEntry + UBreakExpression () + USwitchClauseExpressionWithBody + UBinaryExpressionWithType (null, is) + USimpleReferenceExpression (it) USpecialExpressionList (when_entry) ULiteralExpression ("cs") - USpecialExpressionList (break) + UBreakExpression () + USwitchClauseExpressionWithBody - KotlinUSwitchEntry USpecialExpressionList (when_entry) ULiteralExpression ("unknown") - USpecialExpressionList (break) - + UBreakExpression () UDeclarationsExpression UVariable (x, kind = local) USwitchExpression USpecialExpressionList (when) - KotlinUSwitchEntry + USwitchClauseExpressionWithBody + UBinaryExpression (==) + USimpleReferenceExpression (value) + ULiteralExpression ("b") USpecialExpressionList (when_entry) ULiteralExpression ("B") - USpecialExpressionList (break) - - KotlinUSwitchEntry + UBreakExpression () + USwitchClauseExpressionWithBody + UBinaryExpression (==) + UBinaryExpression (%) + ULiteralExpression (5) + ULiteralExpression (2) + ULiteralExpression (0) USpecialExpressionList (when_entry) UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) USimpleReferenceExpression (println) ULiteralExpression ("A") ULiteralExpression ("Q") - USpecialExpressionList (break) - - KotlinUSwitchEntry + UBreakExpression () + USwitchClauseExpressionWithBody + ULiteralExpression (false) USpecialExpressionList (when_entry) ULiteralExpression ("!") - USpecialExpressionList (break) + UBreakExpression () + USwitchClauseExpressionWithBody - KotlinUSwitchEntry USpecialExpressionList (when_entry) ULiteralExpression ("A") - USpecialExpressionList (break) + UBreakExpression () + UTryExpression + UBlockExpression + UBinaryExpression (+) + ULiteralExpression (5) + ULiteralExpression (1) + UThrowExpression + UFunctionCallExpression (UastCallKind(name='constructor_call'), argCount = 0) + USimpleReferenceExpression (Exception) + UCatchClause + UBlockExpression + UQualifiedExpression + USimpleReferenceExpression (e) + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 0) + USimpleReferenceExpression (printStackTrace) - USpecialExpressionList (return) + UCatchClause + UBlockExpression + UQualifiedExpression + UQualifiedExpression + USimpleReferenceExpression (System) + USimpleReferenceExpression (out) + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) + USimpleReferenceExpression (println) + ULiteralExpression ("error!") UBlockExpression + UQualifiedExpression + UQualifiedExpression + USimpleReferenceExpression (System) + USimpleReferenceExpression (out) + UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) + USimpleReferenceExpression (println) + ULiteralExpression ("finally") + UReturnExpression ULiteralExpression (false) \ No newline at end of file diff --git a/plugins/uast-kotlin/testData/log/Declarations.txt b/plugins/uast-kotlin/testData/log/Declarations.txt index 5bb903f36b7..5bb13bdfe05 100644 --- a/plugins/uast-kotlin/testData/log/Declarations.txt +++ b/plugins/uast-kotlin/testData/log/Declarations.txt @@ -1,7 +1,7 @@ UFile (package = ) UClass (Declarations, kind = class) UFunction (, kind = constructor, paramCount = 0) - EmptyExpression + UVariable (a, kind = member) ULiteralExpression ("a") UVariable (b, kind = member) @@ -10,22 +10,22 @@ UFile (package = ) EmptyExpression UClass (NestedClass, kind = class) UFunction (, kind = constructor, paramCount = 0) - EmptyExpression + UVariable (b, kind = member) ULiteralExpression ("b") UClass (InnerClass, kind = class) UFunction (, kind = constructor, paramCount = 0) - EmptyExpression + UVariable (c, kind = member) USimpleReferenceExpression (a) UClass (Companion, kind = companion object) UFunction (, kind = constructor, paramCount = 0) - EmptyExpression + UVariable (CONST_VAL, kind = member) ULiteralExpression (1) UClass (A, kind = companion object) UFunction (, kind = constructor, paramCount = 0) - EmptyExpression + UFunction (b, kind = function, paramCount = 0) ULiteralExpression (true) UFunction (func, kind = function, paramCount = 2) diff --git a/plugins/uast-kotlin/testData/log/Simple.txt b/plugins/uast-kotlin/testData/log/Simple.txt index 262fc426347..8fb66bd2169 100644 --- a/plugins/uast-kotlin/testData/log/Simple.txt +++ b/plugins/uast-kotlin/testData/log/Simple.txt @@ -1,7 +1,7 @@ UFile (package = ) UClass (Simple, kind = class) UFunction (, kind = constructor, paramCount = 0) - EmptyExpression + UVariable (a, kind = member) UBinaryExpression (+) UBinaryExpression (+) @@ -21,5 +21,5 @@ UFile (package = ) UFunctionCallExpression (UastCallKind(name='function_call'), argCount = 1) USimpleReferenceExpression (println) UBinaryExpression (/) - ULiteralExpression (5.0f) + ULiteralExpression (5.0) ULiteralExpression (2) \ No newline at end of file diff --git a/plugins/uast-kotlin/testData/render/ControlStructures.txt b/plugins/uast-kotlin/testData/render/ControlStructures.txt index 03e31ea7e1b..49ae2d40f0e 100644 --- a/plugins/uast-kotlin/testData/render/ControlStructures.txt +++ b/plugins/uast-kotlin/testData/render/ControlStructures.txt @@ -1,6 +1,31 @@ public static class ControlStructures { - public fun () = EmptyExpression + public fun () + + public immutable var prop: Int = 3 + + public fun nullFun(): String? = null + public fun test(): Boolean { + " " + "Z" + "Z Z" + 'c' + 5 + 5.0 + 5.0 + -5 + +5 + 0.0 + -0.0 + 1.0E10 + 1.0E-10 + public immutable var qwe: Int = 2 + + " " + qwe + " " + "a" + "\"" + "b" + "a'b" + "\r" + "\n" + "5" + "\n" + " 2" + "\t" + "\t" + "\t" if (5 > 3) { println("5 > 3") } @@ -13,7 +38,8 @@ public static class ControlStructures { println(c.toByte()) } - var i: Int = 5 + public var i: Int = 5 + while (i > 0) { i-- if (i == 3) break @@ -23,6 +49,25 @@ public static class ControlStructures { } + "" !is String + ("" as Any) as String? + super.equals(this) + this.equals(this) + this.equals(this) + ControlStructures::test + ControlStructures::prop + ControlStructures::class.java + outer@ for (outerVal : 1 .. 2) { + inner@ for (innerVal : 3 .. 4) { + continue@outer + } + + break@outer + } + + nullFun()?.let({ + println(it) + }) i = 5 do { i -= 1 @@ -35,13 +80,19 @@ public static class ControlStructures { "ABC".zip("DEF").forEach({ println(it.first + " " + it.second) }) - var var1496943053: = "ABC".zip("DEF") - var a: Pair = var1496943053.component1() - var b: Pair = var1496943053.component2() - var value: String = if (5 > 3) "a" else "b" - var list: List = listOf("A") - var list2: List = listOf("A") - var type: String = switch (value) { + public immutable var arr: Array = arrayOf("A", "B", "C") + + println(arr[2]) + local var var1496943053: = "ABC".zip("DEF") + local immutable var a: Pair = var1496943053.component1() + local immutable var b: Pair = var1496943053.component2() + public immutable var value: String = if (5 > 3) "a" else "b" + + public immutable var list: List = listOf("A") + + public immutable var list2: List = listOf("A") + + public immutable var type: String = switch (value) { it in list -> { "inlist" break @@ -52,24 +103,25 @@ public static class ControlStructures { break } - (it) is null -> { + it is String -> { "string" break } - (it) is null -> { + it is CharSequence -> { "cs" break } - else -> { + -> { "unknown" break } } - var x: String = switch { + + public immutable var x: String = switch { value == "b" -> { "B" break @@ -86,14 +138,27 @@ public static class ControlStructures { break } - else -> { + -> { "A" break } } + + try { + 5 + 1 + throw () + } + catch (e) { + e.printStackTrace() + } + catch (e) { + System.out.println("error!") + } + finally { + System.out.println("finally") + } return false } - } diff --git a/plugins/uast-kotlin/testData/render/Declarations.txt b/plugins/uast-kotlin/testData/render/Declarations.txt index 95af5700823..1aaba0d1cc9 100644 --- a/plugins/uast-kotlin/testData/render/Declarations.txt +++ b/plugins/uast-kotlin/testData/render/Declarations.txt @@ -1,5 +1,5 @@ public static class Declarations { - public fun () = EmptyExpression + public fun () public immutable var a: String = "a" @@ -13,25 +13,25 @@ public static class Declarations { public immutable var c: String public static class NestedClass { - public fun () = EmptyExpression + public fun () public immutable var b: String = "b" } public class InnerClass { - public fun () = EmptyExpression + public fun () public immutable var c: CharSequence = a } public static companion object Companion { - public fun () = EmptyExpression + public fun () public immutable var CONST_VAL: Int = 1 } public static companion object A { - public fun () = EmptyExpression + public fun () public fun b(): Boolean = true } diff --git a/plugins/uast-kotlin/testData/render/Simple.txt b/plugins/uast-kotlin/testData/render/Simple.txt index 4bf7171b32f..cce2ae634d9 100644 --- a/plugins/uast-kotlin/testData/render/Simple.txt +++ b/plugins/uast-kotlin/testData/render/Simple.txt @@ -1,11 +1,11 @@ public static class Simple { - public fun () = EmptyExpression + public fun () + public immutable var a: String = "text" + "other" + "text" public immutable var b: List = listOf("A") public fun test(): Unit { - System.out.println(5.0f / 2) + System.out.println(5.0 / 2) } - } diff --git a/plugins/uast-kotlin/testData/tree/ControlStructures.txt b/plugins/uast-kotlin/testData/tree/ControlStructures.txt new file mode 100644 index 00000000000..3fd860b3a13 --- /dev/null +++ b/plugins/uast-kotlin/testData/tree/ControlStructures.txt @@ -0,0 +1,448 @@ +KotlinUFile + KotlinUClass + KotlinNameUSimpleReferenceExpression + KotlinDefaultPrimaryConstructorUFunction + KotlinDumbUElement + KotlinUVariable + KotlinDumbUElement + KotlinULiteralExpression + KotlinUType + KotlinUFunction + KotlinDumbUElement + KotlinULiteralExpression + KotlinUType + KotlinUFunction + KotlinDumbUElement + KotlinUBlockExpression + KotlinStringULiteralExpression + KotlinStringULiteralExpression + KotlinStringULiteralExpression + KotlinULiteralExpression + KotlinULiteralExpression + KotlinULiteralExpression + KotlinULiteralExpression + KotlinUPrefixExpression + KotlinULiteralExpression + KotlinUPrefixExpression + KotlinULiteralExpression + KotlinULiteralExpression + KotlinUPrefixExpression + KotlinULiteralExpression + KotlinULiteralExpression + KotlinULiteralExpression + SimpleUDeclarationsExpression + KotlinUVariable + KotlinDumbUElement + KotlinULiteralExpression + KotlinUType + KotlinStringTemplateUBinaryExpression + KotlinStringTemplateUBinaryExpression + KotlinStringULiteralExpression + KotlinUSimpleReferenceExpression + KotlinStringULiteralExpression + KotlinStringTemplateUBinaryExpression + KotlinStringTemplateUBinaryExpression + KotlinStringULiteralExpression + KotlinStringULiteralExpression + KotlinStringULiteralExpression + KotlinStringTemplateUBinaryExpression + KotlinStringTemplateUBinaryExpression + KotlinStringULiteralExpression + KotlinStringULiteralExpression + KotlinStringULiteralExpression + KotlinStringTemplateUBinaryExpression + KotlinStringTemplateUBinaryExpression + KotlinStringULiteralExpression + KotlinStringULiteralExpression + KotlinStringULiteralExpression + KotlinStringTemplateUBinaryExpression + KotlinStringTemplateUBinaryExpression + KotlinStringULiteralExpression + KotlinStringULiteralExpression + KotlinStringULiteralExpression + KotlinUIfExpression + KotlinUBinaryExpression + KotlinULiteralExpression + KotlinULiteralExpression + KotlinUBlockExpression + KotlinUFunctionCallExpression + KotlinNameUSimpleReferenceExpression + KotlinClassViaConstructorUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + KotlinStringULiteralExpression + KotlinUForEachExpression + KotlinParameterUVariable + KotlinDumbUElement + KotlinUType + KotlinStringULiteralExpression + KotlinUBlockExpression + KotlinUFunctionCallExpression + KotlinNameUSimpleReferenceExpression + KotlinClassViaConstructorUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + KotlinUForEachExpression + KotlinParameterUVariable + KotlinDumbUElement + KotlinUType + KotlinStringULiteralExpression + KotlinUBlockExpression + KotlinUFunctionCallExpression + KotlinNameUSimpleReferenceExpression + KotlinClassViaConstructorUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + KotlinUQualifiedExpression + KotlinUSimpleReferenceExpression + KotlinUFunctionCallExpression + KotlinNameUSimpleReferenceExpression + KotlinClassViaConstructorUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + SimpleUDeclarationsExpression + KotlinUVariable + KotlinDumbUElement + KotlinULiteralExpression + KotlinUType + KotlinUWhileExpression + KotlinUBinaryExpression + KotlinUSimpleReferenceExpression + KotlinULiteralExpression + KotlinUBlockExpression + KotlinUPostfixExpression + KotlinUSimpleReferenceExpression + KotlinUIfExpression + KotlinUBinaryExpression + KotlinUSimpleReferenceExpression + KotlinULiteralExpression + KotlinUBreakExpression + KotlinUIfExpression + KotlinUBinaryExpression + KotlinUSimpleReferenceExpression + KotlinULiteralExpression + KotlinUBlockExpression + KotlinUContinueExpression + KotlinUTypeCheckExpression + KotlinStringULiteralExpression + KotlinUType + KotlinUBinaryExpressionWithType + KotlinUParenthesizedExpression + KotlinUBinaryExpressionWithType + KotlinStringULiteralExpression + KotlinUType + KotlinUType + KotlinUQualifiedExpression + KotlinUSuperExpression + KotlinUFunctionCallExpression + KotlinNameUSimpleReferenceExpression + KotlinClassViaConstructorUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + KotlinUThisExpression + KotlinUQualifiedExpression + KotlinUThisExpression + KotlinUFunctionCallExpression + KotlinNameUSimpleReferenceExpression + KotlinClassViaConstructorUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + KotlinUThisExpression + KotlinUQualifiedExpression + KotlinUThisExpression + KotlinUFunctionCallExpression + KotlinNameUSimpleReferenceExpression + KotlinClassViaConstructorUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + KotlinUThisExpression + KotlinUCallableReferenceExpression + KotlinUType + KotlinUCallableReferenceExpression + KotlinUType + KotlinUQualifiedExpression + KotlinUClassLiteralExpression + KotlinUSimpleReferenceExpression + KotlinULabeledExpression + KotlinUForEachExpression + KotlinParameterUVariable + KotlinDumbUElement + KotlinUType + KotlinUBinaryExpression + KotlinULiteralExpression + KotlinULiteralExpression + KotlinUBlockExpression + KotlinULabeledExpression + KotlinUForEachExpression + KotlinParameterUVariable + KotlinDumbUElement + KotlinUType + KotlinUBinaryExpression + KotlinULiteralExpression + KotlinULiteralExpression + KotlinUBlockExpression + KotlinUContinueExpression + KotlinUBreakExpression + KotlinUSafeQualifiedExpression + KotlinUFunctionCallExpression + KotlinNameUSimpleReferenceExpression + KotlinClassViaConstructorUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + KotlinUFunctionCallExpression + KotlinNameUSimpleReferenceExpression + KotlinClassViaConstructorUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + KotlinULambdaExpression + KotlinUBlockExpression + KotlinUFunctionCallExpression + KotlinNameUSimpleReferenceExpression + KotlinClassViaConstructorUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + KotlinUBinaryExpression + KotlinUSimpleReferenceExpression + KotlinULiteralExpression + KotlinUDoWhileExpression + KotlinUBinaryExpression + KotlinUSimpleReferenceExpression + KotlinULiteralExpression + KotlinUBlockExpression + KotlinUBinaryExpression + KotlinUSimpleReferenceExpression + KotlinULiteralExpression + KotlinUQualifiedExpression + KotlinStringULiteralExpression + KotlinUFunctionCallExpression + KotlinNameUSimpleReferenceExpression + KotlinClassViaConstructorUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + KotlinULambdaExpression + KotlinUBlockExpression + KotlinUFunctionCallExpression + KotlinNameUSimpleReferenceExpression + KotlinClassViaConstructorUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + KotlinUArrayAccessExpression + KotlinUQualifiedExpression + KotlinUSimpleReferenceExpression + KotlinUFunctionCallExpression + KotlinNameUSimpleReferenceExpression + KotlinClassViaConstructorUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + KotlinULiteralExpression + KotlinUQualifiedExpression + KotlinUQualifiedExpression + KotlinStringULiteralExpression + KotlinUFunctionCallExpression + KotlinNameUSimpleReferenceExpression + KotlinClassViaConstructorUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + KotlinStringULiteralExpression + KotlinUFunctionCallExpression + KotlinNameUSimpleReferenceExpression + KotlinClassViaConstructorUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + KotlinULambdaExpression + KotlinUBlockExpression + KotlinUFunctionCallExpression + KotlinNameUSimpleReferenceExpression + KotlinClassViaConstructorUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + KotlinUBinaryExpression + KotlinUBinaryExpression + KotlinUQualifiedExpression + KotlinUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + KotlinStringULiteralExpression + KotlinUQualifiedExpression + KotlinUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + SimpleUDeclarationsExpression + KotlinUVariable + KotlinDumbUElement + KotlinUFunctionCallExpression + KotlinNameUSimpleReferenceExpression + KotlinClassViaConstructorUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + KotlinStringULiteralExpression + KotlinStringULiteralExpression + KotlinStringULiteralExpression + KotlinUType + KotlinUFunctionCallExpression + KotlinNameUSimpleReferenceExpression + KotlinClassViaConstructorUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + KotlinUArrayAccessExpression + KotlinUSimpleReferenceExpression + KotlinULiteralExpression + KotlinUDeclarationsExpression + KotlinDestructuringUVariable + KotlinUQualifiedExpression + KotlinStringULiteralExpression + KotlinUFunctionCallExpression + KotlinNameUSimpleReferenceExpression + KotlinClassViaConstructorUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + KotlinStringULiteralExpression +UastErrorType + KotlinDestructuredUVariable + KotlinDumbUElement + KotlinUComponentQualifiedExpression + KotlinStringUSimpleReferenceExpression + KotlinUComponentFunctionCallExpression + KotlinStringUSimpleReferenceExpression + KotlinUType + KotlinDestructuredUVariable + KotlinDumbUElement + KotlinUComponentQualifiedExpression + KotlinStringUSimpleReferenceExpression + KotlinUComponentFunctionCallExpression + KotlinStringUSimpleReferenceExpression + KotlinUType + SimpleUDeclarationsExpression + KotlinUVariable + KotlinDumbUElement + KotlinUIfExpression + KotlinUBinaryExpression + KotlinULiteralExpression + KotlinULiteralExpression + KotlinStringULiteralExpression + KotlinStringULiteralExpression + KotlinUType + SimpleUDeclarationsExpression + KotlinUVariable + KotlinDumbUElement + KotlinUFunctionCallExpression + KotlinNameUSimpleReferenceExpression + KotlinClassViaConstructorUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + KotlinStringULiteralExpression + KotlinUType + SimpleUDeclarationsExpression + KotlinUVariable + KotlinDumbUElement + KotlinUFunctionCallExpression + KotlinNameUSimpleReferenceExpression + KotlinClassViaConstructorUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + KotlinStringULiteralExpression + KotlinUType + SimpleUDeclarationsExpression + KotlinUVariable + KotlinDumbUElement + KotlinUSwitchExpression + KotlinUSimpleReferenceExpression + + KotlinUSwitchEntry + KotlinCustomUBinaryExpression + KotlinStringUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + + KotlinStringULiteralExpression + $special$$inlined$apply$lambda$1 + KotlinUSwitchEntry + KotlinCustomUBinaryExpression + KotlinStringUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + + KotlinStringULiteralExpression + $special$$inlined$apply$lambda$1 + KotlinUSwitchEntry + KotlinCustomUBinaryExpressionWithType + KotlinStringUSimpleReferenceExpression + KotlinUType + + KotlinStringULiteralExpression + $special$$inlined$apply$lambda$1 + KotlinUSwitchEntry + KotlinCustomUBinaryExpressionWithType + KotlinStringUSimpleReferenceExpression + KotlinUType + + KotlinStringULiteralExpression + $special$$inlined$apply$lambda$1 + KotlinUSwitchEntry + + KotlinStringULiteralExpression + $special$$inlined$apply$lambda$1 + KotlinUType + SimpleUDeclarationsExpression + KotlinUVariable + KotlinDumbUElement + KotlinUSwitchExpression + + KotlinUSwitchEntry + KotlinUBinaryExpression + KotlinUSimpleReferenceExpression + KotlinStringULiteralExpression + + KotlinStringULiteralExpression + $special$$inlined$apply$lambda$1 + KotlinUSwitchEntry + KotlinUBinaryExpression + KotlinUBinaryExpression + KotlinULiteralExpression + KotlinULiteralExpression + KotlinULiteralExpression + + KotlinUFunctionCallExpression + KotlinNameUSimpleReferenceExpression + KotlinClassViaConstructorUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + KotlinStringULiteralExpression + KotlinStringULiteralExpression + $special$$inlined$apply$lambda$1 + KotlinUSwitchEntry + KotlinULiteralExpression + + KotlinStringULiteralExpression + $special$$inlined$apply$lambda$1 + KotlinUSwitchEntry + + KotlinStringULiteralExpression + $special$$inlined$apply$lambda$1 + KotlinUType + KotlinUTryExpression + KotlinUBlockExpression + KotlinUBinaryExpression + KotlinULiteralExpression + KotlinULiteralExpression + KotlinUThrowExpression + KotlinUFunctionCallExpression + KotlinNameUSimpleReferenceExpression + KotlinClassViaConstructorUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + KotlinUCatchClause + KotlinUBlockExpression + KotlinUQualifiedExpression + KotlinUSimpleReferenceExpression + KotlinUFunctionCallExpression + KotlinNameUSimpleReferenceExpression + KotlinClassViaConstructorUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + KotlinParameterUVariable + KotlinDumbUElement + KotlinUType + KotlinUType + KotlinUCatchClause + KotlinUBlockExpression + KotlinUQualifiedExpression + KotlinUQualifiedExpression + KotlinUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + KotlinUFunctionCallExpression + KotlinNameUSimpleReferenceExpression + KotlinClassViaConstructorUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + KotlinStringULiteralExpression + KotlinParameterUVariable + KotlinDumbUElement + KotlinUType + KotlinUType + KotlinUBlockExpression + KotlinUQualifiedExpression + KotlinUQualifiedExpression + KotlinUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + KotlinUFunctionCallExpression + KotlinNameUSimpleReferenceExpression + KotlinClassViaConstructorUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + KotlinStringULiteralExpression + KotlinUReturnExpression + KotlinULiteralExpression + KotlinUType diff --git a/plugins/uast-kotlin/testData/tree/Declarations.txt b/plugins/uast-kotlin/testData/tree/Declarations.txt new file mode 100644 index 00000000000..6f96e708d7b --- /dev/null +++ b/plugins/uast-kotlin/testData/tree/Declarations.txt @@ -0,0 +1,67 @@ +KotlinUFile + KotlinUClass + KotlinNameUSimpleReferenceExpression + KotlinDefaultPrimaryConstructorUFunction + KotlinDumbUElement + KotlinUVariable + KotlinDumbUElement + KotlinStringULiteralExpression + KotlinUType + KotlinUVariable + KotlinDumbUElement + EmptyUExpression + KotlinUType + KotlinUVariable + KotlinDumbUElement + EmptyUExpression + KotlinUType + KotlinUClass + KotlinNameUSimpleReferenceExpression + KotlinDefaultPrimaryConstructorUFunction + KotlinDumbUElement + KotlinUVariable + KotlinDumbUElement + KotlinStringULiteralExpression + KotlinUType + KotlinUClass + KotlinNameUSimpleReferenceExpression + KotlinDefaultPrimaryConstructorUFunction + KotlinDumbUElement + KotlinUVariable + KotlinDumbUElement + KotlinUSimpleReferenceExpression + KotlinUType + KotlinUClass + KotlinDefaultPrimaryConstructorUFunction + KotlinDumbUElement + KotlinUVariable + KotlinDumbUElement + KotlinULiteralExpression + KotlinUType + KotlinUClass + KotlinNameUSimpleReferenceExpression + KotlinDefaultPrimaryConstructorUFunction + KotlinDumbUElement + KotlinUFunction + KotlinDumbUElement + KotlinULiteralExpression + KotlinUType + KotlinUFunction + KotlinDumbUElement + KotlinParameterUVariable + KotlinDumbUElement + KotlinUType + KotlinParameterUVariable + KotlinDumbUElement + KotlinUType + KotlinUBlockExpression + KotlinUReturnExpression + KotlinUBinaryExpression + KotlinUParenthesizedExpression + KotlinUBinaryExpression + KotlinUSimpleReferenceExpression + KotlinULiteralExpression + KotlinUQualifiedExpression + KotlinUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + KotlinUType diff --git a/plugins/uast-kotlin/testData/tree/Simple.txt b/plugins/uast-kotlin/testData/tree/Simple.txt new file mode 100644 index 00000000000..dce95c9f61e --- /dev/null +++ b/plugins/uast-kotlin/testData/tree/Simple.txt @@ -0,0 +1,36 @@ +KotlinUFile + KotlinUClass + KotlinNameUSimpleReferenceExpression + KotlinDefaultPrimaryConstructorUFunction + KotlinDumbUElement + KotlinUVariable + KotlinDumbUElement + KotlinUBinaryExpression + KotlinUBinaryExpression + KotlinStringULiteralExpression + KotlinStringULiteralExpression + KotlinStringULiteralExpression + KotlinUType + KotlinUVariable + KotlinDumbUElement + KotlinUFunctionCallExpression + KotlinNameUSimpleReferenceExpression + KotlinClassViaConstructorUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + KotlinStringULiteralExpression + KotlinUType + KotlinUFunction + KotlinDumbUElement + KotlinUBlockExpression + KotlinUQualifiedExpression + KotlinUQualifiedExpression + KotlinUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + KotlinUFunctionCallExpression + KotlinNameUSimpleReferenceExpression + KotlinClassViaConstructorUSimpleReferenceExpression + KotlinUSimpleReferenceExpression + KotlinUBinaryExpression + KotlinULiteralExpression + KotlinULiteralExpression + KotlinUType