[Analysis API] create declarations from a library with library origin in StubBasedFirDeserializedSymbolProvider
This commit is contained in:
committed by
Space Team
parent
a3b67594ff
commit
64f90f685d
Vendored
+4
-3
@@ -148,7 +148,7 @@ KtFunctionSymbol:
|
||||
isSuspend: false
|
||||
modality: FINAL
|
||||
name: copy
|
||||
origin: SOURCE_MEMBER_GENERATED
|
||||
origin: LIBRARY
|
||||
receiverParameter: null
|
||||
returnType: KtUsualClassType:
|
||||
annotationsList: []
|
||||
@@ -176,7 +176,7 @@ KtFunctionSymbol:
|
||||
isNoinline: false
|
||||
isVararg: false
|
||||
name: first
|
||||
origin: SOURCE_MEMBER_GENERATED
|
||||
origin: LIBRARY
|
||||
receiverParameter: null
|
||||
returnType: KtTypeParameterType:
|
||||
annotationsList: []
|
||||
@@ -195,7 +195,7 @@ KtFunctionSymbol:
|
||||
isNoinline: false
|
||||
isVararg: false
|
||||
name: second
|
||||
origin: SOURCE_MEMBER_GENERATED
|
||||
origin: LIBRARY
|
||||
receiverParameter: null
|
||||
returnType: KtTypeParameterType:
|
||||
annotationsList: []
|
||||
@@ -400,3 +400,4 @@ KtKotlinPropertySymbol:
|
||||
symbolKind: CLASS_MEMBER
|
||||
typeParameters: []
|
||||
visibility: Public
|
||||
|
||||
|
||||
+1
-1
@@ -226,7 +226,7 @@ internal fun deserializeClassToSymbol(
|
||||
classOrObject,
|
||||
context.dispatchReceiver,
|
||||
zippedParameters,
|
||||
createResolvedStatus = true,
|
||||
isFromLibrary = true,
|
||||
createClassTypeRefWithSourceKind = { firPrimaryConstructor.returnTypeRef.copyWithNewSourceKind(it) },
|
||||
createParameterTypeRefWithSourceKind = { property, newKind ->
|
||||
property.returnTypeRef.copyWithNewSourceKind(newKind)
|
||||
|
||||
+23
-21
@@ -73,7 +73,7 @@ abstract class AbstractRawFirBuilder<T>(val baseSession: FirSession, val context
|
||||
name: Name,
|
||||
isExpect: Boolean,
|
||||
forceLocalContext: Boolean = false,
|
||||
l: () -> T
|
||||
l: () -> T,
|
||||
) = when {
|
||||
forceLocalContext -> withForcedLocalContext {
|
||||
withChildClassNameRegardlessLocalContext(name, isExpect, l)
|
||||
@@ -86,7 +86,7 @@ abstract class AbstractRawFirBuilder<T>(val baseSession: FirSession, val context
|
||||
inline fun <T> withChildClassNameRegardlessLocalContext(
|
||||
name: Name,
|
||||
isExpect: Boolean,
|
||||
l: () -> T
|
||||
l: () -> T,
|
||||
): T {
|
||||
context.className = context.className.child(name)
|
||||
val previousIsExpect = context.containerIsExpect
|
||||
@@ -134,7 +134,7 @@ abstract class AbstractRawFirBuilder<T>(val baseSession: FirSession, val context
|
||||
status: Boolean,
|
||||
declarationSource: KtSourceElement? = null,
|
||||
currentFirTypeParameters: List<FirTypeParameterRef>,
|
||||
block: () -> T
|
||||
block: () -> T,
|
||||
): T {
|
||||
addCapturedTypeParameters(status, declarationSource, currentFirTypeParameters)
|
||||
return try {
|
||||
@@ -147,7 +147,7 @@ abstract class AbstractRawFirBuilder<T>(val baseSession: FirSession, val context
|
||||
protected open fun addCapturedTypeParameters(
|
||||
status: Boolean,
|
||||
declarationSource: KtSourceElement?,
|
||||
currentFirTypeParameters: List<FirTypeParameterRef>
|
||||
currentFirTypeParameters: List<FirTypeParameterRef>,
|
||||
) {
|
||||
context.pushFirTypeParameters(status, currentFirTypeParameters)
|
||||
}
|
||||
@@ -218,7 +218,7 @@ abstract class AbstractRawFirBuilder<T>(val baseSession: FirSession, val context
|
||||
fun FirExpression.toReturn(
|
||||
baseSource: KtSourceElement? = source,
|
||||
labelName: String? = null,
|
||||
fromKtReturnExpression: Boolean = false
|
||||
fromKtReturnExpression: Boolean = false,
|
||||
): FirReturnExpression {
|
||||
return buildReturnExpression {
|
||||
fun FirFunctionTarget.bindToErrorFunction(message: String, kind: DiagnosticKind) {
|
||||
@@ -466,7 +466,7 @@ abstract class AbstractRawFirBuilder<T>(val baseSession: FirSession, val context
|
||||
protected fun ExceptionAttachmentBuilder.withSourceElementEntry(name: String, element: T?) {
|
||||
when (element) {
|
||||
is PsiElement -> withPsiEntry(name, element)
|
||||
else -> withEntry(name, element) { it.asText}
|
||||
else -> withEntry(name, element) { it.asText }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -474,7 +474,7 @@ abstract class AbstractRawFirBuilder<T>(val baseSession: FirSession, val context
|
||||
fun convertUnaryPlusMinusCallOnIntegerLiteralIfNecessary(
|
||||
source: T,
|
||||
receiver: FirExpression,
|
||||
operationToken: IElementType
|
||||
operationToken: IElementType,
|
||||
): FirExpression? {
|
||||
if (receiver !is FirConstExpression<*>) return null
|
||||
if (receiver.kind != ConstantValueKind.IntegerLiteral) return null
|
||||
@@ -498,7 +498,7 @@ abstract class AbstractRawFirBuilder<T>(val baseSession: FirSession, val context
|
||||
fun Array<out T?>.toInterpolatingCall(
|
||||
base: T,
|
||||
getElementType: (T) -> IElementType = { it.elementType },
|
||||
convertTemplateEntry: T?.(String) -> FirExpression
|
||||
convertTemplateEntry: T?.(String) -> FirExpression,
|
||||
): FirExpression {
|
||||
return buildStringConcatenationCall {
|
||||
val sb = StringBuilder()
|
||||
@@ -555,7 +555,7 @@ abstract class AbstractRawFirBuilder<T>(val baseSession: FirSession, val context
|
||||
receiver: T?,
|
||||
callName: Name,
|
||||
prefix: Boolean,
|
||||
convert: T.() -> FirExpression
|
||||
convert: T.() -> FirExpression,
|
||||
): FirExpression {
|
||||
val unwrappedReceiver = receiver.unwrap() ?: return buildErrorExpression {
|
||||
diagnostic = ConeSyntaxDiagnostic("Inc/dec without operand")
|
||||
@@ -630,7 +630,7 @@ abstract class AbstractRawFirBuilder<T>(val baseSession: FirSession, val context
|
||||
receiver: T,
|
||||
callName: Name,
|
||||
prefix: Boolean,
|
||||
convert: T.() -> FirExpression
|
||||
convert: T.() -> FirExpression,
|
||||
): FirExpression {
|
||||
val array = receiver.arrayExpression
|
||||
return buildBlockPossiblyUnderSafeCall(
|
||||
@@ -740,7 +740,7 @@ abstract class AbstractRawFirBuilder<T>(val baseSession: FirSession, val context
|
||||
receiver: T?,
|
||||
convert: T.() -> FirExpression,
|
||||
sourceElementForError: KtSourceElement?,
|
||||
init: FirBlockBuilder.(receiver: FirExpression) -> Unit = {}
|
||||
init: FirBlockBuilder.(receiver: FirExpression) -> Unit = {},
|
||||
): FirExpression {
|
||||
val receiverFir = receiver?.convert() ?: buildErrorExpression {
|
||||
source = sourceElementForError
|
||||
@@ -779,7 +779,7 @@ abstract class AbstractRawFirBuilder<T>(val baseSession: FirSession, val context
|
||||
// since there should be different nodes for desugaring as `.set(.., get().plus($rhs1))` and `.get(...).plusAssign($rhs2)`
|
||||
// Once KT-50861 is fixed, those two parameters shall be eliminated
|
||||
rhsAST: T?,
|
||||
convert: T.() -> FirExpression
|
||||
convert: T.() -> FirExpression,
|
||||
): FirStatement {
|
||||
val unwrappedLhs = this.unwrap() ?: return buildErrorExpression {
|
||||
diagnostic = ConeSyntaxDiagnostic("Inc/dec without operand")
|
||||
@@ -880,7 +880,7 @@ abstract class AbstractRawFirBuilder<T>(val baseSession: FirSession, val context
|
||||
safeCallNonAssignment: FirSafeCallExpression,
|
||||
baseSource: KtSourceElement?,
|
||||
rhsExpression: FirExpression,
|
||||
annotations: List<FirAnnotation>
|
||||
annotations: List<FirAnnotation>,
|
||||
): FirSafeCallExpression {
|
||||
val nestedAccess = safeCallNonAssignment.selector as FirQualifiedAccessExpression
|
||||
|
||||
@@ -905,7 +905,7 @@ abstract class AbstractRawFirBuilder<T>(val baseSession: FirSession, val context
|
||||
operation: FirOperation,
|
||||
annotations: List<FirAnnotation>,
|
||||
rhs: T?,
|
||||
convert: T.() -> FirExpression
|
||||
convert: T.() -> FirExpression,
|
||||
): FirStatement {
|
||||
require(receiver is FirFunctionCall) {
|
||||
"Array access should be desugared to a function call, but $receiver is found"
|
||||
@@ -974,7 +974,7 @@ abstract class AbstractRawFirBuilder<T>(val baseSession: FirSession, val context
|
||||
source,
|
||||
currentDispatchReceiverType(),
|
||||
zippedParameters,
|
||||
createResolvedStatus = false,
|
||||
isFromLibrary = false,
|
||||
createClassTypeRefWithSourceKind,
|
||||
createParameterTypeRefWithSourceKind,
|
||||
{ src, kind -> src?.toFirSourceElement(kind) },
|
||||
@@ -1024,7 +1024,7 @@ abstract class AbstractRawFirBuilder<T>(val baseSession: FirSession, val context
|
||||
protected fun buildExpressionWithErrorLabel(
|
||||
element: FirElement?,
|
||||
errorLabelSource: KtSourceElement?,
|
||||
elementSource: KtSourceElement
|
||||
elementSource: KtSourceElement,
|
||||
): FirElement {
|
||||
return if (element != null) {
|
||||
if (errorLabelSource != null) {
|
||||
@@ -1044,7 +1044,7 @@ abstract class AbstractRawFirBuilder<T>(val baseSession: FirSession, val context
|
||||
protected fun convertFirSelector(
|
||||
firSelector: FirQualifiedAccessExpression,
|
||||
source: KtSourceElement?,
|
||||
receiver: FirExpression
|
||||
receiver: FirExpression,
|
||||
): FirQualifiedAccessExpression {
|
||||
return if (firSelector is FirImplicitInvokeCall) {
|
||||
buildImplicitInvokeCall {
|
||||
@@ -1113,7 +1113,7 @@ fun <TBase, TSource : TBase, TParameter : TBase> FirRegularClassBuilder.createDa
|
||||
sourceElement: TSource,
|
||||
dispatchReceiver: ConeClassLikeType?,
|
||||
zippedParameters: List<Pair<TParameter, FirProperty>>,
|
||||
createResolvedStatus: Boolean,
|
||||
isFromLibrary: Boolean,
|
||||
createClassTypeRefWithSourceKind: (KtFakeSourceElementKind) -> FirTypeRef,
|
||||
createParameterTypeRefWithSourceKind: (FirProperty, KtFakeSourceElementKind) -> FirTypeRef,
|
||||
toFirSource: (TBase?, KtFakeSourceElementKind) -> KtSourceElement?,
|
||||
@@ -1143,17 +1143,19 @@ fun <TBase, TSource : TBase, TParameter : TBase> FirRegularClassBuilder.createDa
|
||||
}
|
||||
}
|
||||
|
||||
val declarationOrigin = if (isFromLibrary) FirDeclarationOrigin.Library else FirDeclarationOrigin.Synthetic.DataClassMember
|
||||
|
||||
return buildSimpleFunction {
|
||||
val classTypeRef = createClassTypeRefWithSourceKind(KtFakeSourceElementKind.DataClassGeneratedMembers)
|
||||
this.source = toFirSource(sourceElement, KtFakeSourceElementKind.DataClassGeneratedMembers)
|
||||
moduleData = this@createDataClassCopyFunction.moduleData
|
||||
origin = FirDeclarationOrigin.Synthetic.DataClassMember
|
||||
origin = declarationOrigin
|
||||
returnTypeRef = classTypeRef
|
||||
name = StandardNames.DATA_CLASS_COPY
|
||||
symbol = FirNamedFunctionSymbol(CallableId(classId.packageFqName, classId.relativeClassName, StandardNames.DATA_CLASS_COPY))
|
||||
dispatchReceiverType = dispatchReceiver
|
||||
resolvePhase = this@createDataClassCopyFunction.resolvePhase
|
||||
status = if (createResolvedStatus) {
|
||||
status = if (isFromLibrary) {
|
||||
FirResolvedDeclarationStatusImpl(Visibilities.Public, Modality.FINAL, EffectiveVisibility.Public)
|
||||
} else {
|
||||
FirDeclarationStatusImpl(Visibilities.Public, Modality.FINAL)
|
||||
@@ -1167,7 +1169,7 @@ fun <TBase, TSource : TBase, TParameter : TBase> FirRegularClassBuilder.createDa
|
||||
source = parameterSource
|
||||
containingFunctionSymbol = this@buildSimpleFunction.symbol
|
||||
moduleData = this@createDataClassCopyFunction.moduleData
|
||||
origin = FirDeclarationOrigin.Synthetic.DataClassMember
|
||||
origin = declarationOrigin
|
||||
returnTypeRef = propertyReturnTypeRef
|
||||
name = propertyName
|
||||
symbol = FirValueParameterSymbol(propertyName)
|
||||
|
||||
Reference in New Issue
Block a user