refactored std.* package to be kotlin.*. Due to KT-1381 I had to move the functions from kotlin.test into the stdlib for now (I made them not depend on JUnit for now)

This commit is contained in:
James Strachan
2012-03-03 12:11:06 +00:00
parent 4a53e468fe
commit eb3aac9acb
162 changed files with 454 additions and 324 deletions
@@ -53,6 +53,8 @@ import static org.jetbrains.jet.lang.resolve.BindingContext.REFERENCE_TARGET;
*/
public abstract class ExpectedResolveData {
protected static final String STANDARD_PREFIX = "kotlin::";
private static class Position {
private final PsiElement element;
@@ -212,7 +214,7 @@ public abstract class ExpectedResolveData {
}
JetReferenceExpression reference = getAncestorOfType(JetReferenceExpression.class, element);
if (expected == null && name.startsWith("std::")) {
if (expected == null && name.startsWith(STANDARD_PREFIX)) {
DeclarationDescriptor expectedDescriptor = nameToDescriptor.get(name);
JetTypeReference typeReference = getAncestorOfType(JetTypeReference.class, element);
if (expectedDescriptor != null) {
@@ -225,7 +227,7 @@ public abstract class ExpectedResolveData {
JetType actualType = bindingContext.get(BindingContext.TYPE, typeReference);
assertNotNull("Type " + name + " not resolved for reference " + name, actualType);
ClassifierDescriptor expectedClass = lib.getLibraryScope().getClassifier(name.substring(5));
ClassifierDescriptor expectedClass = lib.getLibraryScope().getClassifier(name.substring(STANDARD_PREFIX.length()));
assertNotNull("Expected class not found: " + name);
assertSame("Type resolution mismatch: ", expectedClass.getTypeConstructor(), actualType.getConstructor());
continue;
@@ -282,8 +284,9 @@ public abstract class ExpectedResolveData {
JetType expressionType = bindingContext.get(BindingContext.EXPRESSION_TYPE, expression);
TypeConstructor expectedTypeConstructor;
if (typeName.startsWith("std::")) {
ClassifierDescriptor expectedClass = lib.getLibraryScope().getClassifier(typeName.substring(5));
if (typeName.startsWith(STANDARD_PREFIX)) {
String name = typeName.substring(STANDARD_PREFIX.length());
ClassifierDescriptor expectedClass = lib.getLibraryScope().getClassifier(name);
assertNotNull("Expected class not found: " + typeName, expectedClass);
expectedTypeConstructor = expectedClass.getTypeConstructor();
@@ -64,13 +64,13 @@ public class JetResolveTest extends ExtensibleResolveTestCase {
Project project = getProject();
JetStandardLibrary lib = JetStandardLibrary.getInstance();
Map<String, DeclarationDescriptor> nameToDescriptor = new HashMap<String, DeclarationDescriptor>();
nameToDescriptor.put("std::Int.plus(Int)", standardFunction(lib.getInt(), "plus", lib.getIntType()));
nameToDescriptor.put("kotlin::Int.plus(Int)", standardFunction(lib.getInt(), "plus", lib.getIntType()));
FunctionDescriptor descriptorForGet = standardFunction(lib.getArray(), Collections.singletonList(new TypeProjection(lib.getIntType())), "get", lib.getIntType());
nameToDescriptor.put("std::Array.get(Int)", descriptorForGet.getOriginal());
nameToDescriptor.put("std::Int.compareTo(Double)", standardFunction(lib.getInt(), "compareTo", lib.getDoubleType()));
nameToDescriptor.put("kotlin::Array.get(Int)", descriptorForGet.getOriginal());
nameToDescriptor.put("kotlin::Int.compareTo(Double)", standardFunction(lib.getInt(), "compareTo", lib.getDoubleType()));
@NotNull
FunctionDescriptor descriptorForSet = standardFunction(lib.getArray(), Collections.singletonList(new TypeProjection(lib.getIntType())), "set", lib.getIntType(), lib.getIntType());
nameToDescriptor.put("std::Array.set(Int, Int)", descriptorForSet.getOriginal());
nameToDescriptor.put("kotlin::Array.set(Int, Int)", descriptorForSet.getOriginal());
Map<String, PsiElement> nameToDeclaration = new HashMap<String, PsiElement>();
PsiClass java_util_Collections = findClass("java.util.Collections");
@@ -147,7 +147,7 @@ public class JetResolveTest extends ExtensibleResolveTestCase {
}
}
}
throw new IllegalArgumentException("Not found: std::" + classDescriptor.getName() + "." + name + "(" + parameterTypeList + ")");
throw new IllegalArgumentException("Not found: kotlin::" + classDescriptor.getName() + "." + name + "(" + parameterTypeList + ")");
}
@Override