Move utility method to DescriptorUtils and make it more general
This commit is contained in:
@@ -238,6 +238,14 @@ public class DescriptorUtils {
|
||||
return isKindOf(descriptor, ClassKind.ENUM_ENTRY);
|
||||
}
|
||||
|
||||
public static boolean isObject(@NotNull DeclarationDescriptor classifier) {
|
||||
if (classifier instanceof ClassDescriptor) {
|
||||
ClassDescriptor clazz = (ClassDescriptor) classifier;
|
||||
return clazz.getKind().isObject();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isEnumClass(@NotNull DeclarationDescriptor descriptor) {
|
||||
return isKindOf(descriptor, ClassKind.ENUM_CLASS);
|
||||
}
|
||||
@@ -475,4 +483,4 @@ public class DescriptorUtils {
|
||||
assert classObject != null : "Enum class should have a class object: " + enumClass;
|
||||
return classObject.getDefaultType().getMemberScope();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.LabelName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||
@@ -309,7 +310,7 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
public void addClassifierDescriptor(@NotNull ClassifierDescriptor classDescriptor) {
|
||||
checkMayWrite();
|
||||
|
||||
if (isObject(classDescriptor)) {
|
||||
if (DescriptorUtils.isObject(classDescriptor)) {
|
||||
throw new IllegalStateException("must not be object: " + classDescriptor);
|
||||
}
|
||||
|
||||
@@ -497,19 +498,6 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
return declaredDescriptorsAccessibleBySimpleName.values();
|
||||
}
|
||||
|
||||
private static boolean isObject(@NotNull ClassifierDescriptor classifier) {
|
||||
if (classifier instanceof ClassDescriptor) {
|
||||
ClassDescriptor clazz = (ClassDescriptor) classifier;
|
||||
return clazz.getKind().isObject();
|
||||
}
|
||||
else if (classifier instanceof TypeParameterDescriptor) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException("unknown classifier: " + classifier);
|
||||
}
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
@Override
|
||||
protected void printAdditionalScopeStructure(@NotNull Printer p) {
|
||||
|
||||
Reference in New Issue
Block a user