Analysis API: adapt to KtCall data model change
Also add API to check if a `KtFunctionSymbol` is the invoke function on a Kotlin builtin functional type.
This commit is contained in:
committed by
Ilya Kirillov
parent
53b3893738
commit
c9f9ce99c1
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2020 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.kotlin.analysis.api.calls
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtFunctionLikeSymbol
|
||||
|
||||
public fun KtCallTarget.getSuccessCallSymbolOrNull(): KtFunctionLikeSymbol? = when (this) {
|
||||
is KtSuccessCallTarget -> symbol
|
||||
is KtErrorCallTarget -> null
|
||||
}
|
||||
|
||||
public fun KtCallTarget.getSingleCandidateSymbolOrNull(): KtFunctionLikeSymbol? = when (this) {
|
||||
is KtSuccessCallTarget -> symbol
|
||||
is KtErrorCallTarget -> candidates.singleOrNull()
|
||||
}
|
||||
|
||||
public inline fun <reified S : KtFunctionLikeSymbol> KtCall.isSuccessCallOf(predicate: (S) -> Boolean): Boolean {
|
||||
if (this !is KtSimpleFunctionCall) return false
|
||||
val symbol = targetFunction.getSuccessCallSymbolOrNull() ?: return false
|
||||
if (symbol !is S) return false
|
||||
return predicate(symbol)
|
||||
}
|
||||
+5
@@ -53,6 +53,11 @@ public abstract class KtFunctionSymbol : KtFunctionLikeSymbol(),
|
||||
public abstract val isInfix: Boolean
|
||||
public abstract val isStatic: Boolean
|
||||
|
||||
/**
|
||||
* Whether this symbol is the `invoke` method defined on the Kotlin builtin functional type.
|
||||
*/
|
||||
public abstract val isBuiltinFunctionInvoke: Boolean
|
||||
|
||||
abstract override fun createPointer(): KtSymbolPointer<KtFunctionSymbol>
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -2,6 +2,7 @@ KtFunctionSymbol:
|
||||
annotationsList: []
|
||||
callableIdIfNonLocal: null
|
||||
hasStableParameterNames: true
|
||||
isBuiltinFunctionInvoke: false
|
||||
isExtension: false
|
||||
isExternal: false
|
||||
isInfix: false
|
||||
|
||||
@@ -132,6 +132,7 @@ KtFunctionSymbol:
|
||||
]
|
||||
callableIdIfNonLocal: /f
|
||||
hasStableParameterNames: true
|
||||
isBuiltinFunctionInvoke: false
|
||||
isExtension: false
|
||||
isExternal: false
|
||||
isInfix: false
|
||||
@@ -217,6 +218,7 @@ KtFunctionSymbol:
|
||||
]
|
||||
callableIdIfNonLocal: /Foo.f2
|
||||
hasStableParameterNames: true
|
||||
isBuiltinFunctionInvoke: false
|
||||
isExtension: false
|
||||
isExternal: false
|
||||
isInfix: false
|
||||
|
||||
+1
@@ -187,6 +187,7 @@ KtFunctionSymbol:
|
||||
annotationsList: []
|
||||
callableIdIfNonLocal: /X.foo
|
||||
hasStableParameterNames: true
|
||||
isBuiltinFunctionInvoke: false
|
||||
isExtension: false
|
||||
isExternal: false
|
||||
isInfix: false
|
||||
|
||||
+1
@@ -135,6 +135,7 @@ KtFunctionSymbol:
|
||||
annotationsList: []
|
||||
callableIdIfNonLocal: /X.f
|
||||
hasStableParameterNames: true
|
||||
isBuiltinFunctionInvoke: false
|
||||
isExtension: false
|
||||
isExternal: false
|
||||
isInfix: false
|
||||
|
||||
+1
@@ -2,6 +2,7 @@ KtFunctionSymbol:
|
||||
annotationsList: []
|
||||
callableIdIfNonLocal: test/TopLevel.Child.withOuter
|
||||
hasStableParameterNames: true
|
||||
isBuiltinFunctionInvoke: false
|
||||
isExtension: false
|
||||
isExternal: false
|
||||
isInfix: false
|
||||
|
||||
Reference in New Issue
Block a user