extracted method 'getInnerClassByName'
This commit is contained in:
@@ -387,4 +387,13 @@ public class DescriptorUtils {
|
||||
Collections.sort(resultList);
|
||||
return resultList;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ClassDescriptor getInnerClassByName(@NotNull ClassDescriptor classDescriptor, @NotNull String innerClassName) {
|
||||
ClassifierDescriptor classifier = classDescriptor.getDefaultType().getMemberScope().getClassifier(Name.identifier(innerClassName));
|
||||
assert classifier instanceof ClassDescriptor :
|
||||
"Inner class " + innerClassName + " in " + classDescriptor + " should be instance of ClassDescriptor, but was: "
|
||||
+ (classifier == null ? "null" : classifier.getClass());
|
||||
return (ClassDescriptor) classifier;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTraceContext;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.TopDownAnalyzer;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
@@ -428,14 +429,14 @@ public class JetStandardLibrary {
|
||||
|
||||
@NotNull
|
||||
public ClassDescriptor getMapEntry() {
|
||||
ClassifierDescriptor entry = getMap().getDefaultType().getMemberScope().getClassifier(Name.identifier("Entry"));
|
||||
ClassifierDescriptor entry = DescriptorUtils.getInnerClassByName(getMap(), "Entry");
|
||||
assert entry instanceof ClassDescriptor;
|
||||
return (ClassDescriptor) entry;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassDescriptor getMutableMapEntry() {
|
||||
ClassifierDescriptor entry = getMutableMap().getDefaultType().getMemberScope().getClassifier(Name.identifier("MutableEntry"));
|
||||
ClassifierDescriptor entry = DescriptorUtils.getInnerClassByName(getMutableMap(), "MutableEntry");
|
||||
assert entry instanceof ClassDescriptor;
|
||||
return (ClassDescriptor) entry;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user