Cleanup: apply "Use synthetic property access syntax"
This commit is contained in:
@@ -34,7 +34,7 @@ object LightClassUtil {
|
||||
|
||||
fun findClass(stub: StubElement<*>, predicate: (PsiClassStub<*>) -> Boolean): PsiClass? {
|
||||
if (stub is PsiClassStub<*> && predicate(stub)) {
|
||||
return stub.getPsi()
|
||||
return stub.psi
|
||||
}
|
||||
|
||||
if (stub is PsiClassStub<*> || stub is PsiFileStub<*>) {
|
||||
|
||||
+4
-4
@@ -165,9 +165,9 @@ class LightClassDataProviderForClassOrObject(private val classOrObject: KtClassO
|
||||
LightClassDataProvider<WithFileStubAndExtraDiagnostics>(classOrObject.project) {
|
||||
|
||||
private val file: KtFile
|
||||
get() = classOrObject.getContainingKtFile()
|
||||
get() = classOrObject.containingKtFile
|
||||
|
||||
override val isLocal: Boolean get() = classOrObject.isLocal()
|
||||
override val isLocal: Boolean get() = classOrObject.isLocal
|
||||
|
||||
override fun getContext(files: Collection<KtFile>): LightClassConstructionContext {
|
||||
return LightClassGenerationSupport.getInstance(classOrObject.project).getContextForClassOrObject(classOrObject)
|
||||
@@ -237,7 +237,7 @@ class LightClassDataProviderForClassOrObject(private val classOrObject: KtClassO
|
||||
// TODO: current method will process local classes in irrelevant declarations, it should be fixed.
|
||||
// We generate all enclosing classes
|
||||
|
||||
if (classOrObject.isLocal() && processingClassOrObject.isLocal()) {
|
||||
if (classOrObject.isLocal && processingClassOrObject.isLocal) {
|
||||
val commonParent = PsiTreeUtil.findCommonParent(classOrObject, processingClassOrObject)
|
||||
return commonParent != null && commonParent !is PsiFile
|
||||
}
|
||||
@@ -252,7 +252,7 @@ class LightClassDataProviderForClassOrObject(private val classOrObject: KtClassO
|
||||
|
||||
override fun generate(state: GenerationState, files: Collection<KtFile>) {
|
||||
val packageCodegen = state.factory.forPackage(packageFqName, files)
|
||||
val file = classOrObject.getContainingKtFile()
|
||||
val file = classOrObject.containingKtFile
|
||||
val packagePartType = state.fileClassesProvider.getFileClassType(file)
|
||||
val context = state.rootContext.intoPackagePart(packageCodegen.packageFragment, packagePartType, file)
|
||||
packageCodegen.generateClassOrObject(classOrObject, context)
|
||||
|
||||
+4
-4
@@ -194,7 +194,7 @@ class KtLightClassForFacade private constructor(
|
||||
|
||||
override fun isValid() = files.all { it.isValid && fileHasTopLevelCallables(it) && facadeClassFqName == it.javaFileFacadeFqName }
|
||||
|
||||
override fun copy() = KtLightClassForFacade(getManager(), facadeClassFqName, lightClassDataCache, files)
|
||||
override fun copy() = KtLightClassForFacade(manager, facadeClassFqName, lightClassDataCache, files)
|
||||
|
||||
override val clsDelegate: PsiClass
|
||||
get() {
|
||||
@@ -216,7 +216,7 @@ class KtLightClassForFacade private constructor(
|
||||
override fun getNavigationElement() = files.iterator().next()
|
||||
|
||||
override fun isEquivalentTo(another: PsiElement?): Boolean {
|
||||
return another is PsiClass && Comparing.equal(another.qualifiedName, getQualifiedName())
|
||||
return another is PsiClass && Comparing.equal(another.qualifiedName, qualifiedName)
|
||||
}
|
||||
|
||||
override fun getElementIcon(flags: Int): Icon? = throw UnsupportedOperationException("This should be done by JetIconProvider")
|
||||
@@ -240,7 +240,7 @@ class KtLightClassForFacade private constructor(
|
||||
override fun hashCode() = hashCode
|
||||
|
||||
private fun computeHashCode(): Int {
|
||||
var result = getManager().hashCode()
|
||||
var result = manager.hashCode()
|
||||
result = 31 * result + files.hashCode()
|
||||
result = 31 * result + facadeClassFqName.hashCode()
|
||||
return result
|
||||
@@ -255,7 +255,7 @@ class KtLightClassForFacade private constructor(
|
||||
if (this === other) return true
|
||||
|
||||
if (this.hashCode != lightClass.hashCode) return false
|
||||
if (getManager() != lightClass.getManager()) return false
|
||||
if (manager != lightClass.manager) return false
|
||||
if (files != lightClass.files) return false
|
||||
if (facadeClassFqName != lightClass.facadeClassFqName) return false
|
||||
|
||||
|
||||
+3
-3
@@ -121,7 +121,7 @@ abstract class KtLightClassForSourceDeclaration(protected val classOrObject: KtC
|
||||
classOrObject.containingFile.virtualFile ?: error("No virtual file for " + classOrObject.text)
|
||||
|
||||
object : FakeFileForLightClass(
|
||||
classOrObject.getContainingKtFile(),
|
||||
classOrObject.containingKtFile,
|
||||
{ if (classOrObject.isTopLevel()) this else create(getOutermostClassOrObject(classOrObject))!! },
|
||||
{ getJavaFileStub() }
|
||||
) {
|
||||
@@ -352,7 +352,7 @@ abstract class KtLightClassForSourceDeclaration(protected val classOrObject: KtC
|
||||
|
||||
|
||||
fun create(classOrObject: KtClassOrObject): KtLightClassForSourceDeclaration? {
|
||||
if (classOrObject.getContainingKtFile().isScript || classOrObject.hasModifier(KtTokens.HEADER_KEYWORD)) {
|
||||
if (classOrObject.containingKtFile.isScript || classOrObject.hasModifier(KtTokens.HEADER_KEYWORD)) {
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -366,7 +366,7 @@ abstract class KtLightClassForSourceDeclaration(protected val classOrObject: KtC
|
||||
return null
|
||||
}
|
||||
|
||||
if (classOrObject.isLocal()) {
|
||||
if (classOrObject.isLocal) {
|
||||
if (classOrObject.containingFile.virtualFile == null) return null
|
||||
|
||||
return KtLightClassForLocalDeclaration(classOrObject)
|
||||
|
||||
@@ -91,12 +91,12 @@ class FilteredJvmDiagnostics(val jvmDiagnostics: Diagnostics, val otherDiagnosti
|
||||
val higherPriority = setOf<DiagnosticFactory<*>>(
|
||||
CONFLICTING_OVERLOADS, REDECLARATION, NOTHING_TO_OVERRIDE, MANY_IMPL_MEMBER_NOT_IMPLEMENTED)
|
||||
return otherDiagnostics.forElement(psiElement).any { it.factory in higherPriority }
|
||||
|| psiElement is KtPropertyAccessor && alreadyReported(psiElement.getParent()!!)
|
||||
|| psiElement is KtPropertyAccessor && alreadyReported(psiElement.parent!!)
|
||||
}
|
||||
|
||||
override fun forElement(psiElement: PsiElement): Collection<Diagnostic> {
|
||||
val jvmDiagnosticFactories = setOf(CONFLICTING_JVM_DECLARATIONS, ACCIDENTAL_OVERRIDE, CONFLICTING_INHERITED_JVM_DECLARATIONS)
|
||||
fun Diagnostic.data() = cast(this, jvmDiagnosticFactories).getA()
|
||||
fun Diagnostic.data() = cast(this, jvmDiagnosticFactories).a
|
||||
val (conflicting, other) = jvmDiagnostics.forElement(psiElement).partition { it.factory in jvmDiagnosticFactories }
|
||||
if (alreadyReported(psiElement)) {
|
||||
// CONFLICTING_OVERLOADS already reported, no need to duplicate it
|
||||
|
||||
@@ -70,7 +70,7 @@ fun PsiElement.toLightMethods(): List<PsiMethod> =
|
||||
is KtProperty -> LightClassUtil.getLightClassPropertyMethods(this).toList()
|
||||
is KtParameter -> LightClassUtil.getLightClassPropertyMethods(this).toList()
|
||||
is KtPropertyAccessor -> LightClassUtil.getLightClassAccessorMethods(this)
|
||||
is KtClass -> toLightClass()?.getConstructors()?.firstOrNull().singletonOrEmptyList()
|
||||
is KtClass -> toLightClass()?.constructors?.firstOrNull().singletonOrEmptyList()
|
||||
is PsiMethod -> this.singletonList()
|
||||
else -> listOf()
|
||||
}
|
||||
@@ -88,8 +88,8 @@ fun PsiElement.getRepresentativeLightMethod(): PsiMethod? =
|
||||
fun KtParameter.toPsiParameters(): Collection<PsiParameter> {
|
||||
val paramList = getNonStrictParentOfType<KtParameterList>() ?: return emptyList()
|
||||
|
||||
val paramIndex = paramList.getParameters().indexOf(this)
|
||||
val owner = paramList.getParent()
|
||||
val paramIndex = paramList.parameters.indexOf(this)
|
||||
val owner = paramList.parent
|
||||
val lightParamIndex = if (owner is KtDeclaration && owner.isExtensionDeclaration()) paramIndex + 1 else paramIndex
|
||||
|
||||
val methods: Collection<PsiMethod> =
|
||||
|
||||
Reference in New Issue
Block a user