[slc] reformat code
^KT-50241
This commit is contained in:
+1
@@ -26,6 +26,7 @@ internal class FirLightIdentifier(
|
||||
is KtPrimaryConstructor -> ktDeclaration.getConstructorKeyword()
|
||||
?: ktDeclaration.valueParameterList
|
||||
?: ktDeclaration.containingClassOrObject?.nameIdentifier
|
||||
|
||||
is KtPropertyAccessor -> ktDeclaration.namePlaceholder
|
||||
is KtNamedDeclaration -> ktDeclaration.nameIdentifier
|
||||
else -> null
|
||||
|
||||
+2
@@ -52,6 +52,7 @@ class SymbolLightClassFacadeCache(private val project: Project) {
|
||||
analyzeForLightClasses(firstFile) {
|
||||
FirLightClassForFacade(firstFile.manager, facadeClassFqName, ktFiles)
|
||||
}
|
||||
|
||||
ktFiles.all { it.isCompiled } -> {
|
||||
val file = ktFiles.firstOrNull { it.javaFileFacadeFqName == facadeClassFqName } as? KtClsFile
|
||||
?: error("Can't find the representative decompiled file for $facadeClassFqName")
|
||||
@@ -64,6 +65,7 @@ class SymbolLightClassFacadeCache(private val project: Project) {
|
||||
) ?: return null
|
||||
KtLightClassForDecompiledFacade(clsDelegate, clsDelegate.parent, file, classOrObject, ktFiles)
|
||||
}
|
||||
|
||||
else ->
|
||||
error("Source and compiled files are mixed: $ktFiles}")
|
||||
}
|
||||
|
||||
+2
-2
@@ -25,13 +25,13 @@ import org.jetbrains.kotlin.asJava.elements.KtLightMethod
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
|
||||
import org.jetbrains.kotlin.fileClasses.javaFileFacadeFqName
|
||||
import org.jetbrains.kotlin.idea.KotlinLanguage
|
||||
import org.jetbrains.kotlin.light.classes.symbol.modifierLists.FirLightClassModifierList
|
||||
import org.jetbrains.kotlin.light.classes.symbol.fields.FirLightField
|
||||
import org.jetbrains.kotlin.light.classes.symbol.NullabilityType
|
||||
import org.jetbrains.kotlin.light.classes.symbol.annotations.computeAnnotations
|
||||
import org.jetbrains.kotlin.light.classes.symbol.annotations.hasInlineOnlyAnnotation
|
||||
import org.jetbrains.kotlin.light.classes.symbol.annotations.hasJvmFieldAnnotation
|
||||
import org.jetbrains.kotlin.light.classes.symbol.annotations.hasJvmMultifileClassAnnotation
|
||||
import org.jetbrains.kotlin.light.classes.symbol.fields.FirLightField
|
||||
import org.jetbrains.kotlin.light.classes.symbol.modifierLists.FirLightClassModifierList
|
||||
import org.jetbrains.kotlin.light.classes.symbol.toPsiVisibilityForMember
|
||||
import org.jetbrains.kotlin.load.java.structure.LightClassOriginKind
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
|
||||
+15
-11
@@ -83,11 +83,13 @@ internal fun createFirLightClassNoCache(classOrObject: KtClassOrObject): KtLight
|
||||
classOrObject is KtEnumEntry -> analyzeForLightClasses(classOrObject) {
|
||||
lightClassForEnumEntry(classOrObject)
|
||||
}
|
||||
|
||||
classOrObject.hasModifier(INLINE_KEYWORD) -> {
|
||||
analyzeForLightClasses(classOrObject) {
|
||||
classOrObject.getNamedClassOrObjectSymbol()?.let { FirLightInlineClass(it, classOrObject.manager) }
|
||||
}
|
||||
}
|
||||
|
||||
else -> {
|
||||
analyzeForLightClasses(classOrObject) {
|
||||
classOrObject.getClassOrObjectSymbol().createLightClassNoCache(classOrObject.manager)
|
||||
@@ -98,7 +100,7 @@ internal fun createFirLightClassNoCache(classOrObject: KtClassOrObject): KtLight
|
||||
|
||||
|
||||
context(KtAnalysisSession)
|
||||
internal fun KtClassOrObjectSymbol.createLightClassNoCache(manager: PsiManager): FirLightClassBase = when (this) {
|
||||
internal fun KtClassOrObjectSymbol.createLightClassNoCache(manager: PsiManager): FirLightClassBase = when (this) {
|
||||
is KtAnonymousObjectSymbol -> FirLightAnonymousClassForSymbol(this, manager)
|
||||
is KtNamedClassOrObjectSymbol -> when (classKind) {
|
||||
KtClassKind.INTERFACE -> FirLightInterfaceClassSymbol(this, manager)
|
||||
@@ -108,7 +110,7 @@ context(KtAnalysisSession)
|
||||
}
|
||||
|
||||
context(KtAnalysisSession)
|
||||
private fun lightClassForEnumEntry(ktEnumEntry: KtEnumEntry): KtLightClass? {
|
||||
private fun lightClassForEnumEntry(ktEnumEntry: KtEnumEntry): KtLightClass? {
|
||||
if (ktEnumEntry.body == null) return null
|
||||
|
||||
val firClass = ktEnumEntry
|
||||
@@ -124,7 +126,7 @@ context(KtAnalysisSession)
|
||||
}
|
||||
|
||||
context(KtAnalysisSession)
|
||||
internal fun FirLightClassBase.createConstructors(
|
||||
internal fun FirLightClassBase.createConstructors(
|
||||
declarations: Sequence<KtConstructorSymbol>,
|
||||
result: MutableList<KtLightMethod>
|
||||
) {
|
||||
@@ -153,7 +155,7 @@ context(KtAnalysisSession)
|
||||
}
|
||||
|
||||
context(KtAnalysisSession)
|
||||
private fun FirLightClassBase.shouldGenerateNoArgOverload(
|
||||
private fun FirLightClassBase.shouldGenerateNoArgOverload(
|
||||
primaryConstructor: KtConstructorSymbol,
|
||||
constructors: Iterable<KtConstructorSymbol>,
|
||||
): Boolean {
|
||||
@@ -168,7 +170,7 @@ context(KtAnalysisSession)
|
||||
}
|
||||
|
||||
context(KtAnalysisSession)
|
||||
private fun FirLightClassBase.defaultConstructor(): KtLightMethod {
|
||||
private fun FirLightClassBase.defaultConstructor(): KtLightMethod {
|
||||
val classOrObject = kotlinOrigin
|
||||
val visibility = when {
|
||||
classOrObject is KtObjectDeclaration || classOrObject?.hasModifier(SEALED_KEYWORD) == true || isEnum -> PsiModifier.PRIVATE
|
||||
@@ -179,7 +181,7 @@ context(KtAnalysisSession)
|
||||
}
|
||||
|
||||
context(KtAnalysisSession)
|
||||
private fun FirLightClassBase.noArgConstructor(
|
||||
private fun FirLightClassBase.noArgConstructor(
|
||||
visibility: String,
|
||||
methodIndex: Int,
|
||||
): KtLightMethod {
|
||||
@@ -196,7 +198,7 @@ context(KtAnalysisSession)
|
||||
}
|
||||
|
||||
context(KtAnalysisSession)
|
||||
internal fun FirLightClassBase.createMethods(
|
||||
internal fun FirLightClassBase.createMethods(
|
||||
declarations: Sequence<KtCallableSymbol>,
|
||||
result: MutableList<KtLightMethod>,
|
||||
isTopLevel: Boolean = false,
|
||||
@@ -241,12 +243,14 @@ context(KtAnalysisSession)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is KtPropertySymbol -> createPropertyAccessors(
|
||||
result,
|
||||
declaration,
|
||||
isTopLevel = isTopLevel,
|
||||
suppressStatic = suppressStatic
|
||||
)
|
||||
|
||||
is KtConstructorSymbol -> error("Constructors should be handled separately and not passed to this function")
|
||||
else -> {}
|
||||
}
|
||||
@@ -263,7 +267,7 @@ context(KtAnalysisSession)
|
||||
}
|
||||
|
||||
context(KtAnalysisSession)
|
||||
internal fun FirLightClassBase.createPropertyAccessors(
|
||||
internal fun FirLightClassBase.createPropertyAccessors(
|
||||
result: MutableList<KtLightMethod>,
|
||||
declaration: KtPropertySymbol,
|
||||
isTopLevel: Boolean,
|
||||
@@ -342,7 +346,7 @@ context(KtAnalysisSession)
|
||||
}
|
||||
|
||||
context(KtAnalysisSession)
|
||||
internal fun FirLightClassBase.createField(
|
||||
internal fun FirLightClassBase.createField(
|
||||
declaration: KtPropertySymbol,
|
||||
nameGenerator: FirLightField.FieldNameGenerator,
|
||||
isTopLevel: Boolean,
|
||||
@@ -386,7 +390,7 @@ context(KtAnalysisSession)
|
||||
}
|
||||
|
||||
context(KtAnalysisSession)
|
||||
internal fun FirLightClassBase.createInheritanceList(forExtendsList: Boolean, superTypes: List<KtType>): PsiReferenceList {
|
||||
internal fun FirLightClassBase.createInheritanceList(forExtendsList: Boolean, superTypes: List<KtType>): PsiReferenceList {
|
||||
|
||||
val role = if (forExtendsList) PsiReferenceList.Role.EXTENDS_LIST else PsiReferenceList.Role.IMPLEMENTS_LIST
|
||||
|
||||
@@ -428,7 +432,7 @@ context(KtAnalysisSession)
|
||||
}
|
||||
|
||||
context(KtAnalysisSession)
|
||||
internal fun KtSymbolWithMembers.createInnerClasses(
|
||||
internal fun KtSymbolWithMembers.createInnerClasses(
|
||||
manager: PsiManager,
|
||||
containingClass: FirLightClassBase,
|
||||
classOrObject: KtClassOrObject?
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ internal abstract class FirLightPsiJavaCodeReferenceElementBase(private val ktEl
|
||||
|
||||
override fun multiResolve(incompleteCode: Boolean): Array<JavaResolveResult> = emptyArray()
|
||||
|
||||
override fun processVariants(processor: PsiScopeProcessor) { }
|
||||
override fun processVariants(processor: PsiScopeProcessor) {}
|
||||
|
||||
override fun advancedResolve(incompleteCode: Boolean): JavaResolveResult =
|
||||
JavaResolveResult.EMPTY
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiReference
|
||||
import com.intellij.util.IncorrectOperationException
|
||||
|
||||
internal class FirLightPsiJavaCodeReferenceElementWithNoReference(private val ktElement: PsiElement):
|
||||
internal class FirLightPsiJavaCodeReferenceElementWithNoReference(private val ktElement: PsiElement) :
|
||||
FirLightPsiJavaCodeReferenceElementBase(ktElement),
|
||||
PsiReference {
|
||||
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ package org.jetbrains.kotlin.light.classes.symbol.codeReferences
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiReference
|
||||
|
||||
internal class FirLightPsiJavaCodeReferenceElementWithReference(private val ktElement: PsiElement, reference: PsiReference):
|
||||
internal class FirLightPsiJavaCodeReferenceElementWithReference(private val ktElement: PsiElement, reference: PsiReference) :
|
||||
FirLightPsiJavaCodeReferenceElementBase(ktElement),
|
||||
PsiReference by reference {
|
||||
|
||||
|
||||
+1
@@ -47,6 +47,7 @@ internal class FirLightFieldForPropertySymbol(
|
||||
(kotlinOrigin as? KtProperty)?.delegateExpression?.let {
|
||||
it.getKtType()?.asPsiType(this@FirLightFieldForPropertySymbol, KtTypeMappingMode.RETURN_TYPE)
|
||||
}
|
||||
|
||||
else -> {
|
||||
propertySymbol.returnType.asPsiType(this@FirLightFieldForPropertySymbol, KtTypeMappingMode.RETURN_TYPE)
|
||||
}
|
||||
|
||||
+7
-1
@@ -92,6 +92,7 @@ internal fun KtSymbolWithModality.computeModalityForMethod(
|
||||
result.add(PsiModifier.STATIC)
|
||||
}
|
||||
}
|
||||
|
||||
context(KtAnalysisSession)
|
||||
internal fun PsiElement.tryGetEffectiveVisibility(symbol: KtCallableSymbol): Visibility? {
|
||||
if (symbol !is KtPropertySymbol && symbol !is KtFunctionSymbol) return null
|
||||
@@ -122,6 +123,7 @@ private fun Visibility.toPsiVisibility(isTopLevel: Boolean, forClass: Boolean):
|
||||
// Nested private class has PRIVATE visibility
|
||||
Visibilities.Private, Visibilities.PrivateToThis ->
|
||||
if (forClass && isTopLevel) PsiModifier.PACKAGE_LOCAL else PsiModifier.PRIVATE
|
||||
|
||||
Visibilities.Protected -> PsiModifier.PROTECTED
|
||||
else -> PsiModifier.PUBLIC
|
||||
}
|
||||
@@ -201,6 +203,7 @@ internal fun KtAnnotationValue.toAnnotationMemberValue(parent: PsiElement): PsiA
|
||||
FirPsiArrayInitializerMemberValue(sourcePsi, parent) { arrayLiteralParent ->
|
||||
values.mapNotNull { element -> element.toAnnotationMemberValue(arrayLiteralParent) }
|
||||
}
|
||||
|
||||
is KtAnnotationApplicationValue ->
|
||||
FirLightSimpleAnnotation(
|
||||
annotationValue.classId?.relativeClassName?.asString(),
|
||||
@@ -208,6 +211,7 @@ internal fun KtAnnotationValue.toAnnotationMemberValue(parent: PsiElement): PsiA
|
||||
annotationValue.arguments,
|
||||
annotationValue.psi
|
||||
)
|
||||
|
||||
is KtConstantAnnotationValue -> {
|
||||
this.constantValue.createPsiLiteral(parent)?.let {
|
||||
when (it) {
|
||||
@@ -216,11 +220,13 @@ internal fun KtAnnotationValue.toAnnotationMemberValue(parent: PsiElement): PsiA
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is KtEnumEntryAnnotationValue -> {
|
||||
val fqName = this.callableId?.asSingleFqName()?.asString() ?: return null
|
||||
val psiExpression = PsiElementFactory.getInstance(parent.project).createExpressionFromText(fqName, parent)
|
||||
FirPsiExpression(sourcePsi, parent, psiExpression)
|
||||
}
|
||||
|
||||
KtUnsupportedAnnotationValue -> null
|
||||
is KtKClassAnnotationValue.KtErrorClassAnnotationValue -> null
|
||||
is KtKClassAnnotationValue.KtLocalKClassAnnotationValue -> null
|
||||
@@ -231,7 +237,7 @@ internal fun KtAnnotationValue.toAnnotationMemberValue(parent: PsiElement): PsiA
|
||||
private fun KtKClassAnnotationValue.KtNonLocalKClassAnnotationValue.toAnnotationMemberValue(parent: PsiElement): PsiExpression? {
|
||||
val fqName = classId.asSingleFqName()
|
||||
val canonicalText = psiType(
|
||||
fqName.asString(), parent, boxPrimitiveType = false /* TODO value.arrayNestedness > 0*/,
|
||||
fqName.asString(), parent, boxPrimitiveType = false, /* TODO value.arrayNestedness > 0*/
|
||||
).let(TypeConversionUtil::erasure).getCanonicalText(false)
|
||||
return try {
|
||||
PsiElementFactory.getInstance(parent.project).createExpressionFromText("$canonicalText.class", parent)
|
||||
|
||||
+2
-2
@@ -73,8 +73,8 @@ internal class FirLightConstructorForSymbol(
|
||||
override fun equals(other: Any?): Boolean =
|
||||
this === other ||
|
||||
(other is FirLightConstructorForSymbol &&
|
||||
kotlinOrigin == other.kotlinOrigin &&
|
||||
constructorSymbol == other.constructorSymbol)
|
||||
kotlinOrigin == other.kotlinOrigin &&
|
||||
constructorSymbol == other.constructorSymbol)
|
||||
|
||||
override fun hashCode(): Int = kotlinOrigin.hashCode()
|
||||
|
||||
|
||||
+3
-3
@@ -20,7 +20,7 @@ internal class FirLightNoArgConstructor(
|
||||
containingClass: FirLightClassBase,
|
||||
visibility: String,
|
||||
methodIndex: Int,
|
||||
): FirLightMethod(lightMemberOrigin, containingClass, methodIndex) {
|
||||
) : FirLightMethod(lightMemberOrigin, containingClass, methodIndex) {
|
||||
private val _name: String? = containingClass.name
|
||||
|
||||
override fun getName(): String = _name ?: ""
|
||||
@@ -60,8 +60,8 @@ internal class FirLightNoArgConstructor(
|
||||
override fun equals(other: Any?): Boolean =
|
||||
this === other ||
|
||||
(other is FirLightNoArgConstructor &&
|
||||
kotlinOrigin == other.kotlinOrigin &&
|
||||
containingClass == other.containingClass)
|
||||
kotlinOrigin == other.kotlinOrigin &&
|
||||
containingClass == other.containingClass)
|
||||
|
||||
override fun hashCode(): Int = containingClass.hashCode()
|
||||
|
||||
|
||||
+4
@@ -70,8 +70,10 @@ internal class FirLightSimpleMethodForSymbol(
|
||||
when {
|
||||
functionSymbol.isSuspend -> // Any?
|
||||
return@l NullabilityType.Nullable
|
||||
|
||||
isVoidReturnType ->
|
||||
return@l NullabilityType.Unknown
|
||||
|
||||
else ->
|
||||
functionSymbol.returnType
|
||||
}
|
||||
@@ -145,8 +147,10 @@ internal class FirLightSimpleMethodForSymbol(
|
||||
val ktType = when {
|
||||
functionSymbol.isSuspend -> // Any?
|
||||
analysisSession.builtinTypes.NULLABLE_ANY
|
||||
|
||||
isVoidReturnType ->
|
||||
return@lazyPub PsiType.VOID
|
||||
|
||||
else ->
|
||||
functionSymbol.returnType
|
||||
}
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ internal class FirLightParameterForReceiver private constructor(
|
||||
) : FirLightParameter(method) {
|
||||
|
||||
companion object {
|
||||
context (KtAnalysisSession)
|
||||
context (KtAnalysisSession)
|
||||
fun tryGet(
|
||||
callableSymbol: KtCallableSymbol,
|
||||
method: FirLightMethod
|
||||
|
||||
+2
-3
@@ -8,16 +8,15 @@ package org.jetbrains.kotlin.light.classes.symbol.parameters
|
||||
import com.intellij.psi.PsiParameter
|
||||
import com.intellij.psi.PsiParameterList
|
||||
import com.intellij.psi.impl.light.LightParameterListBuilder
|
||||
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtCallableSymbol
|
||||
import org.jetbrains.kotlin.asJava.classes.lazyPub
|
||||
import org.jetbrains.kotlin.asJava.elements.KtLightElement
|
||||
import org.jetbrains.kotlin.asJava.elements.KtLightElementBase
|
||||
import org.jetbrains.kotlin.light.classes.symbol.methods.FirLightMethod
|
||||
import org.jetbrains.kotlin.psi.KtFunction
|
||||
import org.jetbrains.kotlin.psi.KtParameterList
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
||||
import org.jetbrains.kotlin.light.classes.symbol.methods.FirLightMethod
|
||||
|
||||
context(KtAnalysisSession)
|
||||
internal class FirLightParameterList(
|
||||
private val parent: FirLightMethod,
|
||||
|
||||
+2
@@ -107,9 +107,11 @@ abstract class AbstractSymbolLightClassesAnnotationOwnerTest(
|
||||
is PsiClass,
|
||||
is PsiParameter ->
|
||||
TestCase.assertTrue(owner is FirLightClassModifierList<*>)
|
||||
|
||||
is PsiField,
|
||||
is PsiMethod ->
|
||||
TestCase.assertTrue(owner is FirLightMemberModifierList<*>)
|
||||
|
||||
else ->
|
||||
throw IllegalStateException("Unexpected annotation owner kind: ${lastDeclaration::class.java}")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user