FIR/UAST: commonize throw expression

This commit is contained in:
Jinseong Jeon
2021-05-27 01:07:47 -07:00
committed by Ilya Kirillov
parent c21fce6cbc
commit 8977e7766b
7 changed files with 28 additions and 33 deletions
@@ -0,0 +1,19 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.uast.kotlin
import org.jetbrains.kotlin.psi.KtThrowExpression
import org.jetbrains.uast.UElement
import org.jetbrains.uast.UThrowExpression
class KotlinUThrowExpression(
override val sourcePsi: KtThrowExpression,
givenParent: UElement?
) : KotlinAbstractUExpression(givenParent), UThrowExpression, KotlinUElementWithType {
override val thrownExpression by lz {
baseResolveProviderService.baseKotlinConverter.convertOrEmpty(sourcePsi.thrownExpression, this)
}
}
@@ -277,6 +277,7 @@ internal object FirKotlinConverter : BaseKotlinConverter {
FirKotlinUBlockExpression(expression, givenParent)
}
is KtReturnExpression -> expr<UReturnExpression>(build(::KotlinUReturnExpression))
is KtThrowExpression -> expr<UThrowExpression>(build(::KotlinUThrowExpression))
is KtBreakExpression -> expr<UBreakExpression>(build(::KotlinUBreakExpression))
is KtContinueExpression -> expr<UContinueExpression>(build(::KotlinUContinueExpression))
@@ -8,4 +8,5 @@ UFile (package = )
UParameter (name = clazz)
UParameter (name = factory)
UBlockExpression
[!] UnknownKotlinExpression (THROW)
UThrowExpression
[!] UnknownKotlinExpression (CALL_EXPRESSION)
@@ -5,6 +5,6 @@ public abstract interface Callback {
public final class Model {
public fun Model() = UastEmptyExpression
public final fun crashMe(clazz: java.lang.Class<T>, factory: kotlin.jvm.functions.Function0<? extends T>) : void {
[!] UnknownKotlinExpression (THROW)
throw [!] UnknownKotlinExpression (CALL_EXPRESSION)
}
}
@@ -8,4 +8,5 @@ UFile (package = ) [public abstract interface Callback {...]
UParameter (name = clazz) [var clazz: java.lang.Class<T>]
UParameter (name = factory) [var factory: kotlin.jvm.functions.Function0<? extends T>]
UBlockExpression [{...}]
[!] UnknownKotlinExpression (THROW) [[!] UnknownKotlinExpression (THROW)]
UThrowExpression [throw [!] UnknownKotlinExpression (CALL_EXPRESSION)]
[!] UnknownKotlinExpression (CALL_EXPRESSION) [[!] UnknownKotlinExpression (CALL_EXPRESSION)]
@@ -7,5 +7,6 @@ UFile (package = ) [public abstract interface Callback {...]
UMethod (name = crashMe) [public final fun crashMe(clazz: java.lang.Class<T>, factory: kotlin.jvm.functions.Function0<? extends T>) : void {...}]
UParameter (name = clazz) [var clazz: java.lang.Class<T>]
UParameter (name = factory) [var factory: kotlin.jvm.functions.Function0<? extends T>]
UBlockExpression [{...}] = Undetermined
[!] UnknownKotlinExpression (THROW) [[!] UnknownKotlinExpression (THROW)] = Undetermined
UBlockExpression [{...}] = Nothing
UThrowExpression [throw [!] UnknownKotlinExpression (CALL_EXPRESSION)] = Nothing
[!] UnknownKotlinExpression (CALL_EXPRESSION) [[!] UnknownKotlinExpression (CALL_EXPRESSION)] = Undetermined
@@ -1,28 +0,0 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.uast.kotlin
import org.jetbrains.kotlin.psi.KtThrowExpression
import org.jetbrains.uast.UElement
import org.jetbrains.uast.UThrowExpression
class KotlinUThrowExpression(
override val sourcePsi: KtThrowExpression,
givenParent: UElement?
) : KotlinAbstractUExpression(givenParent), UThrowExpression, KotlinUElementWithType {
override val thrownExpression by lz { KotlinConverter.convertOrEmpty(sourcePsi.thrownExpression, this) }
}