Uast: consistency updates for ULambdaExpression
This commit is contained in:
@@ -90,6 +90,14 @@ abstract class KotlinAbstractUElement(private val givenParent: UElement?) : UEle
|
|||||||
parent = parent.parent
|
parent = parent.parent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (psi is KtFunctionLiteral && parent is KtLambdaExpression) {
|
||||||
|
parent = parent.parent
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parent is KtLambdaArgument) {
|
||||||
|
parent = parent.parent
|
||||||
|
}
|
||||||
|
|
||||||
if (psi is KtSuperTypeCallEntry) {
|
if (psi is KtSuperTypeCallEntry) {
|
||||||
parent = parent?.parent
|
parent = parent?.parent
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ class KotlinUastLanguagePlugin : UastLanguagePlugin {
|
|||||||
is KtFunction ->
|
is KtFunction ->
|
||||||
if (original.isLocal) {
|
if (original.isLocal) {
|
||||||
el<ULambdaExpression> {
|
el<ULambdaExpression> {
|
||||||
if (original.name.isNullOrEmpty()) {
|
if (original.name.isNullOrEmpty() || original.parent is KtLambdaExpression) {
|
||||||
createLocalFunctionLambdaExpression(original, givenParent)
|
createLocalFunctionLambdaExpression(original, givenParent)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
+2
@@ -5,6 +5,8 @@ import java.io.InputStream
|
|||||||
fun foo() {
|
fun foo() {
|
||||||
val runnable = object : Runnable { override fun run() {} }
|
val runnable = object : Runnable { override fun run() {} }
|
||||||
runnable.run()
|
runnable.run()
|
||||||
|
val runnable2 = Runnable { println() }
|
||||||
|
runnable2.run()
|
||||||
val closeableRunnable = object : Runnable, Closeable { override fun close() {} override fun run() {} }
|
val closeableRunnable = object : Runnable, Closeable { override fun close() {} override fun run() {} }
|
||||||
val runnableIs = object : InputStream(), Runnable { override fun read(): Int = 0; override fun run() {} }
|
val runnableIs = object : InputStream(), Runnable { override fun read(): Int = 0; override fun run() {} }
|
||||||
}
|
}
|
||||||
+15
@@ -16,6 +16,21 @@ UFile (package = )
|
|||||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
|
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
|
||||||
UIdentifier (Identifier (run))
|
UIdentifier (Identifier (run))
|
||||||
USimpleNameReferenceExpression (identifier = run)
|
USimpleNameReferenceExpression (identifier = run)
|
||||||
|
UDeclarationsExpression
|
||||||
|
ULocalVariable (name = runnable2)
|
||||||
|
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1))
|
||||||
|
UIdentifier (Identifier (Runnable))
|
||||||
|
USimpleNameReferenceExpression (identifier = Runnable)
|
||||||
|
ULambdaExpression
|
||||||
|
UBlockExpression
|
||||||
|
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
|
||||||
|
UIdentifier (Identifier (println))
|
||||||
|
USimpleNameReferenceExpression (identifier = println)
|
||||||
|
UQualifiedReferenceExpression
|
||||||
|
USimpleNameReferenceExpression (identifier = runnable2)
|
||||||
|
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
|
||||||
|
UIdentifier (Identifier (run))
|
||||||
|
USimpleNameReferenceExpression (identifier = run)
|
||||||
UDeclarationsExpression
|
UDeclarationsExpression
|
||||||
ULocalVariable (name = closeableRunnable)
|
ULocalVariable (name = closeableRunnable)
|
||||||
UObjectLiteralExpression
|
UObjectLiteralExpression
|
||||||
|
|||||||
@@ -5,6 +5,10 @@ public final class AnonymousKt {
|
|||||||
public static final fun foo() : void {
|
public static final fun foo() : void {
|
||||||
var runnable: <ErrorType> = anonymous object : Runnable { override fun run() {} }
|
var runnable: <ErrorType> = anonymous object : Runnable { override fun run() {} }
|
||||||
runnable.run()
|
runnable.run()
|
||||||
|
var runnable2: java.lang.Runnable = Runnable({
|
||||||
|
println()
|
||||||
|
})
|
||||||
|
runnable2.run()
|
||||||
var closeableRunnable: <ErrorType> = anonymous object : Runnable, Closeable { override fun close() {} override fun run() {} }
|
var closeableRunnable: <ErrorType> = anonymous object : Runnable, Closeable { override fun close() {} override fun run() {} }
|
||||||
var runnableIs: <ErrorType> = anonymous object : InputStream(), Runnable { override fun read(): Int = 0; override fun run() {} }
|
var runnableIs: <ErrorType> = anonymous object : InputStream(), Runnable { override fun read(): Int = 0; override fun run() {} }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,9 +49,11 @@ class SimpleKotlinRenderLogTest : AbstractKotlinRenderLogTest() {
|
|||||||
|
|
||||||
@Test fun testParametersWithDefaultValues() = doTest("ParametersWithDefaultValues")
|
@Test fun testParametersWithDefaultValues() = doTest("ParametersWithDefaultValues")
|
||||||
|
|
||||||
@Test fun testUnexpectedContainer() = doTest("UnexpectedContainerException") { testName, file -> check(testName, file, false) }
|
@Test
|
||||||
|
fun testUnexpectedContainer() = doTest("UnexpectedContainerException")
|
||||||
|
|
||||||
@Test fun testWhenStringLiteral() = doTest("WhenStringLiteral") { testName, file -> check(testName, file, false) }
|
@Test
|
||||||
|
fun testWhenStringLiteral() = doTest("WhenStringLiteral")
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testWhenAndDestructing() = doTest("WhenAndDestructing") { testName, file -> check(testName, file, false) }
|
fun testWhenAndDestructing() = doTest("WhenAndDestructing") { testName, file -> check(testName, file, false) }
|
||||||
|
|||||||
Reference in New Issue
Block a user