diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetClass.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetClass.kt index d5b1a79ff84..bfc8a7c9467 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetClass.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetClass.kt @@ -30,18 +30,19 @@ public open class JetClass : JetClassOrObject { public constructor(node: ASTNode) : super(node) public constructor(stub: KotlinClassStub) : super(stub, JetStubElementTypes.CLASS) - override fun getStub(): KotlinClassStub? = super.getStub() as? KotlinClassStub - override fun accept(visitor: JetVisitor, data: D): R { return visitor.visitClass(this, data) } + private val _stub: KotlinClassStub? + get() = stub as? KotlinClassStub + public fun getColon(): PsiElement? = findChildByType(JetTokens.COLON) public fun getProperties(): List = getBody()?.getProperties().orEmpty() public fun isInterface(): Boolean = - getStub()?.isInterface() ?: (findChildByType(JetTokens.INTERFACE_KEYWORD) != null) + _stub?.isInterface() ?: (findChildByType(JetTokens.INTERFACE_KEYWORD) != null) public fun isEnum(): Boolean = hasModifier(JetTokens.ENUM_KEYWORD) public fun isSealed(): Boolean = hasModifier(JetTokens.SEALED_KEYWORD) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetEnumEntry.java b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetEnumEntry.java index f2d1da47fd7..c444a5cdb7a 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetEnumEntry.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetEnumEntry.java @@ -17,16 +17,14 @@ package org.jetbrains.kotlin.psi; import com.intellij.lang.ASTNode; -import com.intellij.openapi.util.Comparing; import com.intellij.psi.PsiClass; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiEnumConstant; -import com.intellij.psi.PsiField; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.name.FqName; +import org.jetbrains.kotlin.psi.stubs.KotlinClassOrObjectStub; import org.jetbrains.kotlin.psi.stubs.KotlinClassStub; import org.jetbrains.kotlin.psi.stubs.elements.JetStubElementTypes; @@ -44,7 +42,7 @@ public class JetEnumEntry extends JetClass { @Override public String getName() { - KotlinClassStub classStub = getStub(); + KotlinClassOrObjectStub classStub = getStub(); if (classStub != null) { return classStub.getName(); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetObjectDeclaration.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetObjectDeclaration.kt index 860e7f88445..c503ace1933 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetObjectDeclaration.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetObjectDeclaration.kt @@ -28,13 +28,11 @@ public class JetObjectDeclaration : JetClassOrObject { public constructor(node: ASTNode) : super(node) public constructor(stub: KotlinObjectStub) : super(stub, JetStubElementTypes.OBJECT_DECLARATION) - override fun getStub(): KotlinObjectStub? = super.getStub() as? KotlinObjectStub + private val _stub: KotlinObjectStub? + get() = stub as? KotlinObjectStub override fun getName(): String? { - val stub = stub - if (stub != null) { - return stub.name - } + _stub?.name?.let { return it } val nameAsDeclaration = getNameAsDeclaration() if (nameAsDeclaration == null && isCompanion()) { @@ -60,7 +58,7 @@ public class JetObjectDeclaration : JetClassOrObject { } } - public fun isCompanion(): Boolean = stub?.isCompanion() ?: hasModifier(JetTokens.COMPANION_KEYWORD) + public fun isCompanion(): Boolean = _stub?.isCompanion() ?: hasModifier(JetTokens.COMPANION_KEYWORD) override fun getTextOffset(): Int = nameIdentifier?.textRange?.startOffset ?: getObjectKeyword().textRange.startOffset @@ -69,7 +67,7 @@ public class JetObjectDeclaration : JetClassOrObject { return visitor.visitObjectDeclaration(this, data) } - public fun isObjectLiteral(): Boolean = stub?.isObjectLiteral() ?: (parent is JetObjectLiteralExpression) + public fun isObjectLiteral(): Boolean = _stub?.isObjectLiteral() ?: (parent is JetObjectLiteralExpression) public fun getObjectKeyword(): PsiElement = findChildByType(JetTokens.OBJECT_KEYWORD)!! }