JetClass.isEnum() introduced
This commit is contained in:
@@ -107,7 +107,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
isAnnotation = true;
|
||||
signature.getInterfaces().add("java/lang/annotation/Annotation");
|
||||
}
|
||||
else if (jetClass.hasModifier(JetTokens.ENUM_KEYWORD)) {
|
||||
else if (jetClass.isEnum()) {
|
||||
isAbstract = hasAbstractMembers(descriptor);
|
||||
isEnum = true;
|
||||
}
|
||||
|
||||
@@ -142,6 +142,15 @@ public class JetClass extends JetTypeParameterListOwnerStub<PsiJetClassStub> imp
|
||||
return findChildByType(JetTokens.TRAIT_KEYWORD) != null;
|
||||
}
|
||||
|
||||
public boolean isEnum() {
|
||||
PsiJetClassStub stub = getStub();
|
||||
if (stub != null) {
|
||||
return stub.isEnumClass();
|
||||
}
|
||||
|
||||
return hasModifier(JetTokens.ENUM_KEYWORD);
|
||||
}
|
||||
|
||||
public boolean isAnnotation() {
|
||||
PsiJetClassStub stub = getStub();
|
||||
if (stub != null) {
|
||||
|
||||
@@ -33,6 +33,8 @@ public interface PsiJetClassStub extends NamedStub<JetClass> {
|
||||
|
||||
boolean isAnnotation();
|
||||
|
||||
boolean isEnumClass();
|
||||
|
||||
boolean isEnumEntry();
|
||||
|
||||
@NotNull
|
||||
|
||||
+4
-2
@@ -55,7 +55,7 @@ public class JetClassElementType extends JetStubElementType<PsiJetClassStub, Jet
|
||||
FqName fqName = JetPsiUtil.getFQName(psi);
|
||||
boolean isEnumEntry = psi instanceof JetEnumEntry;
|
||||
return new PsiJetClassStubImpl(getStubType(isEnumEntry), parentStub, fqName != null ? fqName.getFqName() : null, psi.getName(),
|
||||
psi.getSuperNames(), psi.isTrait(), isEnumEntry, psi.isAnnotation());
|
||||
psi.getSuperNames(), psi.isTrait(), psi.isEnum(), isEnumEntry, psi.isAnnotation());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,6 +63,7 @@ public class JetClassElementType extends JetStubElementType<PsiJetClassStub, Jet
|
||||
dataStream.writeName(stub.getName());
|
||||
dataStream.writeName(stub.getQualifiedName());
|
||||
dataStream.writeBoolean(stub.isTrait());
|
||||
dataStream.writeBoolean(stub.isEnumClass());
|
||||
dataStream.writeBoolean(stub.isEnumEntry());
|
||||
dataStream.writeBoolean(stub.isAnnotation());
|
||||
|
||||
@@ -78,6 +79,7 @@ public class JetClassElementType extends JetStubElementType<PsiJetClassStub, Jet
|
||||
StringRef name = dataStream.readName();
|
||||
StringRef qualifiedName = dataStream.readName();
|
||||
boolean isTrait = dataStream.readBoolean();
|
||||
boolean isEnumClass = dataStream.readBoolean();
|
||||
boolean isEnumEntry = dataStream.readBoolean();
|
||||
boolean isAnnotation = dataStream.readBoolean();
|
||||
|
||||
@@ -87,7 +89,7 @@ public class JetClassElementType extends JetStubElementType<PsiJetClassStub, Jet
|
||||
superNames[i] = dataStream.readName();
|
||||
}
|
||||
|
||||
return new PsiJetClassStubImpl(getStubType(isEnumEntry), parentStub, qualifiedName, name, superNames, isTrait, isEnumEntry, isAnnotation);
|
||||
return new PsiJetClassStubImpl(getStubType(isEnumEntry), parentStub, qualifiedName, name, superNames, isTrait, isEnumClass, isEnumEntry, isAnnotation);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ import org.jetbrains.jet.plugin.JetLanguage;
|
||||
import java.io.IOException;
|
||||
|
||||
public class JetFileElementType extends IStubFileElementType<PsiJetFileStub> {
|
||||
public static final int STUB_VERSION = 19;
|
||||
public static final int STUB_VERSION = 20;
|
||||
|
||||
public JetFileElementType() {
|
||||
super("jet.FILE", JetLanguage.INSTANCE);
|
||||
|
||||
+16
-3
@@ -35,6 +35,7 @@ public class PsiJetClassStubImpl extends StubBase<JetClass> implements PsiJetCla
|
||||
private final StringRef name;
|
||||
private final StringRef[] superNames;
|
||||
private final boolean isTrait;
|
||||
private final boolean isEnumClass;
|
||||
private final boolean isEnumEntry;
|
||||
private final boolean isAnnotation;
|
||||
|
||||
@@ -44,9 +45,9 @@ public class PsiJetClassStubImpl extends StubBase<JetClass> implements PsiJetCla
|
||||
@Nullable final String qualifiedName,
|
||||
String name,
|
||||
List<String> superNames,
|
||||
boolean isTrait, boolean isEnumEntry, boolean isAnnotation) {
|
||||
boolean isTrait, boolean isEnumClass, boolean isEnumEntry, boolean isAnnotation) {
|
||||
this(type, parent, StringRef.fromString(qualifiedName), StringRef.fromString(name), wrapStrings(superNames),
|
||||
isTrait, isEnumEntry, isAnnotation);
|
||||
isTrait, isEnumClass, isEnumEntry, isAnnotation);
|
||||
}
|
||||
|
||||
public PsiJetClassStubImpl(
|
||||
@@ -55,13 +56,16 @@ public class PsiJetClassStubImpl extends StubBase<JetClass> implements PsiJetCla
|
||||
StringRef qualifiedName,
|
||||
StringRef name,
|
||||
StringRef[] superNames,
|
||||
boolean isTrait, boolean isEnumEntry,
|
||||
boolean isTrait,
|
||||
boolean isEnumClass,
|
||||
boolean isEnumEntry,
|
||||
boolean isAnnotation) {
|
||||
super(parent, type);
|
||||
this.qualifiedName = qualifiedName;
|
||||
this.name = name;
|
||||
this.superNames = superNames;
|
||||
this.isTrait = isTrait;
|
||||
this.isEnumClass = isEnumClass;
|
||||
this.isEnumEntry = isEnumEntry;
|
||||
this.isAnnotation = isAnnotation;
|
||||
}
|
||||
@@ -89,6 +93,11 @@ public class PsiJetClassStubImpl extends StubBase<JetClass> implements PsiJetCla
|
||||
return isAnnotation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnumClass() {
|
||||
return isEnumClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnumEntry() {
|
||||
return isEnumEntry;
|
||||
@@ -114,6 +123,10 @@ public class PsiJetClassStubImpl extends StubBase<JetClass> implements PsiJetCla
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("PsiJetClassStubImpl[");
|
||||
|
||||
if (isEnumClass()) {
|
||||
builder.append("enumClass ");
|
||||
}
|
||||
|
||||
if (isEnumEntry()) {
|
||||
builder.append("enumEntry ");
|
||||
}
|
||||
|
||||
@@ -208,8 +208,8 @@ public class TypeHierarchyResolver {
|
||||
@NotNull
|
||||
private static ClassKind getClassKind(@NotNull JetClass jetClass) {
|
||||
if (jetClass.isTrait()) return ClassKind.TRAIT;
|
||||
if (jetClass.hasModifier(JetTokens.ANNOTATION_KEYWORD)) return ClassKind.ANNOTATION_CLASS;
|
||||
if (jetClass.hasModifier(JetTokens.ENUM_KEYWORD)) return ClassKind.ENUM_CLASS;
|
||||
if (jetClass.isAnnotation()) return ClassKind.ANNOTATION_CLASS;
|
||||
if (jetClass.isEnum()) return ClassKind.ENUM_CLASS;
|
||||
return ClassKind.CLASS;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.jetbrains.jet.lang.resolve.lazy.data;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassKind;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -36,10 +35,10 @@ public class JetClassInfo extends JetClassOrObjectInfo<JetClass> {
|
||||
else if (element.isTrait()) {
|
||||
this.kind = ClassKind.TRAIT;
|
||||
}
|
||||
else if (element.hasModifier(JetTokens.ANNOTATION_KEYWORD)) {
|
||||
else if (element.isAnnotation()) {
|
||||
this.kind = ClassKind.ANNOTATION_CLASS;
|
||||
}
|
||||
else if (element.hasModifier(JetTokens.ENUM_KEYWORD)) {
|
||||
else if (element.isEnum()) {
|
||||
this.kind = ClassKind.ENUM_CLASS;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -130,7 +130,7 @@ public class JetIconProvider extends IconProvider {
|
||||
return JetIcons.TRAIT;
|
||||
}
|
||||
|
||||
Icon icon = jetClass.hasModifier(JetTokens.ENUM_KEYWORD) ? PlatformIcons.ENUM_ICON : JetIcons.CLASS;
|
||||
Icon icon = jetClass.isEnum() ? PlatformIcons.ENUM_ICON : JetIcons.CLASS;
|
||||
if (jetClass instanceof JetEnumEntry) {
|
||||
JetEnumEntry enumEntry = (JetEnumEntry) jetClass;
|
||||
if (enumEntry.getPrimaryConstructorParameterList() == null) {
|
||||
|
||||
@@ -141,7 +141,7 @@ public class JetStubsTest extends LightCodeInsightFixtureTestCase {
|
||||
public void testSimpleEnumBuild() {
|
||||
doBuildTest("enum class Test { First\n Second\n }",
|
||||
"PsiJetFileStubImpl[package=]\n" +
|
||||
" CLASS:PsiJetClassStubImpl[name=Test fqn=Test superNames=[]]\n" +
|
||||
" CLASS:PsiJetClassStubImpl[enumClass name=Test fqn=Test superNames=[]]\n" +
|
||||
" TYPE_PARAMETER_LIST:PsiJetTypeParameterListStubImpl\n" +
|
||||
" ENUM_ENTRY:PsiJetClassStubImpl[enumEntry name=First fqn=Test.First superNames=[]]\n" +
|
||||
" ENUM_ENTRY:PsiJetClassStubImpl[enumEntry name=Second fqn=Test.Second superNames=[]]\n"
|
||||
|
||||
Reference in New Issue
Block a user