Catch InvalidModuleException from getModality() in icon provider

Related to KT-20986
This commit is contained in:
Mikhail Glukhikh
2017-11-17 17:02:47 +03:00
parent dce7377099
commit 4c583c5a61
@@ -77,6 +77,15 @@ public final class KotlinDescriptorIconProvider {
return null; return null;
} }
private static Modality getModalitySafe(@NotNull MemberDescriptor descriptor) {
try {
return descriptor.getModality();
}
catch (InvalidModuleException ex) {
return Modality.FINAL;
}
}
private static Icon getBaseIcon(@NotNull DeclarationDescriptor descriptor) { private static Icon getBaseIcon(@NotNull DeclarationDescriptor descriptor) {
if (descriptor instanceof PackageFragmentDescriptor || descriptor instanceof PackageViewDescriptor) { if (descriptor instanceof PackageFragmentDescriptor || descriptor instanceof PackageViewDescriptor) {
return PlatformIcons.PACKAGE_ICON; return PlatformIcons.PACKAGE_ICON;
@@ -84,13 +93,13 @@ public final class KotlinDescriptorIconProvider {
if (descriptor instanceof FunctionDescriptor) { if (descriptor instanceof FunctionDescriptor) {
FunctionDescriptor functionDescriptor = (FunctionDescriptor) descriptor; FunctionDescriptor functionDescriptor = (FunctionDescriptor) descriptor;
if (functionDescriptor.getExtensionReceiverParameter() != null) { if (functionDescriptor.getExtensionReceiverParameter() != null) {
return Modality.ABSTRACT == functionDescriptor.getModality() return Modality.ABSTRACT == getModalitySafe(functionDescriptor)
? KotlinIcons.ABSTRACT_EXTENSION_FUNCTION ? KotlinIcons.ABSTRACT_EXTENSION_FUNCTION
: KotlinIcons.EXTENSION_FUNCTION; : KotlinIcons.EXTENSION_FUNCTION;
} }
if (descriptor.getContainingDeclaration() instanceof ClassDescriptor) { if (descriptor.getContainingDeclaration() instanceof ClassDescriptor) {
return Modality.ABSTRACT == functionDescriptor.getModality() return Modality.ABSTRACT == getModalitySafe(functionDescriptor)
? PlatformIcons.ABSTRACT_METHOD_ICON ? PlatformIcons.ABSTRACT_METHOD_ICON
: PlatformIcons.METHOD_ICON; : PlatformIcons.METHOD_ICON;
} }
@@ -112,7 +121,7 @@ public final class KotlinDescriptorIconProvider {
case OBJECT: case OBJECT:
return KotlinIcons.OBJECT; return KotlinIcons.OBJECT;
case CLASS: case CLASS:
return Modality.ABSTRACT == classDescriptor.getModality() ? return Modality.ABSTRACT == getModalitySafe(classDescriptor) ?
KotlinIcons.ABSTRACT_CLASS : KotlinIcons.ABSTRACT_CLASS :
KotlinIcons.CLASS; KotlinIcons.CLASS;
default: default: