rename Kt to Kotlin in KtType, KtIcons

This commit is contained in:
Dmitry Jemerov
2015-10-20 16:23:25 +02:00
parent 9d7a8e7696
commit d6a3870101
457 changed files with 2831 additions and 2830 deletions
@@ -22,9 +22,9 @@ import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
public val KtType.nameIfStandardType: Name?
public val KotlinType.nameIfStandardType: Name?
get() {
val descriptor = getConstructor().getDeclarationDescriptor()
@@ -35,7 +35,7 @@ public val KtType.nameIfStandardType: Name?
return null
}
public fun KtType.getJetTypeFqName(printTypeArguments: Boolean): String {
public fun KotlinType.getJetTypeFqName(printTypeArguments: Boolean): String {
val declaration = requireNotNull(getConstructor().getDeclarationDescriptor())
if (declaration is TypeParameterDescriptor) {
return StringUtil.join(declaration.getUpperBounds(), { type -> type.getJetTypeFqName(printTypeArguments) }, "&")
@@ -24,14 +24,14 @@ import org.jetbrains.kotlin.psi.KtDeclaration;
import org.jetbrains.kotlin.psi.KtElement;
import org.jetbrains.kotlin.psi.KtExpression;
import org.jetbrains.kotlin.psi.KtNamedDeclaration;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
import static org.jetbrains.kotlin.diagnostics.PositioningStrategies.*;
import static org.jetbrains.kotlin.diagnostics.Severity.ERROR;
import static org.jetbrains.kotlin.diagnostics.Severity.WARNING;
public interface ErrorsJs {
DiagnosticFactory1<KtElement, KtType> NATIVE_ANNOTATIONS_ALLOWED_ONLY_ON_MEMBER_OR_EXTENSION_FUN = DiagnosticFactory1.create(ERROR, DECLARATION_SIGNATURE_OR_DEFAULT);
DiagnosticFactory1<KtElement, KotlinType> NATIVE_ANNOTATIONS_ALLOWED_ONLY_ON_MEMBER_OR_EXTENSION_FUN = DiagnosticFactory1.create(ERROR, DECLARATION_SIGNATURE_OR_DEFAULT);
DiagnosticFactory1<KtElement, String> NATIVE_INDEXER_KEY_SHOULD_BE_STRING_OR_NUMBER = DiagnosticFactory1.create(ERROR, DECLARATION_SIGNATURE_OR_DEFAULT);
DiagnosticFactory1<KtElement, String> NATIVE_INDEXER_CAN_NOT_HAVE_DEFAULT_ARGUMENTS = DiagnosticFactory1.create(ERROR, DECLARATION_SIGNATURE_OR_DEFAULT);
DiagnosticFactory0<KtDeclaration> NATIVE_GETTER_RETURN_TYPE_SHOULD_BE_NULLABLE = DiagnosticFactory0.create(ERROR, DECLARATION_RETURN_TYPE);
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationWithTarget
import org.jetbrains.kotlin.resolve.constants.ConstantValue
import org.jetbrains.kotlin.serialization.ProtoBuf
import org.jetbrains.kotlin.serialization.deserialization.*
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
class KotlinJavascriptAnnotationAndConstantLoader(
module: ModuleDescriptor
@@ -82,7 +82,7 @@ class KotlinJavascriptAnnotationAndConstantLoader(
override fun loadPropertyConstant(
container: ProtoContainer,
proto: ProtoBuf.Property,
expectedType: KtType
expectedType: KotlinType
): ConstantValue<*>? {
if (!proto.hasExtension(JsProtoBuf.compileTimeValue)) return null
val value = proto.getExtension(JsProtoBuf.compileTimeValue)
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.serialization.AnnotationSerializer
import org.jetbrains.kotlin.serialization.ProtoBuf
import org.jetbrains.kotlin.serialization.SerializerExtension
import org.jetbrains.kotlin.serialization.StringTableImpl
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
public class KotlinJavascriptSerializerExtension : SerializerExtension() {
private val stringTable = StringTableImpl()
@@ -64,7 +64,7 @@ public class KotlinJavascriptSerializerExtension : SerializerExtension() {
}
}
override fun serializeType(type: KtType, proto: ProtoBuf.Type.Builder) {
override fun serializeType(type: KotlinType, proto: ProtoBuf.Type.Builder) {
for (annotation in type.annotations) {
proto.addExtension(JsProtoBuf.typeAnnotation, annotationSerializer.serializeAnnotation(annotation))
}
@@ -48,7 +48,7 @@ import org.jetbrains.kotlin.psi.KtObjectDeclaration
import org.jetbrains.kotlin.psi.KtSecondaryConstructor
import org.jetbrains.kotlin.resolve.BindingContextUtils
import org.jetbrains.kotlin.resolve.DescriptorUtils.*
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeConstructor
import org.jetbrains.kotlin.types.TypeUtils.topologicallySortSuperclassesAndRecordAllInstances
import org.jetbrains.kotlin.utils.identity
@@ -190,7 +190,7 @@ public class ClassTranslator private constructor(
for (type in supertypes) {
supertypeConstructors.add(type.getConstructor())
}
val sortedAllSuperTypes = topologicallySortSuperclassesAndRecordAllInstances(descriptor.getDefaultType(), HashMap<TypeConstructor, Set<KtType>>(), HashSet<TypeConstructor>())
val sortedAllSuperTypes = topologicallySortSuperclassesAndRecordAllInstances(descriptor.getDefaultType(), HashMap<TypeConstructor, Set<KotlinType>>(), HashSet<TypeConstructor>())
val supertypesRefs = ArrayList<JsExpression>()
for (typeConstructor in sortedAllSuperTypes) {
if (supertypeConstructors.contains(typeConstructor)) {
@@ -33,7 +33,7 @@ import org.jetbrains.kotlin.js.translate.initializer.ClassInitializerTranslator;
import org.jetbrains.kotlin.js.translate.utils.BindingUtils;
import org.jetbrains.kotlin.js.translate.utils.TranslationUtils;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
import java.util.List;
@@ -75,7 +75,7 @@ public class DeclarationBodyVisitor extends TranslatorVisitor<Void> {
public Void visitEnumEntry(@NotNull KtEnumEntry enumEntry, TranslationContext data) {
JsExpression jsEnumEntryCreation;
ClassDescriptor descriptor = getClassDescriptor(data.bindingContext(), enumEntry);
List<KtType> supertypes = getSupertypesWithoutFakes(descriptor);
List<KotlinType> supertypes = getSupertypesWithoutFakes(descriptor);
if (enumEntry.getBody() != null || supertypes.size() > 1) {
jsEnumEntryCreation = ClassTranslator.generateClassCreation(enumEntry, data);
} else {
@@ -45,7 +45,7 @@ import org.jetbrains.kotlin.resolve.constants.ConstantValue;
import org.jetbrains.kotlin.resolve.constants.NullValue;
import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator;
import org.jetbrains.kotlin.resolve.inline.InlineUtil;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
import org.jetbrains.kotlin.types.TypeUtils;
import java.util.List;
@@ -77,7 +77,7 @@ public final class ExpressionVisitor extends TranslatorVisitor<JsNode> {
private static JsNode translateConstantExpression(@NotNull KtConstantExpression expression, @NotNull TranslationContext context) {
CompileTimeConstant<?> compileTimeValue = ConstantExpressionEvaluator.getConstant(expression, context.bindingContext());
assert compileTimeValue != null : message(expression, "Expression is not compile time value: " + expression.getText() + " ");
KtType expectedType = context.bindingContext().getType(expression);
KotlinType expectedType = context.bindingContext().getType(expression);
ConstantValue<?> constant = compileTimeValue.toConstantValue(expectedType != null ? expectedType : TypeUtils.NO_EXPECTED_TYPE);
if (constant instanceof NullValue) {
return JsLiteral.NULL;
@@ -362,8 +362,8 @@ public final class ExpressionVisitor extends TranslatorVisitor<JsNode> {
KtTypeReference right = expression.getRight();
assert right != null;
KtType rightType = BindingContextUtils.getNotNull(context.bindingContext(), BindingContext.TYPE, right);
KtType leftType = BindingContextUtils.getTypeNotNull(context.bindingContext(), expression.getLeft());
KotlinType rightType = BindingContextUtils.getNotNull(context.bindingContext(), BindingContext.TYPE, right);
KotlinType leftType = BindingContextUtils.getTypeNotNull(context.bindingContext(), expression.getLeft());
if (TypeUtils.isNullableType(rightType) || !TypeUtils.isNullableType(leftType)) {
return jsExpression.source(expression);
}
@@ -33,7 +33,7 @@ import org.jetbrains.kotlin.psi.KtExpression;
import org.jetbrains.kotlin.psi.KtIsExpression;
import org.jetbrains.kotlin.psi.KtTypeReference;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
import static org.jetbrains.kotlin.js.translate.utils.BindingUtils.getTypeByReference;
import static org.jetbrains.kotlin.js.translate.utils.JsAstUtils.*;
@@ -63,7 +63,7 @@ public final class PatternTranslator extends AbstractTranslator {
@NotNull
public JsExpression translateIsCheck(@NotNull JsExpression subject, @NotNull KtTypeReference typeReference) {
KtType type = BindingUtils.getTypeByReference(bindingContext(), typeReference);
KotlinType type = BindingUtils.getTypeByReference(bindingContext(), typeReference);
JsExpression checkFunReference = getIsTypeCheckCallable(type);
JsInvocation isCheck = new JsInvocation(checkFunReference, subject);
@@ -75,7 +75,7 @@ public final class PatternTranslator extends AbstractTranslator {
}
@NotNull
public JsExpression getIsTypeCheckCallable(@NotNull KtType type) {
public JsExpression getIsTypeCheckCallable(@NotNull KotlinType type) {
JsExpression builtinCheck = getIsTypeCheckCallableForBuiltin(type);
if (builtinCheck != null) return builtinCheck;
@@ -94,7 +94,7 @@ public final class PatternTranslator extends AbstractTranslator {
}
@Nullable
private JsExpression getIsTypeCheckCallableForBuiltin(@NotNull KtType type) {
private JsExpression getIsTypeCheckCallableForBuiltin(@NotNull KotlinType type) {
Name typeName = DescriptorUtilsKt.getNameIfStandardType(type);
if (NamePredicate.STRING.apply(typeName)) {
@@ -147,7 +147,7 @@ public final class PatternTranslator extends AbstractTranslator {
}
@NotNull
private JsNameRef getClassNameReference(@NotNull KtType type) {
private JsNameRef getClassNameReference(@NotNull KotlinType type) {
ClassDescriptor referencedClass = DescriptorUtils.getClassDescriptorForType(type);
return context().getQualifiedReference(referencedClass);
}
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.js.translate.general.Translation;
import org.jetbrains.kotlin.js.translate.intrinsic.functions.factories.TopLevelFIF;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
import java.util.Collections;
@@ -88,7 +88,7 @@ public final class StringTemplateTranslator extends AbstractTranslator {
return;
}
KtType type = context().bindingContext().getType(entryExpression);
KotlinType type = context().bindingContext().getType(entryExpression);
if (type == null || type.isMarkedNullable()) {
append(TopLevelFIF.TO_STRING.apply((JsExpression) null, Collections.singletonList(translatedExpression), context()));
}
@@ -100,7 +100,7 @@ public final class StringTemplateTranslator extends AbstractTranslator {
}
}
private boolean mustCallToString(@NotNull KtType type) {
private boolean mustCallToString(@NotNull KotlinType type) {
Name typeName = DescriptorUtilsKt.getNameIfStandardType(type);
if (typeName != null) {
//TODO: this is a hacky optimization, should use some generic approach
@@ -32,7 +32,7 @@ import org.jetbrains.kotlin.psi.KtDeclaration;
import org.jetbrains.kotlin.psi.KtFile;
import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.resolve.scopes.KtScope;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
import java.util.Collection;
import java.util.List;
@@ -48,7 +48,7 @@ public class JetTestFunctionDetector {
Annotations annotations = functionDescriptor.getAnnotations();
for (AnnotationDescriptor annotation : annotations) {
// TODO ideally we should find the fully qualified name here...
KtType type = annotation.getType();
KotlinType type = annotation.getType();
String name = type.toString();
if (name.equals("Test")) {
return true;
@@ -32,7 +32,7 @@ import org.jetbrains.kotlin.lexer.KtTokens;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt;
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
import java.util.ArrayList;
import java.util.Collections;
@@ -114,7 +114,7 @@ public final class ClassInitializerTranslator extends AbstractTranslator {
}
@NotNull
public JsExpression generateEnumEntryInstanceCreation(@NotNull KtType enumClassType) {
public JsExpression generateEnumEntryInstanceCreation(@NotNull KotlinType enumClassType) {
ResolvedCall<FunctionDescriptor> superCall = getSuperCall();
if (superCall == null) {
@@ -38,7 +38,7 @@ import org.jetbrains.kotlin.psi.KtReferenceExpression;
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver;
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
import java.util.List;
@@ -219,7 +219,7 @@ public final class TopLevelFIF extends CompositeFIF {
@NotNull List<JsExpression> arguments,
@NotNull TranslationContext context
) {
KtType keyType = callInfo.getResolvedCall().getTypeArguments().values().iterator().next();
KotlinType keyType = callInfo.getResolvedCall().getTypeArguments().values().iterator().next();
Name keyTypeName = DescriptorUtilsKt.getNameIfStandardType(keyType);
String collectionClassName = null;
if (keyTypeName != null) {
@@ -37,7 +37,7 @@ import org.jetbrains.kotlin.psi.KtExpression;
import org.jetbrains.kotlin.resolve.bindingContextUtil.BindingContextUtilsKt;
import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt;
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
import org.jetbrains.kotlin.types.TypeUtils;
import org.jetbrains.kotlin.types.expressions.OperatorConventions;
@@ -267,8 +267,8 @@ public final class BinaryOperationTranslator extends AbstractTranslator {
return new JsBinaryOperation(operator, left, right);
}
KtType leftType = context().bindingContext().getType(leftKtExpression);
KtType rightType = context().bindingContext().getType(rightKtExpression);
KotlinType leftType = context().bindingContext().getType(leftKtExpression);
KotlinType rightType = context().bindingContext().getType(rightKtExpression);
if (leftType != null && TypeUtils.isNullableType(leftType) || rightType != null && TypeUtils.isNullableType(rightType)) {
return mayBeWrapWithNegation(TopLevelFIF.KOTLIN_EQUALS.apply(left, Collections.singletonList(right), context()));
@@ -34,7 +34,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt;
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant;
import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
import static org.jetbrains.kotlin.js.translate.general.Translation.translateAsExpression;
import static org.jetbrains.kotlin.js.translate.utils.BindingUtils.getCompileTimeValue;
@@ -55,7 +55,7 @@ public final class UnaryOperationTranslator {
IElementType operationToken = expression.getOperationReference().getReferencedNameElementType();
if (operationToken == KtTokens.EXCLEXCL) {
KtExpression baseExpression = getBaseExpression(expression);
KtType type = BindingContextUtils.getTypeNotNull(context.bindingContext(), baseExpression);
KotlinType type = BindingContextUtils.getTypeNotNull(context.bindingContext(), baseExpression);
JsExpression translatedExpression = translateAsExpression(baseExpression, context);
return type.isMarkedNullable() ? sure(translatedExpression, context) : translatedExpression;
}
@@ -32,7 +32,7 @@ import org.jetbrains.kotlin.js.translate.utils.*
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.ValueArgument
import org.jetbrains.kotlin.resolve.calls.model.*
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import java.util.ArrayList
import java.util.Collections
@@ -336,7 +336,7 @@ public class CallArgumentTranslator private constructor(
}
private fun Map<TypeParameterDescriptor, KtType>.addReifiedTypeArgsTo(
private fun Map<TypeParameterDescriptor, KotlinType>.addReifiedTypeArgsTo(
info: CallArgumentTranslator.ArgumentsInfo,
context: TranslationContext
): CallArgumentTranslator.ArgumentsInfo {
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant;
import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator;
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
import org.jetbrains.kotlin.types.TypeUtils;
import java.util.List;
@@ -90,7 +90,7 @@ public final class BindingUtils {
}
@NotNull
public static KtType getTypeByReference(@NotNull BindingContext context,
public static KotlinType getTypeByReference(@NotNull BindingContext context,
@NotNull KtTypeReference typeReference) {
return BindingContextUtils.getNotNull(context, BindingContext.TYPE, typeReference);
}
@@ -159,7 +159,7 @@ public final class BindingUtils {
@Nullable
public static Object getCompileTimeValue(@NotNull BindingContext context, @NotNull KtExpression expression, @NotNull CompileTimeConstant<?> constant) {
KtType expectedType = context.getType(expression);
KotlinType expectedType = context.getType(expression);
return constant.getValue(expectedType == null ? TypeUtils.NO_EXPECTED_TYPE : expectedType);
}
@@ -204,7 +204,7 @@ public final class BindingUtils {
}
@NotNull
public static KtType getTypeForExpression(@NotNull BindingContext context,
public static KotlinType getTypeForExpression(@NotNull BindingContext context,
@NotNull KtExpression expression) {
return BindingContextUtils.getTypeNotNull(context, expression);
}
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.js.translate.utils.mutator.Mutator;
import org.jetbrains.kotlin.psi.KtDeclarationWithBody;
import org.jetbrains.kotlin.psi.KtExpression;
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
import java.util.ArrayList;
import java.util.List;
@@ -100,7 +100,7 @@ public final class FunctionBodyTranslator extends AbstractTranslator {
}
private boolean mustAddReturnToGeneratedFunctionBody() {
KtType functionReturnType = descriptor.getReturnType();
KotlinType functionReturnType = descriptor.getReturnType();
assert functionReturnType != null : "Function return typed type must be resolved.";
return (!declaration.hasBlockBody()) && (!KotlinBuiltIns.isUnit(functionReturnType));
}
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.psi.KtExpression;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
import org.jetbrains.kotlin.resolve.scopes.receivers.ThisReceiver;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
import org.jetbrains.kotlin.util.OperatorNameConventions;
import java.util.Collection;
@@ -80,11 +80,11 @@ public final class JsDescriptorUtils {
}
@NotNull
public static List<KtType> getSupertypesWithoutFakes(ClassDescriptor descriptor) {
Collection<KtType> supertypes = descriptor.getTypeConstructor().getSupertypes();
return ContainerUtil.filter(supertypes, new Condition<KtType>() {
public static List<KotlinType> getSupertypesWithoutFakes(ClassDescriptor descriptor) {
Collection<KotlinType> supertypes = descriptor.getTypeConstructor().getSupertypes();
return ContainerUtil.filter(supertypes, new Condition<KotlinType>() {
@Override
public boolean value(KtType type) {
public boolean value(KotlinType type) {
ClassDescriptor classDescriptor = getClassDescriptorForType(type);
return !FAKE_CLASSES.contains(getFqNameSafe(classDescriptor).asString()) &&
@@ -161,7 +161,7 @@ public final class JsDescriptorUtils {
@Nullable
public static Name getNameIfStandardType(@NotNull KtExpression expression, @NotNull TranslationContext context) {
KtType type = context.bindingContext().getType(expression);
KotlinType type = context.bindingContext().getType(expression);
return type != null ? DescriptorUtilsKt.getNameIfStandardType(type) : null;
}
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.js.translate.context.TranslationContext;
import org.jetbrains.kotlin.js.translate.general.Translation;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
import java.util.ArrayList;
import java.util.Collections;
@@ -224,7 +224,7 @@ public final class TranslationUtils {
if (operationDescriptor == null || !(operationDescriptor instanceof FunctionDescriptor)) return true;
KtType returnType = operationDescriptor.getReturnType();
KotlinType returnType = operationDescriptor.getReturnType();
if (returnType != null && (KotlinBuiltIns.isChar(returnType) || KotlinBuiltIns.isLong(returnType))) return false;
if (context.intrinsics().getFunctionIntrinsic((FunctionDescriptor) operationDescriptor).exists()) return true;