refactor initStdClasses()

This commit is contained in:
Alexander Udalov
2012-08-27 18:10:19 +04:00
parent cfbab55a43
commit 9be4f63735
@@ -23,7 +23,6 @@ import com.intellij.psi.PsiFileFactory;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.ClassDescriptor; import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor; import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.lang.psi.JetFile;
@@ -164,19 +163,19 @@ public class JetStandardLibrary {
if (libraryScope == null) { if (libraryScope == null) {
this.libraryScope = JetStandardClasses.STANDARD_CLASSES_NAMESPACE.getMemberScope(); this.libraryScope = JetStandardClasses.STANDARD_CLASSES_NAMESPACE.getMemberScope();
this.numberClass = (ClassDescriptor) libraryScope.getClassifier(Name.identifier("Number")); this.numberClass = getStdClassByName("Number");
this.stringClass = (ClassDescriptor) libraryScope.getClassifier(Name.identifier("String")); this.stringClass = getStdClassByName("String");
this.charSequenceClass = (ClassDescriptor) libraryScope.getClassifier(Name.identifier("CharSequence")); this.charSequenceClass = getStdClassByName("CharSequence");
this.arrayClass = (ClassDescriptor) libraryScope.getClassifier(Name.identifier("Array")); this.arrayClass = getStdClassByName("Array");
this.throwableClass = (ClassDescriptor) libraryScope.getClassifier(Name.identifier("Throwable")); this.throwableClass = getStdClassByName("Throwable");
this.enumClass = (ClassDescriptor) libraryScope.getClassifier(Name.identifier("Enum")); this.enumClass = getStdClassByName("Enum");
this.volatileClass = (ClassDescriptor) libraryScope.getClassifier(Name.identifier("volatile")); this.volatileClass = getStdClassByName("volatile");
this.iterableClass = (ClassDescriptor) libraryScope.getClassifier(Name.identifier("Iterable")); this.iterableClass = getStdClassByName("Iterable");
this.iteratorClass = (ClassDescriptor) libraryScope.getClassifier(Name.identifier("Iterator")); this.iteratorClass = getStdClassByName("Iterator");
this.mutableIterableClass = (ClassDescriptor) libraryScope.getClassifier(Name.identifier("MutableIterable")); this.mutableIterableClass = getStdClassByName("MutableIterable");
this.mutableIteratorClass = (ClassDescriptor) libraryScope.getClassifier(Name.identifier("MutableIterator")); this.mutableIteratorClass = getStdClassByName("MutableIterator");
this.comparableClass = (ClassDescriptor) libraryScope.getClassifier(Name.identifier("Comparable")); this.comparableClass = getStdClassByName("Comparable");
this.stringType = new JetTypeImpl(getString()); this.stringType = new JetTypeImpl(getString());
this.tuple0Type = new JetTypeImpl(JetStandardClasses.getTuple(0)); this.tuple0Type = new JetTypeImpl(JetStandardClasses.getTuple(0));
@@ -194,6 +193,13 @@ public class JetStandardLibrary {
} }
} }
@NotNull
private ClassDescriptor getStdClassByName(String className) {
ClassDescriptor classDescriptor = (ClassDescriptor) libraryScope.getClassifier(Name.identifier(className));
assert classDescriptor != null : "Standard class not found: " + className;
return classDescriptor;
}
private void makePrimitive(PrimitiveType primitiveType) { private void makePrimitive(PrimitiveType primitiveType) {
ClassDescriptor clazz = (ClassDescriptor) libraryScope.getClassifier(primitiveType.getTypeName()); ClassDescriptor clazz = (ClassDescriptor) libraryScope.getClassifier(primitiveType.getTypeName());
ClassDescriptor arrayClazz = (ClassDescriptor) libraryScope.getClassifier(primitiveType.getArrayTypeName()); ClassDescriptor arrayClazz = (ClassDescriptor) libraryScope.getClassifier(primitiveType.getArrayTypeName());