Reformat file

Relates to #KT-40960
This commit is contained in:
Vladimir Dolzhenko
2020-08-10 15:46:00 +02:00
committed by Vladimir Dolzhenko
parent 5c7054a5ab
commit ee0250bd35
@@ -170,9 +170,9 @@ object LightClassUtil {
private fun findFileFacade(ktFile: KtFile): PsiClass? {
val fqName = ktFile.javaFileFacadeFqName
val project = ktFile.project
val classesWithMatchingFqName = JavaElementFinder.getInstance(project).findClasses(fqName.asString(), GlobalSearchScope.allScope(project))
return classesWithMatchingFqName.singleOrNull() ?:
classesWithMatchingFqName.find {
val classesWithMatchingFqName =
JavaElementFinder.getInstance(project).findClasses(fqName.asString(), GlobalSearchScope.allScope(project))
return classesWithMatchingFqName.singleOrNull() ?: classesWithMatchingFqName.find {
it.containingFile?.virtualFile == ktFile.virtualFile
}
}
@@ -193,7 +193,8 @@ object LightClassUtil {
private fun extractPropertyAccessors(
ktDeclaration: KtDeclaration,
specialGetter: PsiMethod?, specialSetter: PsiMethod?): PropertyAccessorsPsiMethods {
specialGetter: PsiMethod?, specialSetter: PsiMethod?
): PropertyAccessorsPsiMethods {
val (setters, getters) = getPsiMethodWrappers(ktDeclaration).partition { it.isSetter }
@@ -211,12 +212,13 @@ object LightClassUtil {
fun buildLightTypeParameterList(
owner: PsiTypeParameterListOwner,
declaration: KtDeclaration): PsiTypeParameterList {
declaration: KtDeclaration
): PsiTypeParameterList {
val builder = KotlinLightTypeParameterListBuilder(owner)
if (declaration is KtTypeParameterListOwner) {
val parameters = declaration.typeParameters
for (i in parameters.indices) {
val jetTypeParameter = parameters.get(i)
val jetTypeParameter = parameters[i]
val name = jetTypeParameter.name
val safeName = name ?: "__no_name__"
builder.addParameter(KtLightTypeParameter(owner, i, safeName))
@@ -225,19 +227,21 @@ object LightClassUtil {
return builder
}
class PropertyAccessorsPsiMethods(val getter: PsiMethod?,
class PropertyAccessorsPsiMethods(
val getter: PsiMethod?,
val setter: PsiMethod?,
val backingField: PsiField?,
additionalAccessors: List<PsiMethod>) : Iterable<PsiMethod> {
additionalAccessors: List<PsiMethod>
) : Iterable<PsiMethod> {
private val allMethods: List<PsiMethod>
val allDeclarations: List<PsiNamedElement>
init {
allMethods = arrayListOf<PsiMethod>()
allMethods = arrayListOf()
arrayOf(getter, setter).filterNotNullTo(allMethods)
additionalAccessors.filterIsInstanceTo<PsiMethod, MutableList<PsiMethod>>(allMethods)
allDeclarations = arrayListOf<PsiNamedElement>()
allDeclarations = arrayListOf()
arrayOf<PsiNamedElement?>(getter, setter, backingField).filterNotNullTo(allDeclarations)
allDeclarations.addAll(additionalAccessors)
}
@@ -250,6 +254,6 @@ fun KtNamedDeclaration.getAccessorLightMethods(): LightClassUtil.PropertyAccesso
return when (this) {
is KtProperty -> LightClassUtil.getLightClassPropertyMethods(this)
is KtParameter -> LightClassUtil.getLightClassPropertyMethods(this)
else -> throw IllegalStateException("Unexpected property type: ${this}")
else -> throw IllegalStateException("Unexpected property type: $this")
}
}