From f74c0950d241df2ac31419582be44b8b4a605440 Mon Sep 17 00:00:00 2001 From: Kirill Rakhman Date: Mon, 16 Jan 2017 21:35:48 +0100 Subject: [PATCH] use property syntax --- .../src/org/jetbrains/kotlin/psi/KtClass.kt | 4 ++-- .../org/jetbrains/kotlin/psi/KtPsiFactory.kt | 20 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtClass.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtClass.kt index 53f39fae056..284eae40711 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtClass.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtClass.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 JetBrains s.r.o. + * Copyright 2010-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -89,7 +89,7 @@ open class KtClass : KtClassOrObject { } fun KtClass.createPrimaryConstructorIfAbsent(): KtPrimaryConstructor { - val constructor = getPrimaryConstructor() + val constructor = primaryConstructor if (constructor != null) return constructor var anchor: PsiElement? = typeParameterList if (anchor == null) anchor = nameIdentifier diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiFactory.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiFactory.kt index 2045851eca1..cdca360283a 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiFactory.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiFactory.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 JetBrains s.r.o. + * Copyright 2010-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -181,7 +181,7 @@ class KtPsiFactory(private val project: Project) { } fun createCompanionObject(): KtObjectDeclaration { - return createClass("class A {\n companion object{\n}\n}").getCompanionObjects().first() + return createClass("class A {\n companion object{\n}\n}").companionObjects.first() } fun createFileAnnotation(annotationText: String): KtAnnotationEntry { @@ -293,7 +293,7 @@ class KtPsiFactory(private val project: Project) { fun createCallableReferenceExpression(text: String) = createExpression(text) as? KtCallableReferenceExpression fun createSecondaryConstructor(decl: String): KtSecondaryConstructor { - return createClass("class Foo {\n $decl \n}").getSecondaryConstructors().first() + return createClass("class Foo {\n $decl \n}").secondaryConstructors.first() } fun createModifierList(modifier: KtModifierKeywordToken): KtModifierList { @@ -326,7 +326,7 @@ class KtPsiFactory(private val project: Project) { } fun createParameter(text : String): KtParameter { - return createClass("class A($text)").getPrimaryConstructorParameters().first() + return createClass("class A($text)").primaryConstructorParameters.first() } fun createParameterList(text: String): KtParameterList { @@ -401,15 +401,15 @@ class KtPsiFactory(private val project: Project) { } fun createPrimaryConstructor(): KtPrimaryConstructor { - return createClass("class A()").getPrimaryConstructor()!! + return createClass("class A()").primaryConstructor!! } fun createPrimaryConstructor(modifiers: String?): KtPrimaryConstructor { - return modifiers?.let { createClass("class A $modifiers constructor()").getPrimaryConstructor() } ?: createPrimaryConstructor() + return modifiers?.let { createClass("class A $modifiers constructor()").primaryConstructor } ?: createPrimaryConstructor() } fun createConstructorKeyword(): PsiElement = - createClass("class A constructor()").getPrimaryConstructor()!!.getConstructorKeyword()!! + createClass("class A constructor()").primaryConstructor!!.getConstructorKeyword()!! fun createLabeledExpression(labelName: String): KtLabeledExpression = createExpression("$labelName@ 1") as KtLabeledExpression @@ -456,16 +456,16 @@ class KtPsiFactory(private val project: Project) { fun createArgument(text: String) = createCallArguments("($text)").arguments.first()!! fun createSuperTypeCallEntry(text: String): KtSuperTypeCallEntry { - return createClass("class A: $text").getSuperTypeListEntries().first() as KtSuperTypeCallEntry + return createClass("class A: $text").superTypeListEntries.first() as KtSuperTypeCallEntry } fun createSuperTypeEntry(text: String): KtSuperTypeEntry { - return createClass("class A: $text").getSuperTypeListEntries().first() as KtSuperTypeEntry + return createClass("class A: $text").superTypeListEntries.first() as KtSuperTypeEntry } fun creareDelegatedSuperTypeEntry(text: String): KtConstructorDelegationCall { val colonOrEmpty = if (text.isEmpty()) "" else ": " - return createClass("class A { constructor()$colonOrEmpty$text {}").getSecondaryConstructors().first().getDelegationCall() + return createClass("class A { constructor()$colonOrEmpty$text {}").secondaryConstructors.first().getDelegationCall() } class ClassHeaderBuilder {