Don't override StubBasedPsiElementBase.getStub
#KT-9575 Fixed
This commit is contained in:
@@ -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 <R, D> accept(visitor: JetVisitor<R, D>, 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<JetProperty> = getBody()?.getProperties().orEmpty()
|
||||
|
||||
public fun isInterface(): Boolean =
|
||||
getStub()?.isInterface() ?: (findChildByType<PsiElement>(JetTokens.INTERFACE_KEYWORD) != null)
|
||||
_stub?.isInterface() ?: (findChildByType<PsiElement>(JetTokens.INTERFACE_KEYWORD) != null)
|
||||
|
||||
public fun isEnum(): Boolean = hasModifier(JetTokens.ENUM_KEYWORD)
|
||||
public fun isSealed(): Boolean = hasModifier(JetTokens.SEALED_KEYWORD)
|
||||
|
||||
@@ -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<? extends JetClassOrObject> classStub = getStub();
|
||||
if (classStub != null) {
|
||||
return classStub.getName();
|
||||
}
|
||||
|
||||
@@ -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)!!
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user