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
@@ -40,7 +40,7 @@ import org.jetbrains.kotlin.resolve.scopes.getDescriptorsFiltered
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
import org.jetbrains.kotlin.resolve.scopes.utils.getDescriptorsFiltered
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeUtils
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
import org.jetbrains.kotlin.utils.addIfNotNull
@@ -222,8 +222,8 @@ public class ReferenceVariantsHelper(
}
private fun MutableSet<DeclarationDescriptor>.processAll(
implicitReceiverTypes: Collection<KtType>,
receiverTypes: Collection<KtType>,
implicitReceiverTypes: Collection<KotlinType>,
receiverTypes: Collection<KotlinType>,
resolutionScope: KtScope,
callType: CallType<*>,
kindFilter: DescriptorKindFilter,
@@ -235,8 +235,8 @@ public class ReferenceVariantsHelper(
}
private fun MutableSet<DeclarationDescriptor>.addMemberExtensions(
dispatchReceiverTypes: Collection<KtType>,
extensionReceiverTypes: Collection<KtType>,
dispatchReceiverTypes: Collection<KotlinType>,
extensionReceiverTypes: Collection<KotlinType>,
callType: CallType<*>,
kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean
@@ -250,7 +250,7 @@ public class ReferenceVariantsHelper(
}
private fun MutableSet<DeclarationDescriptor>.addNonExtensionMembers(
receiverTypes: Collection<KtType>,
receiverTypes: Collection<KotlinType>,
kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean,
constructorFilter: (ClassDescriptor) -> Boolean
@@ -287,7 +287,7 @@ public class ReferenceVariantsHelper(
private fun MutableSet<DeclarationDescriptor>.addScopeAndSyntheticExtensions(
resolutionScope: KtScope,
receiverTypes: Collection<KtType>,
receiverTypes: Collection<KotlinType>,
callType: CallType<*>,
kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean
@@ -320,7 +320,7 @@ public class ReferenceVariantsHelper(
}
}
private fun getQualifierRuntimeType(receiver: KtExpression): KtType? {
private fun getQualifierRuntimeType(receiver: KtExpression): KotlinType? {
val type = context.getType(receiver)
if (type != null && TypeUtils.canHaveSubtypes(KotlinTypeChecker.DEFAULT, type)) {
val evaluator = receiver.getContainingFile().getCopyableUserData(KtCodeFragment.RUNTIME_TYPE_EVALUATOR)
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.SmartCastManager
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindExclude
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.utils.addToStdlib.singletonOrEmptyList
public sealed class CallType<TReceiver : KtElement?>(val descriptorKindFilter: DescriptorKindFilter) {
@@ -185,7 +185,7 @@ public fun CallTypeAndReceiver<*, *>.receiverTypes(
position: KtExpression,
moduleDescriptor: ModuleDescriptor,
predictableSmartCastsOnly: Boolean
): Collection<KtType>? {
): Collection<KotlinType>? {
val receiverExpression: KtExpression?
when (this) {
is CallTypeAndReceiver.CALLABLE_REFERENCE -> {
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl
import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind
import org.jetbrains.kotlin.resolve.calls.inference.registerTypeVariables
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeSubstitutor
import org.jetbrains.kotlin.types.Variance
import org.jetbrains.kotlin.types.typeUtil.*
@@ -51,7 +51,7 @@ fun FuzzyType.isAlmostEverything(): Boolean {
}
class FuzzyType(
val type: KtType,
val type: KotlinType,
freeParameters: Collection<TypeParameterDescriptor>
) {
public val freeParameters: Set<TypeParameterDescriptor>
@@ -71,7 +71,7 @@ class FuzzyType(
override fun hashCode() = type.hashCode()
private fun MutableSet<TypeParameterDescriptor>.addUsedTypeParameters(type: KtType) {
private fun MutableSet<TypeParameterDescriptor>.addUsedTypeParameters(type: KotlinType) {
val typeParameter = type.getConstructor().getDeclarationDescriptor() as? TypeParameterDescriptor
if (typeParameter != null && add(typeParameter)) {
typeParameter.getLowerBounds().forEach { addUsedTypeParameters(it) }
@@ -91,10 +91,10 @@ class FuzzyType(
public fun checkIsSuperTypeOf(otherType: FuzzyType): TypeSubstitutor?
= matchedSubstitutor(otherType, MatchKind.IS_SUPERTYPE)
public fun checkIsSubtypeOf(otherType: KtType): TypeSubstitutor?
public fun checkIsSubtypeOf(otherType: KotlinType): TypeSubstitutor?
= checkIsSubtypeOf(FuzzyType(otherType, emptyList()))
public fun checkIsSuperTypeOf(otherType: KtType): TypeSubstitutor?
public fun checkIsSuperTypeOf(otherType: KotlinType): TypeSubstitutor?
= checkIsSuperTypeOf(FuzzyType(otherType, emptyList()))
private enum class MatchKind {
@@ -106,7 +106,7 @@ class FuzzyType(
if (type.isError()) return null
if (otherType.type.isError()) return null
fun KtType.checkInheritance(otherType: KtType): Boolean {
fun KotlinType.checkInheritance(otherType: KotlinType): Boolean {
return when (matchKind) {
MatchKind.IS_SUBTYPE -> this.isSubtypeOf(otherType)
MatchKind.IS_SUPERTYPE -> otherType.isSubtypeOf(this)
@@ -20,16 +20,16 @@ import org.jetbrains.kotlin.renderer.DescriptorRenderer
import org.jetbrains.kotlin.renderer.DescriptorRendererModifier
import org.jetbrains.kotlin.renderer.NameShortness
import org.jetbrains.kotlin.renderer.OverrideRenderingPolicy
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.isDynamic
import org.jetbrains.kotlin.types.typeUtil.builtIns
public object IdeDescriptorRenderers {
public val APPROXIMATE_FLEXIBLE_TYPES: (KtType) -> KtType = { approximateFlexibleTypes(it, true) }
public val APPROXIMATE_FLEXIBLE_TYPES: (KotlinType) -> KotlinType = { approximateFlexibleTypes(it, true) }
public val APPROXIMATE_FLEXIBLE_TYPES_IN_ARGUMENTS: (KtType) -> KtType = { approximateFlexibleTypes(it, false) }
public val APPROXIMATE_FLEXIBLE_TYPES_IN_ARGUMENTS: (KotlinType) -> KotlinType = { approximateFlexibleTypes(it, false) }
private fun unwrapAnonymousType(type: KtType): KtType {
private fun unwrapAnonymousType(type: KotlinType): KotlinType {
if (type.isDynamic()) return type
val classifier = type.constructor.declarationDescriptor
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.bindingContextUtil.getReferenceTargets
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
import org.jetbrains.kotlin.resolve.descriptorUtil.getImportableDescriptor
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
public val DeclarationDescriptor.importableFqName: FqName?
get() {
@@ -51,7 +51,7 @@ public fun DeclarationDescriptor.canBeReferencedViaImport(): Boolean {
}
}
public fun KtType.canBeReferencedViaImport(): Boolean {
public fun KotlinType.canBeReferencedViaImport(): Boolean {
val descriptor = getConstructor().getDeclarationDescriptor()
return descriptor != null && descriptor.canBeReferencedViaImport()
}
@@ -34,7 +34,7 @@ import org.jetbrains.kotlin.resolve.scopes.utils.getClassifier
import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.types.typeUtil.*
public fun approximateFlexibleTypes(jetType: KtType, outermost: Boolean = true): KtType {
public fun approximateFlexibleTypes(jetType: KotlinType, outermost: Boolean = true): KotlinType {
if (jetType.isDynamic()) return jetType
if (jetType.isFlexible()) {
val flexible = jetType.flexibility()
@@ -60,7 +60,7 @@ public fun approximateFlexibleTypes(jetType: KtType, outermost: Boolean = true):
return approximation
}
return KtTypeImpl.create(
return KotlinTypeImpl.create(
jetType.getAnnotations(),
jetType.getConstructor(),
jetType.isMarkedNullable(),
@@ -69,15 +69,15 @@ public fun approximateFlexibleTypes(jetType: KtType, outermost: Boolean = true):
)
}
public fun KtType.isAnnotatedReadOnly(): Boolean = hasAnnotationMaybeExternal(JETBRAINS_READONLY_ANNOTATION)
public fun KtType.isAnnotatedNotNull(): Boolean = hasAnnotationMaybeExternal(JETBRAINS_NOT_NULL_ANNOTATION)
public fun KtType.isAnnotatedNullable(): Boolean = hasAnnotationMaybeExternal(JETBRAINS_NULLABLE_ANNOTATION)
public fun KotlinType.isAnnotatedReadOnly(): Boolean = hasAnnotationMaybeExternal(JETBRAINS_READONLY_ANNOTATION)
public fun KotlinType.isAnnotatedNotNull(): Boolean = hasAnnotationMaybeExternal(JETBRAINS_NOT_NULL_ANNOTATION)
public fun KotlinType.isAnnotatedNullable(): Boolean = hasAnnotationMaybeExternal(JETBRAINS_NULLABLE_ANNOTATION)
private fun KtType.hasAnnotationMaybeExternal(fqName: FqName) = with (getAnnotations()) {
private fun KotlinType.hasAnnotationMaybeExternal(fqName: FqName) = with (getAnnotations()) {
findAnnotation(fqName) ?: findExternalAnnotation(fqName)
} != null
fun KtType.isResolvableInScope(scope: LexicalScope?, checkTypeParameters: Boolean): Boolean {
fun KotlinType.isResolvableInScope(scope: LexicalScope?, checkTypeParameters: Boolean): Boolean {
if (canBeReferencedViaImport()) return true
val descriptor = getConstructor().getDeclarationDescriptor()
@@ -87,13 +87,13 @@ fun KtType.isResolvableInScope(scope: LexicalScope?, checkTypeParameters: Boolea
return scope != null && scope.getClassifier(descriptor.name, NoLookupLocation.FROM_IDE) == descriptor
}
public fun KtType.approximateWithResolvableType(scope: LexicalScope?, checkTypeParameters: Boolean): KtType {
public fun KotlinType.approximateWithResolvableType(scope: LexicalScope?, checkTypeParameters: Boolean): KotlinType {
if (isError() || isResolvableInScope(scope, checkTypeParameters)) return this
return supertypes().firstOrNull { it.isResolvableInScope(scope, checkTypeParameters) }
?: builtIns.anyType
}
public fun KtType.anonymousObjectSuperTypeOrNull(): KtType? {
public fun KotlinType.anonymousObjectSuperTypeOrNull(): KotlinType? {
val classDescriptor = constructor.declarationDescriptor
if (classDescriptor != null && DescriptorUtils.isAnonymousObject(classDescriptor)) {
return immediateSupertypes().firstOrNull() ?: classDescriptor.builtIns.anyType
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.resolve.scopes.KtScope
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
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.types.typeUtil.TypeNullability
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
import org.jetbrains.kotlin.types.typeUtil.nullability
@@ -73,7 +73,7 @@ public fun CallableDescriptor.substituteExtensionIfCallable(
}
public fun CallableDescriptor.substituteExtensionIfCallable(
receiverTypes: Collection<KtType>,
receiverTypes: Collection<KotlinType>,
callType: CallType<*>
): Collection<CallableDescriptor> {
if (!callType.descriptorKindFilter.accepts(this)) return listOf()
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.types.checker.TypeCheckingProcedure
import java.util.LinkedHashMap
public fun getTypeSubstitution(baseType: KtType, derivedType: KtType): LinkedHashMap<TypeConstructor, TypeProjection>? {
public fun getTypeSubstitution(baseType: KotlinType, derivedType: KotlinType): LinkedHashMap<TypeConstructor, TypeProjection>? {
val substitutedType = TypeCheckingProcedure.findCorrespondingSupertype(derivedType, baseType) ?: return null
val substitution = LinkedHashMap<TypeConstructor, TypeProjection>(substitutedType.getArguments().size())
@@ -55,6 +55,6 @@ public fun getCallableSubstitutor(
return getCallableSubstitution(baseCallable, derivedCallable)?.let { TypeSubstitutor.create(it) }
}
public fun getTypeSubstitutor(baseType: KtType, derivedType: KtType): TypeSubstitutor? {
public fun getTypeSubstitutor(baseType: KotlinType, derivedType: KotlinType): TypeSubstitutor? {
return getTypeSubstitution(baseType, derivedType)?.let { TypeSubstitutor.create(it) }
}
@@ -84,7 +84,7 @@ public final class JetDescriptorIconProvider {
if (descriptor instanceof FunctionDescriptor) {
FunctionDescriptor functionDescriptor = (FunctionDescriptor) descriptor;
if (functionDescriptor.getExtensionReceiverParameter() != null) {
return KtIcons.EXTENSION_FUNCTION;
return KotlinIcons.EXTENSION_FUNCTION;
}
if (descriptor.getContainingDeclaration() instanceof ClassDescriptor) {
@@ -96,38 +96,38 @@ public final class JetDescriptorIconProvider {
}
}
else {
return KtIcons.FUNCTION;
return KotlinIcons.FUNCTION;
}
}
if (descriptor instanceof ClassDescriptor) {
switch (((ClassDescriptor) descriptor).getKind()) {
case INTERFACE:
return KtIcons.TRAIT;
return KotlinIcons.TRAIT;
case ENUM_CLASS:
return KtIcons.ENUM;
return KotlinIcons.ENUM;
case ENUM_ENTRY:
return KtIcons.ENUM;
return KotlinIcons.ENUM;
case ANNOTATION_CLASS:
return PlatformIcons.ANNOTATION_TYPE_ICON;
case OBJECT:
return KtIcons.OBJECT;
return KotlinIcons.OBJECT;
case CLASS:
return KtIcons.CLASS;
return KotlinIcons.CLASS;
default:
LOG.warn("No icon for descriptor: " + descriptor);
return null;
}
}
if (descriptor instanceof ValueParameterDescriptor) {
return KtIcons.PARAMETER;
return KotlinIcons.PARAMETER;
}
if (descriptor instanceof LocalVariableDescriptor) {
return ((VariableDescriptor) descriptor).isVar() ? KtIcons.VAR : KtIcons.VAL;
return ((VariableDescriptor) descriptor).isVar() ? KotlinIcons.VAR : KotlinIcons.VAL;
}
if (descriptor instanceof PropertyDescriptor) {
return ((VariableDescriptor) descriptor).isVar() ? KtIcons.FIELD_VAR : KtIcons.FIELD_VAL;
return ((VariableDescriptor) descriptor).isVar() ? KotlinIcons.FIELD_VAR : KotlinIcons.FIELD_VAL;
}
if (descriptor instanceof TypeParameterDescriptor) {
@@ -62,7 +62,7 @@ public class JetIconProvider extends IconProvider implements DumbAware {
if (psiElement instanceof KtFile) {
KtFile file = (KtFile) psiElement;
KtClassOrObject mainClass = getMainClass(file);
return mainClass != null && file.getDeclarations().size() == 1 ? getIcon(mainClass, flags) : KtIcons.FILE;
return mainClass != null && file.getDeclarations().size() == 1 ? getIcon(mainClass, flags) : KotlinIcons.FILE;
}
Icon result = getBaseIcon(psiElement);
@@ -102,7 +102,7 @@ public class JetIconProvider extends IconProvider implements DumbAware {
}
if (psiElement instanceof KotlinLightClassForFacade) {
return KtIcons.FILE;
return KotlinIcons.FILE;
}
if (psiElement instanceof KotlinLightClassForDecompiledDeclaration) {
@@ -112,7 +112,7 @@ public class JetIconProvider extends IconProvider implements DumbAware {
}
else {
//TODO (light classes for decompiled files): correct presentation
return KtIcons.CLASS;
return KotlinIcons.CLASS;
}
}
@@ -122,7 +122,7 @@ public class JetIconProvider extends IconProvider implements DumbAware {
if (psiElement instanceof KtNamedFunction) {
if (((KtFunction) psiElement).getReceiverTypeReference() != null) {
return KtIcons.EXTENSION_FUNCTION;
return KotlinIcons.EXTENSION_FUNCTION;
}
if (PsiTreeUtil.getParentOfType(psiElement, KtNamedDeclaration.class) instanceof KtClass) {
@@ -134,41 +134,41 @@ public class JetIconProvider extends IconProvider implements DumbAware {
}
}
else {
return KtIcons.FUNCTION;
return KotlinIcons.FUNCTION;
}
}
if (psiElement instanceof KtFunctionLiteral) return KtIcons.LAMBDA;
if (psiElement instanceof KtFunctionLiteral) return KotlinIcons.LAMBDA;
if (psiElement instanceof KtClass) {
KtClass ktClass = (KtClass) psiElement;
if (ktClass.isInterface()) {
return KtIcons.TRAIT;
return KotlinIcons.TRAIT;
}
Icon icon = ktClass.isEnum() ? KtIcons.ENUM : KtIcons.CLASS;
Icon icon = ktClass.isEnum() ? KotlinIcons.ENUM : KotlinIcons.CLASS;
if (ktClass instanceof KtEnumEntry) {
KtEnumEntry enumEntry = (KtEnumEntry) ktClass;
if (enumEntry.getPrimaryConstructorParameterList() == null) {
icon = KtIcons.ENUM;
icon = KotlinIcons.ENUM;
}
}
return icon;
}
if (psiElement instanceof KtObjectDeclaration) {
return KtIcons.OBJECT;
return KotlinIcons.OBJECT;
}
if (psiElement instanceof KtParameter) {
KtParameter parameter = (KtParameter) psiElement;
if (KtPsiUtil.getClassIfParameterIsProperty(parameter) != null) {
return parameter.isMutable() ? KtIcons.FIELD_VAR : KtIcons.FIELD_VAL;
return parameter.isMutable() ? KotlinIcons.FIELD_VAR : KotlinIcons.FIELD_VAL;
}
return KtIcons.PARAMETER;
return KotlinIcons.PARAMETER;
}
if (psiElement instanceof KtProperty) {
KtProperty property = (KtProperty) psiElement;
return property.isVar() ? KtIcons.FIELD_VAR : KtIcons.FIELD_VAL;
return property.isVar() ? KotlinIcons.FIELD_VAR : KotlinIcons.FIELD_VAL;
}
return null;
@@ -21,7 +21,7 @@ import com.intellij.util.PlatformIcons;
import javax.swing.*;
public interface KtIcons {
public interface KotlinIcons {
Icon SMALL_LOGO = IconLoader.getIcon("/org/jetbrains/kotlin/idea/icons/kotlin.png");
Icon KOTLIN_LOGO_24 = IconLoader.getIcon("/org/jetbrains/kotlin/idea/icons/kotlin24.png");
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.resolve.BindingTraceContext
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
import org.jetbrains.kotlin.resolve.scopes.KtScope
import org.jetbrains.kotlin.resolve.scopes.utils.asLexicalScope
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeUtils
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices
import org.jetbrains.kotlin.types.expressions.JetTypeInfo
@@ -37,7 +37,7 @@ public fun KtExpression.computeTypeInfoInContext(
contextExpression: KtExpression = this,
trace: BindingTrace = BindingTraceContext(),
dataFlowInfo: DataFlowInfo = DataFlowInfo.EMPTY,
expectedType: KtType = TypeUtils.NO_EXPECTED_TYPE,
expectedType: KotlinType = TypeUtils.NO_EXPECTED_TYPE,
isStatement: Boolean = false
): JetTypeInfo {
PreliminaryDeclarationVisitor.createForExpression(this, trace)
@@ -51,7 +51,7 @@ public fun KtExpression.analyzeInContext(
contextExpression: KtExpression = this,
trace: BindingTrace = BindingTraceContext(),
dataFlowInfo: DataFlowInfo = DataFlowInfo.EMPTY,
expectedType: KtType = TypeUtils.NO_EXPECTED_TYPE,
expectedType: KotlinType = TypeUtils.NO_EXPECTED_TYPE,
isStatement: Boolean = false
): BindingContext {
computeTypeInfoInContext(scope, contextExpression, trace, dataFlowInfo, expectedType, isStatement)
@@ -64,7 +64,7 @@ public fun KtExpression.computeTypeInContext(
contextExpression: KtExpression = this,
trace: BindingTrace = BindingTraceContext(),
dataFlowInfo: DataFlowInfo = DataFlowInfo.EMPTY,
expectedType: KtType = TypeUtils.NO_EXPECTED_TYPE
): KtType? {
expectedType: KotlinType = TypeUtils.NO_EXPECTED_TYPE
): KotlinType? {
return computeTypeInfoInContext(scope, contextExpression, trace, dataFlowInfo, expectedType).type
}
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.serialization.deserialization.AnnotationAndConstantL
import org.jetbrains.kotlin.serialization.deserialization.NameResolver
import org.jetbrains.kotlin.serialization.deserialization.ProtoContainer
import org.jetbrains.kotlin.serialization.js.JsProtoBuf
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
public class AnnotationLoaderForKotlinJavaScriptStubBuilder() : AnnotationAndConstantLoader<ClassId, Unit, ClassIdWithTarget> {
@@ -79,6 +79,6 @@ public class AnnotationLoaderForKotlinJavaScriptStubBuilder() : AnnotationAndCon
override fun loadPropertyConstant(
container: ProtoContainer,
proto: ProtoBuf.Property,
expectedType: KtType
expectedType: KotlinType
) {}
}
@@ -33,7 +33,7 @@ import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
import java.util.List;
import java.util.Set;
@@ -173,7 +173,7 @@ public class MemberMatching {
}
String declarationTypeText = typeReference.getText();
KtType typeToRender = varargInDeclaration ? descriptorParameter.getVarargElementType() : descriptorParameter.getType();
KotlinType typeToRender = varargInDeclaration ? descriptorParameter.getVarargElementType() : descriptorParameter.getType();
assert typeToRender != null;
String descriptorParameterText = DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(typeToRender);
if (!declarationTypeText.equals(descriptorParameterText)) {
@@ -221,9 +221,9 @@ public class MemberMatching {
}
Set<String> descriptorUpperBounds = Sets.newHashSet(ContainerUtil.map(
descriptor.getUpperBounds(), new Function<KtType, String>() {
descriptor.getUpperBounds(), new Function<KotlinType, String>() {
@Override
public String fun(KtType type) {
public String fun(KotlinType type) {
return DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(type);
}
}));
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt;
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall;
import org.jetbrains.kotlin.resolve.calls.tasks.DynamicCallsKt;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
import org.jetbrains.kotlin.types.TypeUtils;
public class FunctionsHighlightingVisitor extends AfterAnalysisHighlightingVisitor {
@@ -103,13 +103,13 @@ public class FunctionsHighlightingVisitor extends AfterAnalysisHighlightingVisit
return false;
}
KtType defaultType = ((ClassDescriptor) parent).getDefaultType();
KotlinType defaultType = ((ClassDescriptor) parent).getDefaultType();
if (KotlinBuiltIns.isFunctionOrExtensionFunctionType(defaultType)) {
return true;
}
for (KtType supertype : TypeUtils.getAllSupertypes(defaultType)) {
for (KotlinType supertype : TypeUtils.getAllSupertypes(defaultType)) {
if (KotlinBuiltIns.isFunctionOrExtensionFunctionType(supertype)) {
return true;
}
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.diagnostics.rendering.TabledDescriptorRenderer.Table
import org.jetbrains.kotlin.idea.highlighter.renderersUtil.RenderersUtilKt;
import org.jetbrains.kotlin.renderer.*;
import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPosition;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
import java.util.Collections;
import java.util.Iterator;
@@ -43,7 +43,7 @@ public class HtmlTabledDescriptorRenderer extends TabledDescriptorRenderer {
@NotNull
@Override
public Renderer<KtType> getTypeRenderer() {
public Renderer<KotlinType> getTypeRenderer() {
return IdeRenderers.HTML_RENDER_TYPE;
}
@@ -117,8 +117,8 @@ public class HtmlTabledDescriptorRenderer extends TabledDescriptorRenderer {
}
private void renderFunctionArguments(
@Nullable KtType receiverType,
@NotNull List<KtType> argumentTypes,
@Nullable KotlinType receiverType,
@NotNull List<KotlinType> argumentTypes,
Predicate<ConstraintPosition> isErrorPosition,
StringBuilder result
) {
@@ -141,8 +141,8 @@ public class HtmlTabledDescriptorRenderer extends TabledDescriptorRenderer {
td(result, RenderersUtilKt.renderStrong("("));
int i = 0;
for (Iterator<KtType> iterator = argumentTypes.iterator(); iterator.hasNext(); ) {
KtType argumentType = iterator.next();
for (Iterator<KotlinType> iterator = argumentTypes.iterator(); iterator.hasNext(); ) {
KotlinType argumentType = iterator.next();
boolean error = false;
if (isErrorPosition.apply(VALUE_PARAMETER_POSITION.position(i))) {
error = true;
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.resolve.MemberComparator
import org.jetbrains.kotlin.resolve.calls.inference.InferenceErrorData
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ConflictingJvmDeclarationsData
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
public object IdeRenderers {
public val HTML_AMBIGUOUS_CALLS: Renderer<Collection<ResolvedCall<*>>> = Renderer {
@@ -36,7 +36,7 @@ public object IdeRenderers {
.joinToString("") { "<li>" + DescriptorRenderer.HTML.render(it) + "</li>" }
}
public val HTML_RENDER_TYPE: Renderer<KtType> = Renderer {
public val HTML_RENDER_TYPE: Renderer<KotlinType> = Renderer {
DescriptorRenderer.HTML.renderType(it)
}
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.resolve.calls.tasks.DynamicCallsKt;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
import org.jetbrains.kotlin.types.expressions.CaptureKind;
import static org.jetbrains.kotlin.resolve.BindingContext.*;
@@ -69,7 +69,7 @@ class VariablesHighlightingVisitor extends AfterAnalysisHighlightingVisitor {
@Override
public void visitExpression(@NotNull KtExpression expression) {
KtType smartCast = bindingContext.get(SMARTCAST, expression);
KotlinType smartCast = bindingContext.get(SMARTCAST, expression);
if (smartCast != null) {
holder.createInfoAnnotation(expression, "Smart cast to " + DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(smartCast)).setTextAttributes(
JetHighlightingColors.SMART_CAST_VALUE);
@@ -45,7 +45,7 @@ import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
import org.jetbrains.kotlin.util.capitalizeDecapitalize.decapitalizeSmart
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstance
@@ -313,7 +313,7 @@ abstract class CompletionSession(protected val configuration: CompletionSessionC
)
}
private fun createLookupElementFactory(callType: CallType<*>?, receiverTypes: Collection<KtType>?): LookupElementFactory {
private fun createLookupElementFactory(callType: CallType<*>?, receiverTypes: Collection<KotlinType>?): LookupElementFactory {
val contextVariablesProvider = {
nameExpression?.let {
referenceVariantsHelper.getReferenceVariants(it, DescriptorKindFilter.VARIABLES, { true }, CallTypeAndReceiver.DEFAULT)
@@ -327,7 +327,7 @@ abstract class CompletionSession(protected val configuration: CompletionSessionC
insertHandlerProvider, contextVariablesProvider)
}
private fun detectCallTypeAndReceiverTypes(): Pair<CallTypeAndReceiver<*, *>, Collection<KtType>?> {
private fun detectCallTypeAndReceiverTypes(): Pair<CallTypeAndReceiver<*, *>, Collection<KotlinType>?> {
if (nameExpression == null) {
return CallTypeAndReceiver.UNKNOWN to null
}
@@ -26,7 +26,7 @@ import com.intellij.psi.PsiDocumentManager
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor
import org.jetbrains.kotlin.idea.KtIcons
import org.jetbrains.kotlin.idea.KotlinIcons
import org.jetbrains.kotlin.idea.completion.handlers.CastReceiverInsertHandler
import org.jetbrains.kotlin.idea.completion.handlers.WithTailInsertHandler
import org.jetbrains.kotlin.idea.core.getResolutionScope
@@ -43,7 +43,7 @@ import org.jetbrains.kotlin.renderer.render
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.inline.InlineUtil
import org.jetbrains.kotlin.resolve.scopes.utils.asJetScope
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.typeUtil.TypeNullability
import org.jetbrains.kotlin.types.typeUtil.nullability
import java.util.*
@@ -247,7 +247,7 @@ fun returnExpressionItems(bindingContext: BindingContext, position: KtElement):
return result
}
private fun KtDeclarationWithBody.returnType(bindingContext: BindingContext): KtType? {
private fun KtDeclarationWithBody.returnType(bindingContext: BindingContext): KotlinType? {
val callable = bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, this] as? CallableDescriptor ?: return null
return callable.getReturnType()
}
@@ -310,12 +310,12 @@ fun breakOrContinueExpressionItems(position: KtElement, breakOrContinue: String)
return result
}
fun LookupElementFactory.createLookupElementForType(type: KtType): LookupElement? {
fun LookupElementFactory.createLookupElementForType(type: KotlinType): LookupElement? {
if (type.isError()) return null
if (KotlinBuiltIns.isExactFunctionOrExtensionFunctionType(type)) {
val text = IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_IN_TYPES.renderType(type)
val baseLookupElement = LookupElementBuilder.create(text).withIcon(KtIcons.LAMBDA)
val baseLookupElement = LookupElementBuilder.create(text).withIcon(KotlinIcons.LAMBDA)
return BaseTypeLookupElement(type, baseLookupElement)
}
else {
@@ -339,7 +339,7 @@ fun LookupElementFactory.createLookupElementForType(type: KtType): LookupElement
}
}
private open class BaseTypeLookupElement(type: KtType, baseLookupElement: LookupElement) : LookupElementDecorator<LookupElement>(baseLookupElement) {
private open class BaseTypeLookupElement(type: KotlinType, baseLookupElement: LookupElement) : LookupElementDecorator<LookupElement>(baseLookupElement) {
val fullText = IdeDescriptorRenderers.SOURCE_CODE.renderType(type)
override fun equals(other: Any?) = other is BaseTypeLookupElement && fullText == other.fullText
@@ -38,7 +38,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getCall
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.resolve.calls.util.DelegatingCall
import org.jetbrains.kotlin.resolve.descriptorUtil.hasDefaultValue
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeSubstitutor
import org.jetbrains.kotlin.types.TypeUtils
import org.jetbrains.kotlin.types.typeUtil.containsError
@@ -97,15 +97,15 @@ class ExpectedInfo(
constructor(fuzzyType: FuzzyType, expectedName: String?, tail: Tail?, itemOptions: ItemOptions = ItemOptions.DEFAULT, additionalData: ExpectedInfo.AdditionalData? = null)
: this(ByExpectedTypeFilter(fuzzyType), expectedName, tail, itemOptions, additionalData)
constructor(type: KtType, expectedName: String?, tail: Tail?, itemOptions: ItemOptions = ItemOptions.DEFAULT, additionalData: ExpectedInfo.AdditionalData? = null)
constructor(type: KotlinType, expectedName: String?, tail: Tail?, itemOptions: ItemOptions = ItemOptions.DEFAULT, additionalData: ExpectedInfo.AdditionalData? = null)
: this(FuzzyType(type, emptyList()), expectedName, tail, itemOptions, additionalData)
fun matchingSubstitutor(descriptorType: FuzzyType): TypeSubstitutor? = filter.matchingSubstitutor(descriptorType)
fun matchingSubstitutor(descriptorType: KtType): TypeSubstitutor? = matchingSubstitutor(FuzzyType(descriptorType, emptyList()))
fun matchingSubstitutor(descriptorType: KotlinType): TypeSubstitutor? = matchingSubstitutor(FuzzyType(descriptorType, emptyList()))
companion object {
fun createForArgument(type: KtType, expectedName: String?, tail: Tail?, argumentData: ArgumentPositionData, itemOptions: ItemOptions = ItemOptions.DEFAULT): ExpectedInfo {
fun createForArgument(type: KotlinType, expectedName: String?, tail: Tail?, argumentData: ArgumentPositionData, itemOptions: ItemOptions = ItemOptions.DEFAULT): ExpectedInfo {
return ExpectedInfo(FuzzyType(type, argumentData.function.typeParameters), expectedName, tail, itemOptions, argumentData)
}
@@ -113,7 +113,7 @@ class ExpectedInfo(
return ExpectedInfo(ByTypeFilter.None, null, null/*TODO?*/, ItemOptions.DEFAULT, argumentData)
}
fun createForReturnValue(type: KtType?, callable: CallableDescriptor): ExpectedInfo {
fun createForReturnValue(type: KotlinType?, callable: CallableDescriptor): ExpectedInfo {
val filter = if (type != null) ByExpectedTypeFilter(FuzzyType(type, emptyList())) else ByTypeFilter.All
return ExpectedInfo(filter, callable.name.asString(), null, additionalData = ReturnValueAdditionalData(callable))
}
@@ -223,7 +223,7 @@ class ExpectedInfos(
return results
}
private fun calculateForArgument(call: Call, callExpectedType: KtType, argument: ValueArgument): Collection<ExpectedInfo> {
private fun calculateForArgument(call: Call, callExpectedType: KotlinType, argument: ValueArgument): Collection<ExpectedInfo> {
val argumentIndex = call.getValueArguments().indexOf(argument)
assert(argumentIndex >= 0) {
"Could not find argument '$argument(${argument.asElement().text})' among arguments of call: $call"
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.resolve.TypeResolver
import org.jetbrains.kotlin.resolve.scopes.LexicalScopeImpl
import org.jetbrains.kotlin.resolve.scopes.utils.memberScopeAsFileScope
import org.jetbrains.kotlin.types.IndexedParametersSubstitution
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.SubstitutionUtils
import org.jetbrains.kotlin.types.Variance
import java.util.*
@@ -41,13 +41,13 @@ public class HeuristicSignatures(
private val project: Project,
private val typeResolver: TypeResolver
) {
public fun correctedParameterType(function: FunctionDescriptor, parameter: ValueParameterDescriptor): KtType? {
public fun correctedParameterType(function: FunctionDescriptor, parameter: ValueParameterDescriptor): KotlinType? {
val parameterIndex = function.getValueParameters().indexOf(parameter)
assert(parameterIndex >= 0)
return correctedParameterType(function, parameterIndex)
}
private fun correctedParameterType(function: FunctionDescriptor, parameterIndex: Int): KtType? {
private fun correctedParameterType(function: FunctionDescriptor, parameterIndex: Int): KotlinType? {
val ownerType = function.getDispatchReceiverParameter()?.getType() ?: return null
val superFunctions = function.getOverriddenDescriptors()
@@ -74,7 +74,7 @@ public class HeuristicSignatures(
}
}
private fun typeFromText(text: String, typeParameters: Collection<TypeParameterDescriptor>): KtType {
private fun typeFromText(text: String, typeParameters: Collection<TypeParameterDescriptor>): KotlinType {
val typeRef = KtPsiFactory(project).createType(text)
val rootPackagesScope = SubpackagesScope(moduleDescriptor, FqName.ROOT).memberScopeAsFileScope()
val scope = LexicalScopeImpl(rootPackagesScope, moduleDescriptor, false, null, "Root packages + type parameters") {
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.idea.completion.handlers.*
import org.jetbrains.kotlin.idea.util.CallType
import org.jetbrains.kotlin.idea.util.fuzzyReturnType
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import java.util.*
class InsertHandlerProvider(
@@ -85,7 +85,7 @@ class InsertHandlerProvider(
val potentiallyInferred = HashSet<TypeParameterDescriptor>()
fun addPotentiallyInferred(type: KtType) {
fun addPotentiallyInferred(type: KotlinType) {
val descriptor = type.constructor.declarationDescriptor as? TypeParameterDescriptor
if (descriptor != null && descriptor in typeParameters) {
potentiallyInferred.add(descriptor)
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.idea.util.CallTypeAndReceiver
import org.jetbrains.kotlin.idea.util.FuzzyType
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.types.KtTypeImpl
import org.jetbrains.kotlin.types.KotlinTypeImpl
import org.jetbrains.kotlin.types.TypeProjectionImpl
import org.jetbrains.kotlin.types.TypeSubstitutor
import org.jetbrains.kotlin.types.typeUtil.isBooleanOrNullableBoolean
@@ -92,7 +92,7 @@ object KeywordValues {
val qualifierType = bindingContext[BindingContext.TYPE, callTypeAndReceiver.receiver]
if (qualifierType != null) {
val kClassDescriptor = resolutionFacade.getFrontendService(ReflectionTypes::class.java).kClass
val classLiteralType = KtTypeImpl.create(Annotations.EMPTY, kClassDescriptor, false, listOf(TypeProjectionImpl(qualifierType)))
val classLiteralType = KotlinTypeImpl.create(Annotations.EMPTY, kClassDescriptor, false, listOf(TypeProjectionImpl(qualifierType)))
val kClassTypes = listOf(FuzzyType(classLiteralType, emptyList()))
val kClassMatcher = { info: ExpectedInfo -> kClassTypes.matchExpectedInfo(info) }
consumer.consume("class", kClassMatcher, SmartCompletionItemPriority.CLASS_LITERAL) {
@@ -104,7 +104,7 @@ object KeywordValues {
.singleOrNull() as? ClassDescriptor
if (javaLangClassDescriptor != null) {
val javaLangClassType = KtTypeImpl.create(Annotations.EMPTY, javaLangClassDescriptor, false, listOf(TypeProjectionImpl(qualifierType)))
val javaLangClassType = KotlinTypeImpl.create(Annotations.EMPTY, javaLangClassDescriptor, false, listOf(TypeProjectionImpl(qualifierType)))
val javaClassTypes = listOf(FuzzyType(javaLangClassType, emptyList()))
val javaClassMatcher = { info: ExpectedInfo -> javaClassTypes.matchExpectedInfo(info) }
consumer.consume("class", javaClassMatcher, SmartCompletionItemPriority.CLASS_LITERAL) {
@@ -38,13 +38,13 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.hasDefaultValue
import org.jetbrains.kotlin.resolve.descriptorUtil.isExtension
import org.jetbrains.kotlin.synthetic.SamAdapterExtensionFunctionDescriptor
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeUtils
import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf
class LookupElementFactory(
private val resolutionFacade: ResolutionFacade,
private val receiverTypes: Collection<KtType>?,
private val receiverTypes: Collection<KotlinType>?,
private val callType: CallType<*>?,
private val isInStringTemplateAfterDollar: Boolean,
public val insertHandlerProvider: InsertHandlerProvider,
@@ -104,7 +104,7 @@ class LookupElementFactory(
}
}
private fun createFunctionCallElementWithLambda(descriptor: FunctionDescriptor, parameterType: KtType, explicitLambdaParameters: Boolean, useReceiverTypes: Boolean): LookupElement {
private fun createFunctionCallElementWithLambda(descriptor: FunctionDescriptor, parameterType: KotlinType, explicitLambdaParameters: Boolean, useReceiverTypes: Boolean): LookupElement {
var lookupElement = createLookupElement(descriptor, useReceiverTypes)
val inputTypeArguments = (insertHandlerProvider.insertHandler(descriptor) as KotlinFunctionInsertHandler.Normal).inputTypeArguments
val lambdaInfo = GenerateLambdaInfo(parameterType, explicitLambdaParameters)
@@ -20,7 +20,7 @@ import com.intellij.codeInsight.completion.InsertHandler
import com.intellij.codeInsight.completion.InsertionContext
import com.intellij.codeInsight.lookup.LookupElement
import com.intellij.codeInsight.lookup.LookupElementBuilder
import org.jetbrains.kotlin.idea.KtIcons
import org.jetbrains.kotlin.idea.KotlinIcons
import org.jetbrains.kotlin.idea.completion.handlers.WithTailInsertHandler
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.KtCallElement
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.psi.KtValueArgument
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
import org.jetbrains.kotlin.renderer.DescriptorRenderer
import org.jetbrains.kotlin.renderer.render
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import java.util.*
object NamedArgumentCompletion {
@@ -45,7 +45,7 @@ object NamedArgumentCompletion {
}
public fun complete(collector: LookupElementsCollector, expectedInfos: Collection<ExpectedInfo>) {
val nameToParameterType = HashMap<Name, MutableSet<KtType>>()
val nameToParameterType = HashMap<Name, MutableSet<KotlinType>>()
for (expectedInfo in expectedInfos) {
val argumentData = expectedInfo.additionalData as? ArgumentPositionData.Positional ?: continue
for (parameter in argumentData.namedArgumentCandidates) {
@@ -59,7 +59,7 @@ object NamedArgumentCompletion {
val lookupElement = LookupElementBuilder.create(nameString)
.withPresentableText("$nameString =")
.withTailText(" $typeText")
.withIcon(KtIcons.PARAMETER)
.withIcon(KotlinIcons.PARAMETER)
.withInsertHandler(NamedArgumentInsertHandler(name))
.assignPriority(ItemPriority.NAMED_PARAMETER)
collector.addElement(lookupElement)
@@ -43,7 +43,7 @@ import org.jetbrains.kotlin.psi.psiUtil.forEachDescendantOfType
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
import org.jetbrains.kotlin.resolve.scopes.utils.getDescriptorsFiltered
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import java.util.*
class ParameterNameAndTypeCompletion(
@@ -152,7 +152,7 @@ class ParameterNameAndTypeCompletion(
}
}
private fun KtType.isVisible(visibilityFilter: (DeclarationDescriptor) -> Boolean): Boolean {
private fun KotlinType.isVisible(visibilityFilter: (DeclarationDescriptor) -> Boolean): Boolean {
if (isError()) return false
val classifier = getConstructor().getDeclarationDescriptor() ?: return false
return visibilityFilter(classifier) && getArguments().all { it.isStarProjection || it.getType().isVisible(visibilityFilter) }
@@ -175,7 +175,7 @@ class ParameterNameAndTypeCompletion(
= lookupElementFactory.createLookupElementForJavaClass(psiClass, qualifyNestedClasses = true)
}
private class ArbitraryType(private val type: KtType) : Type(IdeDescriptorRenderers.SOURCE_CODE.renderType(type)) {
private class ArbitraryType(private val type: KotlinType) : Type(IdeDescriptorRenderers.SOURCE_CODE.renderType(type)) {
override fun createTypeLookupElement(lookupElementFactory: LookupElementFactory)
= lookupElementFactory.createLookupElementForType(type)
}
@@ -33,7 +33,7 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
import org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability
import org.jetbrains.kotlin.resolve.scopes.KtScope
import org.jetbrains.kotlin.resolve.scopes.receivers.ThisReceiver
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
import java.util.HashMap
@@ -49,18 +49,18 @@ class SmartCastCalculator(
private val entityToSmartCastInfo: Map<Any, SmartCastInfo>
= processDataFlowInfo(bindingContext.getDataFlowInfo(expression), bindingContext[BindingContext.RESOLUTION_SCOPE, expression], receiver)
fun types(descriptor: VariableDescriptor): Collection<KtType> {
fun types(descriptor: VariableDescriptor): Collection<KotlinType> {
val type = descriptor.returnType ?: return emptyList()
return entityType(descriptor, type)
}
fun types(thisReceiverParameter: ReceiverParameterDescriptor): Collection<KtType> {
fun types(thisReceiverParameter: ReceiverParameterDescriptor): Collection<KotlinType> {
val type = thisReceiverParameter.type
val thisReceiver = thisReceiverParameter.value as? ThisReceiver ?: return listOf(type)
return entityType(thisReceiver, type)
}
private fun entityType(entity: Any, ownType: KtType): Collection<KtType> {
private fun entityType(entity: Any, ownType: KotlinType): Collection<KotlinType> {
val smartCastInfo = entityToSmartCastInfo[entity] ?: return listOf(ownType)
var types = smartCastInfo.types + ownType
@@ -72,7 +72,7 @@ class SmartCastCalculator(
return types
}
private data class SmartCastInfo(var types: Collection<KtType>, var notNull: Boolean) {
private data class SmartCastInfo(var types: Collection<KotlinType>, var notNull: Boolean) {
constructor() : this(emptyList(), false)
}
@@ -35,9 +35,9 @@ import org.jetbrains.kotlin.idea.util.application.executeWriteCommand
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
fun insertLambdaTemplate(context: InsertionContext, placeholderRange: TextRange, lambdaType: KtType) {
fun insertLambdaTemplate(context: InsertionContext, placeholderRange: TextRange, lambdaType: KotlinType) {
val explicitParameterTypes = needExplicitParameterTypes(context, placeholderRange, lambdaType)
// we start template later to not interfere with insertion of tail type
@@ -64,14 +64,14 @@ fun insertLambdaTemplate(context: InsertionContext, placeholderRange: TextRange,
}
}
fun lambdaPresentation(lambdaType: KtType?): String {
fun lambdaPresentation(lambdaType: KotlinType?): String {
if (lambdaType == null) return "{...}"
val parameterTypes = functionParameterTypes(lambdaType)
val parametersPresentation = parameterTypes.map { IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_IN_TYPES.renderType(it) }.joinToString(", ")
return "{ $parametersPresentation -> ... }"
}
private fun needExplicitParameterTypes(context: InsertionContext, placeholderRange: TextRange, lambdaType: KtType): Boolean {
private fun needExplicitParameterTypes(context: InsertionContext, placeholderRange: TextRange, lambdaType: KotlinType): Boolean {
PsiDocumentManager.getInstance(context.getProject()).commitAllDocuments()
val file = context.getFile() as KtFile
val expression = PsiTreeUtil.findElementOfClassAtRange(file, placeholderRange.getStartOffset(), placeholderRange.getEndOffset(), javaClass<KtExpression>())
@@ -92,7 +92,7 @@ private fun needExplicitParameterTypes(context: InsertionContext, placeholderRan
return functionTypes.filter { KotlinBuiltIns.getParameterTypeProjectionsFromFunctionType(it).size() == lambdaParameterCount }.size() > 1
}
private fun buildTemplate(lambdaType: KtType, explicitParameterTypes: Boolean, project: Project): Template {
private fun buildTemplate(lambdaType: KotlinType, explicitParameterTypes: Boolean, project: Project): Template {
val parameterTypes = functionParameterTypes(lambdaType)
val manager = TemplateManager.getInstance(project)
@@ -128,5 +128,5 @@ private class ParameterNameExpression(val nameSuggestions: Array<String>) : Expr
= Array<LookupElement>(nameSuggestions.size(), { LookupElementBuilder.create(nameSuggestions[it]) })
}
fun functionParameterTypes(functionType: KtType): List<KtType>
fun functionParameterTypes(functionType: KotlinType): List<KotlinType>
= KotlinBuiltIns.getParameterTypeProjectionsFromFunctionType(functionType).map { it.getType() }
@@ -29,9 +29,9 @@ import org.jetbrains.kotlin.idea.core.formatter.JetCodeStyleSettings
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.KtTypeArgumentList
import org.jetbrains.kotlin.psi.psiUtil.endOffset
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
class GenerateLambdaInfo(val lambdaType: KtType, val explicitParameters: Boolean)
class GenerateLambdaInfo(val lambdaType: KotlinType, val explicitParameters: Boolean)
sealed class KotlinFunctionInsertHandler : KotlinCallableInsertHandler() {
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.idea.completion.createLookupElementForType
import org.jetbrains.kotlin.idea.completion.fuzzyType
import org.jetbrains.kotlin.idea.imports.importableFqName
import org.jetbrains.kotlin.idea.quickfix.moveCaret
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.Variance
import java.util.*
@@ -39,7 +39,7 @@ object ClassLiteralItems {
lookupElementFactory: LookupElementFactory,
isJvmModule: Boolean
) {
val typeAndSuffixToExpectedInfos = LinkedHashMap<Pair<KtType, String>, MutableList<ExpectedInfo>>()
val typeAndSuffixToExpectedInfos = LinkedHashMap<Pair<KotlinType, String>, MutableList<ExpectedInfo>>()
for (expectedInfo in expectedInfos) {
val fuzzyType = expectedInfo.fuzzyType ?: continue
@@ -34,7 +34,7 @@ import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeUtils
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
import org.jetbrains.kotlin.utils.addIfNotNull
@@ -374,7 +374,7 @@ class SmartCompletion(
if (elementType != KtTokens.AS_KEYWORD && elementType != KtTokens.AS_SAFE) return null
val expectedInfos = calcExpectedInfos(binaryExpression)
val expectedInfosGrouped: Map<KtType?, List<ExpectedInfo>> = expectedInfos.groupBy { it.fuzzyType?.type?.makeNotNullable() }
val expectedInfosGrouped: Map<KotlinType?, List<ExpectedInfo>> = expectedInfos.groupBy { it.fuzzyType?.type?.makeNotNullable() }
val items = ArrayList<LookupElement>()
for ((type, infos) in expectedInfosGrouped) {
@@ -266,7 +266,7 @@ class TypeInstantiationItems(
return InstantiationLookupElement(lookupElement).addTail(tail)
}
private fun KtType.areTypeParametersUsedInside(freeParameters: Collection<TypeParameterDescriptor>): Boolean {
private fun KotlinType.areTypeParametersUsedInside(freeParameters: Collection<TypeParameterDescriptor>): Boolean {
return FuzzyType(this, freeParameters).freeParameters.isNotEmpty()
}
@@ -296,7 +296,7 @@ class TypeInstantiationItems(
private val tail: Tail?) : InheritanceItemsSearcher {
private val baseHasTypeArgs = classDescriptor.typeConstructor.parameters.isNotEmpty()
private val expectedType = KtTypeImpl.create(Annotations.EMPTY, classDescriptor, false, typeArgs)
private val expectedType = KotlinTypeImpl.create(Annotations.EMPTY, classDescriptor, false, typeArgs)
private val expectedFuzzyType = FuzzyType(expectedType, freeParameters)
override fun search(nameFilter: (String) -> Boolean, consumer: (LookupElement) -> Unit) {
@@ -26,14 +26,14 @@ import org.jetbrains.kotlin.idea.util.nullability
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.scopes.KtScope
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeUtils
import org.jetbrains.kotlin.types.typeUtil.TypeNullability
import java.util.*
class TypesWithContainsDetector(
private val scope: KtScope,
private val argumentType: KtType,
private val argumentType: KotlinType,
private val resolutionFacade: ResolutionFacade
) {
private val cache = HashMap<FuzzyType, Boolean>()
@@ -41,7 +41,7 @@ class TypesWithContainsDetector(
private val booleanType = resolutionFacade.moduleDescriptor.builtIns.booleanType
private val heuristicSignatures = resolutionFacade.ideService<HeuristicSignatures>()
private val typesWithExtensionContains: Collection<KtType> = scope.getFunctions(containsName, NoLookupLocation.FROM_IDE)
private val typesWithExtensionContains: Collection<KotlinType> = scope.getFunctions(containsName, NoLookupLocation.FROM_IDE)
.filter { it.getExtensionReceiverParameter() != null && isGoodContainsFunction(it, listOf()) }
.map { it.getExtensionReceiverParameter()!!.getType() }
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
import org.jetbrains.kotlin.resolve.scopes.KtScope
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
import org.jetbrains.kotlin.resolve.scopes.utils.asLexicalScope
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeUtils
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext
import org.jetbrains.kotlin.types.expressions.ForLoopConventionsChecker
@@ -48,24 +48,24 @@ public class IterableTypesDetection(
private inner class Detector(private val scope: KtScope): IterableTypesDetector {
private val cache = HashMap<FuzzyType, FuzzyType?>()
private val typesWithExtensionIterator: Collection<KtType> = scope.getFunctions(iteratorName, NoLookupLocation.FROM_IDE)
private val typesWithExtensionIterator: Collection<KotlinType> = scope.getFunctions(iteratorName, NoLookupLocation.FROM_IDE)
.map { it.getExtensionReceiverParameter() }
.filterNotNull()
.map { it.getType() }
override fun isIterable(type: FuzzyType, loopVarType: KtType?): Boolean {
override fun isIterable(type: FuzzyType, loopVarType: KotlinType?): Boolean {
val elementType = elementType(type) ?: return false
return loopVarType == null || elementType.checkIsSubtypeOf(loopVarType) != null
}
override fun isIterable(type: KtType, loopVarType: KtType?): Boolean
override fun isIterable(type: KotlinType, loopVarType: KotlinType?): Boolean
= isIterable(FuzzyType(type, emptyList()), loopVarType)
private fun elementType(type: FuzzyType): FuzzyType? {
return cache.getOrPut(type, { elementTypeNoCache(type) })
}
override fun elementType(type: KtType): FuzzyType?
override fun elementType(type: KotlinType): FuzzyType?
= elementType(FuzzyType(type, emptyList()))
private fun elementTypeNoCache(type: FuzzyType): FuzzyType? {
@@ -87,9 +87,9 @@ public class IterableTypesDetection(
}
public interface IterableTypesDetector {
public fun isIterable(type: KtType, loopVarType: KtType? = null): Boolean
public fun isIterable(type: KotlinType, loopVarType: KotlinType? = null): Boolean
public fun isIterable(type: FuzzyType, loopVarType: KtType? = null): Boolean
public fun isIterable(type: FuzzyType, loopVarType: KotlinType? = null): Boolean
public fun elementType(type: KtType): FuzzyType?
public fun elementType(type: KotlinType): FuzzyType?
}
@@ -37,7 +37,7 @@ import org.jetbrains.kotlin.psi.KtNamedDeclaration
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.isAnnotatedAsHidden
import org.jetbrains.kotlin.resolve.lazy.ResolveSessionUtils
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.utils.addIfNotNull
import org.jetbrains.kotlin.utils.addToStdlib.singletonOrEmptyList
import java.util.*
@@ -114,7 +114,7 @@ public class KotlinIndicesHelper(
return findSuitableExtensions(declarations, receiverTypes, callTypeAndReceiver.callType)
}
private fun MutableCollection<String>.addTypeNames(type: KtType) {
private fun MutableCollection<String>.addTypeNames(type: KotlinType) {
val constructor = type.getConstructor()
addIfNotNull(constructor.getDeclarationDescriptor()?.getName()?.asString())
constructor.getSupertypes().forEach { addTypeNames(it) }
@@ -125,7 +125,7 @@ public class KotlinIndicesHelper(
*/
private fun findSuitableExtensions(
declarations: Sequence<KtCallableDeclaration>,
receiverTypes: Collection<KtType>,
receiverTypes: Collection<KotlinType>,
callType: CallType<*>
): Collection<CallableDescriptor> {
val result = LinkedHashSet<CallableDescriptor>()
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.types.ErrorUtils
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeUtils
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
import org.jetbrains.kotlin.types.typeUtil.builtIns
@@ -50,7 +50,7 @@ public object KotlinNameSuggester {
return result
}
public fun suggestNamesByType(type: KtType, validator: (String) -> Boolean, defaultName: String? = null): List<String> {
public fun suggestNamesByType(type: KotlinType, validator: (String) -> Boolean, defaultName: String? = null): List<String> {
val result = ArrayList<String>()
result.addNamesByType(type, validator)
@@ -74,7 +74,7 @@ public object KotlinNameSuggester {
return result
}
public fun suggestIterationVariableNames(collection: KtExpression, elementType: KtType, validator: (String) -> Boolean, defaultName: String?): Collection<String> {
public fun suggestIterationVariableNames(collection: KtExpression, elementType: KotlinType, validator: (String) -> Boolean, defaultName: String?): Collection<String> {
val result = LinkedHashSet<String>()
suggestNamesByExpressionOnly(collection, { true })
@@ -133,7 +133,7 @@ public object KotlinNameSuggester {
}
}
private fun MutableCollection<String>.addNamesByType(type: KtType, validator: (String) -> Boolean) {
private fun MutableCollection<String>.addNamesByType(type: KotlinType, validator: (String) -> Boolean) {
var type = TypeUtils.makeNotNullable(type) // wipe out '?'
val builtIns = type.builtIns
val typeChecker = KotlinTypeChecker.DEFAULT
@@ -45,7 +45,7 @@ import org.jetbrains.kotlin.resolve.scopes.KtScope
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
import org.jetbrains.kotlin.resolve.scopes.receivers.ThisReceiver
import org.jetbrains.kotlin.resolve.scopes.utils.asJetScope
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeUtils
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils
@@ -130,7 +130,7 @@ public fun KtImportDirective.targetDescriptors(): Collection<DeclarationDescript
public fun Call.resolveCandidates(
bindingContext: BindingContext,
resolutionFacade: ResolutionFacade,
expectedType: KtType = expectedType(this, bindingContext),
expectedType: KotlinType = expectedType(this, bindingContext),
filterOutWrongReceiver: Boolean = true,
filterOutByVisibility: Boolean = true
): Collection<ResolvedCall<FunctionDescriptor>> {
@@ -169,7 +169,7 @@ public fun Call.resolveCandidates(
return candidates
}
private fun expectedType(call: Call, bindingContext: BindingContext): KtType {
private fun expectedType(call: Call, bindingContext: BindingContext): KotlinType {
return (call.callElement as? KtExpression)?.let {
bindingContext[BindingContext.EXPECTED_EXPRESSION_TYPE, it.getQualifiedExpressionForSelectorOrThis()]
} ?: TypeUtils.NO_EXPECTED_TYPE
@@ -37,7 +37,7 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt;
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
import org.jetbrains.kotlin.types.DeferredType;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
public class QuickFixUtil {
@@ -58,12 +58,12 @@ public class QuickFixUtil {
}
@Nullable
public static KtType getDeclarationReturnType(KtNamedDeclaration declaration) {
public static KotlinType getDeclarationReturnType(KtNamedDeclaration declaration) {
PsiFile file = declaration.getContainingFile();
if (!(file instanceof KtFile)) return null;
DeclarationDescriptor descriptor = ResolutionUtils.resolveToDescriptor(declaration);
if (!(descriptor instanceof CallableDescriptor)) return null;
KtType type = ((CallableDescriptor) descriptor).getReturnType();
KotlinType type = ((CallableDescriptor) descriptor).getReturnType();
if (type instanceof DeferredType) {
type = ((DeferredType) type).getDelegate();
}
@@ -71,10 +71,10 @@ public class QuickFixUtil {
}
@Nullable
public static KtType findLowerBoundOfOverriddenCallablesReturnTypes(@NotNull CallableDescriptor descriptor) {
KtType matchingReturnType = null;
public static KotlinType findLowerBoundOfOverriddenCallablesReturnTypes(@NotNull CallableDescriptor descriptor) {
KotlinType matchingReturnType = null;
for (CallableDescriptor overriddenDescriptor : ((CallableDescriptor) descriptor).getOverriddenDescriptors()) {
KtType overriddenReturnType = overriddenDescriptor.getReturnType();
KotlinType overriddenReturnType = overriddenDescriptor.getReturnType();
if (overriddenReturnType == null) {
return null;
}
@@ -155,7 +155,7 @@ public class QuickFixUtil {
}
}
public static String renderTypeWithFqNameOnClash(KtType type, String nameToCheckAgainst) {
public static String renderTypeWithFqNameOnClash(KotlinType type, String nameToCheckAgainst) {
FqName typeFqName = DescriptorUtils.getFqNameSafe(DescriptorUtils.getClassDescriptorForType(type));
FqName fqNameToCheckAgainst = new FqName(nameToCheckAgainst);
DescriptorRenderer renderer = typeFqName.shortName().equals(fqNameToCheckAgainst.shortName())
@@ -17,7 +17,7 @@
package org.jetbrains.kotlin.console.gutter
import com.intellij.icons.AllIcons
import org.jetbrains.kotlin.idea.KtIcons
import org.jetbrains.kotlin.idea.KotlinIcons
import javax.swing.Icon
public data class IconWithTooltip(val icon: Icon, val tooltip: String?)
@@ -25,7 +25,7 @@ public data class IconWithTooltip(val icon: Icon, val tooltip: String?)
public object ReplIcons {
public val BUILD_WARNING_INDICATOR: IconWithTooltip = IconWithTooltip(AllIcons.Ide.Warning_notifications, null)
public val HISTORY_INDICATOR: IconWithTooltip = IconWithTooltip(AllIcons.General.MessageHistory, "History of executed commands")
public val EDITOR_INDICATOR: IconWithTooltip = IconWithTooltip(KtIcons.LAUNCH, "Write your commands here")
public val EDITOR_INDICATOR: IconWithTooltip = IconWithTooltip(KotlinIcons.LAUNCH, "Write your commands here")
public val EDITOR_READLINE_INDICATOR: IconWithTooltip = IconWithTooltip(AllIcons.General.Balloon, "Waiting for input...")
public val COMMAND_MARKER: IconWithTooltip = IconWithTooltip(AllIcons.General.Run, "Executed command")
public val READLINE_MARKER: IconWithTooltip = IconWithTooltip(AllIcons.Icons.Ide.SpeedSearchPrompt, "Input line")
@@ -32,7 +32,7 @@ import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiFile;
import org.jetbrains.kotlin.idea.JetBundle;
import org.jetbrains.kotlin.idea.KotlinFileType;
import org.jetbrains.kotlin.idea.KtIcons;
import org.jetbrains.kotlin.idea.KotlinIcons;
import org.jetbrains.kotlin.idea.configuration.ConfigureKotlinInProjectUtils;
import java.util.Map;
@@ -57,10 +57,10 @@ public class NewKotlinFileAction extends CreateFileFromTemplateAction implements
builder
.setTitle("New Kotlin File/Class")
.addKind("File", KotlinFileType.INSTANCE.getIcon(), "Kotlin File")
.addKind("Class", KtIcons.CLASS, "Kotlin Class")
.addKind("Interface", KtIcons.TRAIT, "Kotlin Interface")
.addKind("Enum class", KtIcons.ENUM, "Kotlin Enum")
.addKind("Object", KtIcons.OBJECT, "Kotlin Object");
.addKind("Class", KotlinIcons.CLASS, "Kotlin Class")
.addKind("Interface", KotlinIcons.TRAIT, "Kotlin Interface")
.addKind("Enum class", KotlinIcons.ENUM, "Kotlin Enum")
.addKind("Object", KotlinIcons.OBJECT, "Kotlin Object");
}
@Override
@@ -35,7 +35,7 @@ import org.jetbrains.kotlin.psi.psiUtil.parents
import org.jetbrains.kotlin.psi.psiUtil.startOffset
import org.jetbrains.kotlin.renderer.DescriptorRenderer
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
@Deprecated("Remove once we no longer support IDEA 14.1")
public class ShowExpressionTypeAction : AnAction() {
@@ -80,9 +80,9 @@ public class ShowExpressionTypeAction : AnAction() {
}
companion object {
fun renderTypeHint(type: KtType) = "<html>" + DescriptorRenderer.HTML.renderType(type) + "</html>"
fun renderTypeHint(type: KotlinType) = "<html>" + DescriptorRenderer.HTML.renderType(type) + "</html>"
fun typeByExpression(expression: KtExpression): KtType? {
fun typeByExpression(expression: KtExpression): KotlinType? {
val bindingContext = expression.analyze()
if (expression is KtCallableDeclaration) {
@@ -23,7 +23,7 @@ import com.intellij.openapi.wm.ToolWindowAnchor
import com.intellij.openapi.wm.ToolWindowManager
import com.intellij.ui.content.ContentFactory
import org.jetbrains.kotlin.idea.KotlinFileType
import org.jetbrains.kotlin.idea.KtIcons
import org.jetbrains.kotlin.idea.KotlinIcons
import org.jetbrains.kotlin.idea.internal.KotlinBytecodeToolWindow
public class ShowKotlinBytecodeAction(): AnAction() {
@@ -36,7 +36,7 @@ public class ShowKotlinBytecodeAction(): AnAction() {
var toolWindow = toolWindowManager.getToolWindow(TOOLWINDOW_ID)
if (toolWindow == null) {
toolWindow = toolWindowManager.registerToolWindow("Kotlin Bytecode", true, ToolWindowAnchor.RIGHT)
toolWindow.setIcon(KtIcons.SMALL_LOGO_13)
toolWindow.setIcon(KotlinIcons.SMALL_LOGO_13)
val contentManager = toolWindow.getContentManager()
val contentFactory = ContentFactory.SERVICE.getInstance()
@@ -42,7 +42,7 @@ import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperClassNotAny
import org.jetbrains.kotlin.resolve.source.getPsi
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeSubstitutor
import org.jetbrains.kotlin.types.Variance
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
@@ -140,7 +140,7 @@ class KotlinGenerateSecondaryConstructorAction : KotlinGenerateMemberActionBase<
propertiesToInitialize: List<PropertyDescriptor>,
superConstructor: ConstructorDescriptor?
): KtSecondaryConstructor? {
fun equalTypes(types1: Collection<KtType>, types2: Collection<KtType>): Boolean {
fun equalTypes(types1: Collection<KotlinType>, types2: Collection<KotlinType>): Boolean {
return types1.size == types2.size && (types1.zip(types2)).all { KotlinTypeChecker.DEFAULT.equalTypes(it.first, it.second) }
}
@@ -43,7 +43,7 @@ import org.jetbrains.kotlin.psi.psiUtil.siblings
import org.jetbrains.kotlin.renderer.DescriptorRenderer
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
import java.util.ArrayList
import javax.swing.SwingUtilities
@@ -147,7 +147,7 @@ public class CheckPartialBodyResolveAction : AnAction() {
}
private fun DeclarationDescriptor.presentation() = DescriptorRenderer.FQ_NAMES_IN_TYPES.render(this)
private fun KtType.presentation() = DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(this)
private fun KotlinType.presentation() = DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(this)
override fun update(e: AnActionEvent) {
if (!KotlinInternalMode.enabled) {
@@ -33,7 +33,7 @@ import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.resolve.calls.callUtil.getCalleeExpressionIfAny
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
import com.intellij.usages.UsageViewManager
@@ -125,7 +125,7 @@ public class FindImplicitNothingAction : AnAction() {
}
}
private fun KtType.isNothingOrNothingFunctionType(): Boolean {
private fun KotlinType.isNothingOrNothingFunctionType(): Boolean {
return when {
KotlinBuiltIns.isNothing(this) -> true
@@ -35,7 +35,7 @@ import org.jetbrains.kotlin.lexer.KtTokens;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.resolve.scopes.receivers.Qualifier;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
import java.util.ArrayList;
import java.util.Collections;
@@ -223,7 +223,7 @@ public class CodeInsightUtils {
}
@Nullable
public static String defaultInitializer(KtType type) {
public static String defaultInitializer(KotlinType type) {
if (type.isMarkedNullable()) {
return "null";
}
@@ -39,7 +39,7 @@ import org.jetbrains.kotlin.idea.caches.resolve.ResolutionUtils;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils;
import org.jetbrains.kotlin.resolve.OverrideResolver;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
import java.util.Collection;
import java.util.List;
@@ -103,10 +103,10 @@ public class GotoSuperActionHandler implements CodeInsightActionHandler {
private static List<PsiElement> findSuperDeclarations(DeclarationDescriptor descriptor) {
Collection<? extends DeclarationDescriptor> superDescriptors;
if (descriptor instanceof ClassDescriptor) {
Collection<KtType> supertypes = ((ClassDescriptor) descriptor).getTypeConstructor().getSupertypes();
List<ClassDescriptor> superclasses = ContainerUtil.mapNotNull(supertypes, new Function<KtType, ClassDescriptor>() {
Collection<KotlinType> supertypes = ((ClassDescriptor) descriptor).getTypeConstructor().getSupertypes();
List<ClassDescriptor> superclasses = ContainerUtil.mapNotNull(supertypes, new Function<KotlinType, ClassDescriptor>() {
@Override
public ClassDescriptor fun(KtType type) {
public ClassDescriptor fun(KotlinType type) {
ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
if (descriptor instanceof ClassDescriptor) {
return (ClassDescriptor) descriptor;
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.psi.KtElement;
import org.jetbrains.kotlin.psi.KtFile;
import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
public class JetTypeDeclarationProvider implements TypeDeclarationProvider {
@Override
@@ -35,7 +35,7 @@ public class JetTypeDeclarationProvider implements TypeDeclarationProvider {
BindingContext bindingContext = ResolutionUtils.analyze((KtElement)symbol);
DeclarationDescriptor descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, symbol);
if (descriptor instanceof CallableDescriptor) {
KtType type = ((CallableDescriptor) descriptor).getReturnType();
KotlinType type = ((CallableDescriptor) descriptor).getReturnType();
if (type != null) {
ClassifierDescriptor classifierDescriptor = type.getConstructor().getDeclarationDescriptor();
if (classifierDescriptor != null) {
@@ -33,7 +33,7 @@ import org.jetbrains.kotlin.idea.util.ShortenReferences;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
import java.util.ArrayList;
import java.util.List;
@@ -106,7 +106,7 @@ public class MoveDeclarationsOutHelper {
@NotNull
private static KtProperty createVariableDeclaration(@NotNull KtProperty property, boolean generateDefaultInitializers) {
KtType propertyType = getPropertyType(property);
KotlinType propertyType = getPropertyType(property);
String defaultInitializer = null;
if (generateDefaultInitializers && property.isVar()) {
defaultInitializer = CodeInsightUtils.defaultInitializer(propertyType);
@@ -115,7 +115,7 @@ public class MoveDeclarationsOutHelper {
}
@NotNull
private static KtType getPropertyType(@NotNull KtProperty property) {
private static KotlinType getPropertyType(@NotNull KtProperty property) {
BindingContext bindingContext = ResolutionUtils.analyze(property, BodyResolveMode.PARTIAL);
VariableDescriptor propertyDescriptor = bindingContext.get(BindingContext.VARIABLE, property);
@@ -124,7 +124,7 @@ public class MoveDeclarationsOutHelper {
}
@NotNull
private static KtProperty createProperty(@NotNull KtProperty property, @NotNull KtType propertyType, @Nullable String initializer) {
private static KtProperty createProperty(@NotNull KtProperty property, @NotNull KotlinType propertyType, @Nullable String initializer) {
KtTypeReference typeRef = property.getTypeReference();
String typeString = null;
if (typeRef != null) {
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.psi.KtCallExpression;
import org.jetbrains.kotlin.psi.KtExpression;
import org.jetbrains.kotlin.psi.KtQualifiedExpression;
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
import static org.jetbrains.kotlin.builtins.KotlinBuiltIns.isUnit;
@@ -44,7 +44,7 @@ public abstract class KotlinExpressionSurrounder implements Surrounder {
if (expression instanceof KtCallExpression && expression.getParent() instanceof KtQualifiedExpression) {
return false;
}
KtType type = ResolutionUtils.analyze(expression, BodyResolveMode.PARTIAL).getType(expression);
KotlinType type = ResolutionUtils.analyze(expression, BodyResolveMode.PARTIAL).getType(expression);
if (type == null || isUnit(type)) {
return false;
}
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.psi.KtParenthesizedExpression;
import org.jetbrains.kotlin.psi.KtPrefixExpression;
import org.jetbrains.kotlin.psi.KtPsiFactoryKt;
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
public class KotlinNotSurrounder extends KotlinExpressionSurrounder {
@Override
@@ -40,7 +40,7 @@ public class KotlinNotSurrounder extends KotlinExpressionSurrounder {
@Override
public boolean isApplicable(@NotNull KtExpression expression) {
KtType type = ResolutionUtils.analyze(expression, BodyResolveMode.PARTIAL).getType(expression);
KotlinType type = ResolutionUtils.analyze(expression, BodyResolveMode.PARTIAL).getType(expression);
return type != null && KotlinBuiltIns.isBoolean(type);
}
@@ -36,7 +36,7 @@ import org.jetbrains.kotlin.idea.util.ShortenReferences
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeUtils
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
@@ -75,7 +75,7 @@ public class KotlinRuntimeTypeCastSurrounder: KotlinExpressionSurrounder() {
indicator: ProgressIndicator
): KotlinRuntimeTypeEvaluator(myEditor, expression, context, indicator) {
override fun typeCalculationFinished(type: KtType?) {
override fun typeCalculationFinished(type: KotlinType?) {
if (type == null) return
hold()
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.idea.JetBundle;
import org.jetbrains.kotlin.idea.caches.resolve.ResolutionUtils;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
public class KotlinWhenSurrounder extends KotlinExpressionSurrounder {
@Override
@@ -65,7 +65,7 @@ public class KotlinWhenSurrounder extends KotlinExpressionSurrounder {
}
private String getCodeTemplate(KtExpression expression) {
KtType type = ResolutionUtils.analyze(expression, BodyResolveMode.PARTIAL).getType(expression);
KotlinType type = ResolutionUtils.analyze(expression, BodyResolveMode.PARTIAL).getType(expression);
if (type != null) {
ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
if (descriptor instanceof ClassDescriptor && ((ClassDescriptor) descriptor).getKind() == ClassKind.ENUM_CLASS) {
@@ -61,7 +61,7 @@ import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.inline.InlineUtil
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.typeUtil.makeNullable
import org.jetbrains.kotlin.utils.addToStdlib.check
import java.util.*
@@ -106,9 +106,9 @@ class KotlinCodeFragmentFactory: CodeFragmentFactory() {
else {
val semaphore = Semaphore()
semaphore.down()
val nameRef = AtomicReference<KtType>()
val nameRef = AtomicReference<KotlinType>()
val worker = object : KotlinRuntimeTypeEvaluator(null, expression, debuggerContext, ProgressManager.getInstance().progressIndicator) {
override fun typeCalculationFinished(type: KtType?) {
override fun typeCalculationFinished(type: KotlinType?) {
nameRef.set(type)
semaphore.up()
}
@@ -26,7 +26,7 @@ import com.intellij.debugger.engine.evaluation.EvaluationContextImpl
import java.util.ArrayList
import com.intellij.openapi.components.ServiceManager
import com.intellij.util.containers.MultiMap
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.apache.log4j.Logger
@@ -96,12 +96,12 @@ class KotlinEvaluateExpressionCache(val project: Project) {
class ParametersDescriptor : Iterable<Parameter> {
private val list = ArrayList<Parameter>()
fun add(name: String, jetType: KtType, value: Value? = null) {
fun add(name: String, jetType: KotlinType, value: Value? = null) {
list.add(Parameter(name, jetType, value))
}
override fun iterator() = list.iterator()
}
data class Parameter(val callText: String, val type: KtType, val value: Value? = null)
data class Parameter(val callText: String, val type: KotlinType, val value: Value? = null)
}
@@ -36,7 +36,7 @@ import com.sun.jdi.Value
import org.jetbrains.eval4j.jdi.asValue
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtPsiFactory
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.org.objectweb.asm.Type as AsmType
public abstract class KotlinRuntimeTypeEvaluator(
@@ -44,10 +44,10 @@ public abstract class KotlinRuntimeTypeEvaluator(
expression: KtExpression,
context: DebuggerContextImpl,
indicator: ProgressIndicator
) : EditorEvaluationCommand<KtType>(editor, expression, context, indicator) {
) : EditorEvaluationCommand<KotlinType>(editor, expression, context, indicator) {
override fun threadAction() {
var type: KtType? = null
var type: KotlinType? = null
try {
type = evaluate()
}
@@ -60,9 +60,9 @@ public abstract class KotlinRuntimeTypeEvaluator(
}
}
protected abstract fun typeCalculationFinished(type: KtType?)
protected abstract fun typeCalculationFinished(type: KotlinType?)
override fun evaluate(evaluationContext: EvaluationContextImpl): KtType? {
override fun evaluate(evaluationContext: EvaluationContextImpl): KotlinType? {
val project = evaluationContext.getProject()
val evaluator = DebuggerInvocationUtil.commitAndRunReadAction<ExpressionEvaluator>(project, EvaluatingComputable {
@@ -80,7 +80,7 @@ public abstract class KotlinRuntimeTypeEvaluator(
}
companion object {
private fun getCastableRuntimeType(project: Project, value: Value): KtType? {
private fun getCastableRuntimeType(project: Project, value: Value): KotlinType? {
val myValue = value.asValue()
var psiClass = myValue.asmType.getClassDescriptor(project)
if (psiClass != null) {
@@ -22,7 +22,7 @@ import com.intellij.psi.PsiElement
import com.intellij.psi.PsiMethod
import com.intellij.util.Range
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.idea.KtIcons
import org.jetbrains.kotlin.idea.KotlinIcons
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.KtElement
import org.jetbrains.kotlin.psi.KtFunctionLiteralExpression
@@ -34,7 +34,7 @@ public class KotlinLambdaSmartStepTarget(
highlightElement: KtFunctionLiteralExpression,
lines: Range<Int>
): SmartStepTarget(label, highlightElement, true, lines) {
override fun getIcon() = KtIcons.LAMBDA
override fun getIcon() = KotlinIcons.LAMBDA
fun getLambda() = getHighlightElement() as KtFunctionLiteralExpression
@@ -4,7 +4,7 @@ import com.intellij.debugger.actions.SmartStepTarget
import com.intellij.psi.PsiElement
import com.intellij.util.Range
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.idea.KtIcons
import org.jetbrains.kotlin.idea.KotlinIcons
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
import org.jetbrains.kotlin.psi.KtElement
import org.jetbrains.kotlin.psi.KtNamedFunction
@@ -19,8 +19,8 @@ public class KotlinMethodSmartStepTarget(
): SmartStepTarget(label, highlightElement, false, lines) {
override fun getIcon(): Icon? {
return when {
resolvedElement is KtNamedFunction && resolvedElement.getReceiverTypeReference() != null -> KtIcons.EXTENSION_FUNCTION
else -> KtIcons.FUNCTION
resolvedElement is KtNamedFunction && resolvedElement.getReceiverTypeReference() != null -> KotlinIcons.EXTENSION_FUNCTION
else -> KotlinIcons.FUNCTION
}
}
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.idea.framework;
import com.intellij.framework.FrameworkTypeEx;
import com.intellij.framework.addSupport.FrameworkSupportInModuleProvider;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.idea.KtIcons;
import org.jetbrains.kotlin.idea.KotlinIcons;
import javax.swing.*;
@@ -47,6 +47,6 @@ public class JSFrameworkType extends FrameworkTypeEx {
@NotNull
@Override
public Icon getIcon() {
return KtIcons.SMALL_LOGO_13;
return KotlinIcons.SMALL_LOGO_13;
}
}
@@ -23,7 +23,7 @@ import com.intellij.openapi.roots.libraries.LibraryPresentationProvider;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.idea.KtIcons;
import org.jetbrains.kotlin.idea.KotlinIcons;
import org.jetbrains.kotlin.utils.LibraryUtils;
import org.jetbrains.kotlin.utils.PathUtil;
@@ -43,7 +43,7 @@ public class JSLibraryStdPresentationProvider extends LibraryPresentationProvide
@Nullable
@Override
public Icon getIcon() {
return KtIcons.SMALL_LOGO_13;
return KotlinIcons.SMALL_LOGO_13;
}
@Nullable
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.idea.framework;
import com.intellij.framework.FrameworkTypeEx;
import com.intellij.framework.addSupport.FrameworkSupportInModuleProvider;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.idea.KtIcons;
import org.jetbrains.kotlin.idea.KotlinIcons;
import javax.swing.*;
@@ -47,6 +47,6 @@ public class JavaFrameworkType extends FrameworkTypeEx {
@NotNull
@Override
public Icon getIcon() {
return KtIcons.SMALL_LOGO_13;
return KotlinIcons.SMALL_LOGO_13;
}
}
@@ -23,7 +23,7 @@ import com.intellij.openapi.roots.libraries.LibraryPresentationProvider;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.idea.KtIcons;
import org.jetbrains.kotlin.idea.KotlinIcons;
import org.jetbrains.kotlin.utils.LibraryUtils;
import org.jetbrains.kotlin.utils.PathUtil;
@@ -43,7 +43,7 @@ public class JavaRuntimePresentationProvider extends LibraryPresentationProvider
@Nullable
@Override
public Icon getIcon() {
return KtIcons.SMALL_LOGO_13;
return KotlinIcons.SMALL_LOGO_13;
}
@Nullable
@@ -21,7 +21,7 @@ import com.intellij.ide.util.projectWizard.ModuleWizardStep
import com.intellij.ide.util.projectWizard.SettingsStep
import com.intellij.ide.util.projectWizard.WizardContext
import com.intellij.openapi.roots.ui.configuration.ModulesProvider
import org.jetbrains.kotlin.idea.KtIcons
import org.jetbrains.kotlin.idea.KotlinIcons
import org.jetbrains.kotlin.resolve.TargetPlatform
public class KotlinModuleBuilder(
@@ -30,8 +30,8 @@ public class KotlinModuleBuilder(
override fun getName() = builderName
override fun getPresentableName() = builderName
override fun getDescription() = builderDescription
override fun getBigIcon() = KtIcons.KOTLIN_LOGO_24
override fun getNodeIcon() = KtIcons.SMALL_LOGO
override fun getBigIcon() = KotlinIcons.KOTLIN_LOGO_24
override fun getNodeIcon() = KotlinIcons.SMALL_LOGO
override fun getGroupName() = KotlinTemplatesFactory.KOTLIN_GROUP_NAME
override fun createWizardSteps(wizardContext: WizardContext, modulesProvider: ModulesProvider) = ModuleWizardStep.EMPTY_ARRAY
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.idea.framework
import com.intellij.ide.util.projectWizard.WizardContext
import com.intellij.platform.ProjectTemplatesFactory
import com.intellij.platform.templates.BuilderBasedTemplate
import org.jetbrains.kotlin.idea.KtIcons
import org.jetbrains.kotlin.idea.KotlinIcons
import org.jetbrains.kotlin.js.resolve.JsPlatform
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform
@@ -29,7 +29,7 @@ public class KotlinTemplatesFactory : ProjectTemplatesFactory() {
}
override fun getGroups() = arrayOf(KOTLIN_GROUP_NAME)
override fun getGroupIcon(group: String) = KtIcons.SMALL_LOGO
override fun getGroupIcon(group: String) = KotlinIcons.SMALL_LOGO
override fun createTemplates(group: String?, context: WizardContext?) =
arrayOf(
@@ -39,7 +39,7 @@ import org.jetbrains.kotlin.psi.KtClassOrObject;
import org.jetbrains.kotlin.psi.KtNamedFunction;
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
import java.util.Collection;
@@ -72,7 +72,7 @@ public class KotlinTypeHierarchyProvider extends JavaTypeHierarchyProvider {
FunctionDescriptor functionDescriptor = ResolutionUtils.analyze(function)
.get(BindingContext.FUNCTION, target);
if (functionDescriptor != null) {
KtType type = functionDescriptor.getReturnType();
KotlinType type = functionDescriptor.getReturnType();
if (type != null) {
String returnTypeText = DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(type);
if (returnTypeText.equals(functionName)) {
@@ -23,7 +23,7 @@ import com.intellij.openapi.options.colors.AttributesDescriptor
import com.intellij.openapi.options.colors.ColorDescriptor
import com.intellij.openapi.options.colors.ColorSettingsPage
import org.jetbrains.kotlin.idea.JetBundle
import org.jetbrains.kotlin.idea.KtIcons
import org.jetbrains.kotlin.idea.KotlinIcons
import org.jetbrains.kotlin.idea.KotlinLanguage
import javax.swing.*
@@ -32,7 +32,7 @@ import java.lang.reflect.Modifier
import java.util.HashMap
public class KotlinColorSettingsPage : ColorSettingsPage {
override fun getIcon() = KtIcons.SMALL_LOGO
override fun getIcon() = KotlinIcons.SMALL_LOGO
override fun getHighlighter(): SyntaxHighlighter = JetHighlighter()
override fun getDemoText(): String {
@@ -20,7 +20,7 @@ import com.intellij.execution.lineMarker.ExecutorAction
import com.intellij.execution.lineMarker.RunLineMarkerContributor
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.idea.KtIcons
import org.jetbrains.kotlin.idea.KotlinIcons
import org.jetbrains.kotlin.idea.MainFunctionDetector
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor
import org.jetbrains.kotlin.psi.KtNamedFunction
@@ -38,7 +38,7 @@ public class KotlinRunLineMarkerContributor : RunLineMarkerContributor() {
}
if (detector.isMain(function)) {
return RunLineMarkerContributor.Info(KtIcons.LAUNCH, null, ExecutorAction.getActions(0))
return RunLineMarkerContributor.Info(KotlinIcons.LAUNCH, null, ExecutorAction.getActions(0))
}
return null
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
public class ConvertToBlockBodyIntention : JetSelfTargetingIntention<KtDeclarationWithBody>(
javaClass(), "Convert to block body"
@@ -84,7 +84,7 @@ public class ConvertToBlockBodyIntention : JetSelfTargetingIntention<KtDeclarati
return declaration
}
private fun KtNamedFunction.returnType(): KtType? {
private fun KtNamedFunction.returnType(): KotlinType? {
val descriptor = analyze()[BindingContext.DECLARATION_TO_DESCRIPTOR, this] ?: return null
return (descriptor as FunctionDescriptor).getReturnType()
}
@@ -32,7 +32,7 @@ import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.siblings
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
public class IterateExpressionIntention : JetSelfTargetingIntention<KtExpression>(javaClass(), "Iterate over collection"), HighPriorityAction {
override fun isApplicableTo(element: KtExpression, caretOffset: Int): Boolean {
@@ -44,7 +44,7 @@ public class IterateExpressionIntention : JetSelfTargetingIntention<KtExpression
return true
}
private data class Data(val collectionType: KtType, val elementType: KtType)
private data class Data(val collectionType: KotlinType, val elementType: KotlinType)
private fun data(expression: KtExpression): Data? {
val resolutionFacade = expression.getResolutionFacade()
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.idea.util.ShortenReferences
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
public class ReconstructTypeInCastOrIsIntention : JetSelfTargetingOffsetIndependentIntention<KtTypeReference>(javaClass(), "Replace by reconstructed type"), LowPriorityAction {
override fun isApplicableTo(element: KtTypeReference): Boolean {
@@ -57,7 +57,7 @@ public class ReconstructTypeInCastOrIsIntention : JetSelfTargetingOffsetIndepend
ShortenReferences.DEFAULT.process(element.replaced(newType))
}
private fun getReconstructedType(typeRef: KtTypeReference): KtType? {
private fun getReconstructedType(typeRef: KtTypeReference): KotlinType? {
return typeRef.analyze().get(BindingContext.TYPE, typeRef)
}
}
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.resolve.calls.CallResolver
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
import org.jetbrains.kotlin.resolve.calls.util.DelegatingCall
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeUtils
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
@@ -79,7 +79,7 @@ public class RemoveExplicitTypeArgumentsIntention : JetSelfTargetingOffsetIndepe
val args = originalCall.getTypeArguments()
val newArgs = resolutionResults.getResultingCall().getTypeArguments()
fun equalTypes(type1: KtType, type2: KtType): Boolean {
fun equalTypes(type1: KotlinType, type2: KotlinType): Boolean {
return if (approximateFlexible) {
KotlinTypeChecker.DEFAULT.equalTypes(type1, type2)
}
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.types.ErrorUtils
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeUtils
import java.util.*
@@ -59,27 +59,27 @@ public class SpecifyTypeExplicitlyIntention : JetSelfTargetingIntention<KtCallab
}
companion object {
public fun getTypeForDeclaration(declaration: KtCallableDeclaration): KtType {
public fun getTypeForDeclaration(declaration: KtCallableDeclaration): KotlinType {
val descriptor = declaration.analyze()[BindingContext.DECLARATION_TO_DESCRIPTOR, declaration]
val type = (descriptor as? CallableDescriptor)?.getReturnType()
return type ?: ErrorUtils.createErrorType("null type")
}
public fun createTypeExpressionForTemplate(exprType: KtType): Expression {
public fun createTypeExpressionForTemplate(exprType: KotlinType): Expression {
val descriptor = exprType.getConstructor().getDeclarationDescriptor()
val isAnonymous = descriptor != null && DescriptorUtils.isAnonymousObject(descriptor)
val allSupertypes = TypeUtils.getAllSupertypes(exprType)
val types = if (isAnonymous) ArrayList<KtType>() else arrayListOf(exprType)
val types = if (isAnonymous) ArrayList<KotlinType>() else arrayListOf(exprType)
types.addAll(allSupertypes)
return object : ChooseValueExpression<KtType>(types, types.first()) {
override fun getLookupString(element: KtType) = IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_IN_TYPES.renderType(element)
override fun getResult(element: KtType) = IdeDescriptorRenderers.SOURCE_CODE.renderType(element)
return object : ChooseValueExpression<KotlinType>(types, types.first()) {
override fun getLookupString(element: KotlinType) = IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_IN_TYPES.renderType(element)
override fun getResult(element: KotlinType) = IdeDescriptorRenderers.SOURCE_CODE.renderType(element)
}
}
public fun addTypeAnnotation(editor: Editor?, declaration: KtCallableDeclaration, exprType: KtType) {
public fun addTypeAnnotation(editor: Editor?, declaration: KtCallableDeclaration, exprType: KotlinType) {
if (editor != null) {
addTypeAnnotationWithTemplate(editor, declaration, exprType)
}
@@ -99,7 +99,7 @@ public class SpecifyTypeExplicitlyIntention : JetSelfTargetingIntention<KtCallab
}
}
private fun addTypeAnnotationWithTemplate(editor: Editor, declaration: KtCallableDeclaration, exprType: KtType) {
private fun addTypeAnnotationWithTemplate(editor: Editor, declaration: KtCallableDeclaration, exprType: KotlinType) {
assert(!exprType.isError()) { "Unexpected error type, should have been checked before: " + declaration.getElementTextWithContext() + ", type = " + exprType }
val project = declaration.getProject()
@@ -52,7 +52,7 @@ import org.jetbrains.kotlin.resolve.scopes.KtScope
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
import org.jetbrains.kotlin.resolve.scopes.utils.asJetScope
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeUtils
class UsePropertyAccessSyntaxInspection : IntentionBasedInspection<KtCallExpression>(UsePropertyAccessSyntaxIntention()), CleanupLocalInspectionTool
@@ -121,7 +121,7 @@ class UsePropertyAccessSyntaxIntention : JetSelfTargetingOffsetIndependentIntent
bindingContext: BindingContext,
resolutionScope: LexicalScope,
dataFlowInfo: DataFlowInfo,
expectedType: KtType,
expectedType: KotlinType,
facade: ResolutionFacade
): Boolean {
val project = resolvedCall.call.callElement.project
@@ -31,9 +31,9 @@ import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
fun KtCallableDeclaration.setType(type: KtType, shortenReferences: Boolean = true) {
fun KtCallableDeclaration.setType(type: KotlinType, shortenReferences: Boolean = true) {
if (type.isError()) return
setType(IdeDescriptorRenderers.SOURCE_CODE.renderType(type), shortenReferences)
}
@@ -46,7 +46,7 @@ fun KtCallableDeclaration.setType(typeString: String, shortenReferences: Boolean
}
}
fun KtCallableDeclaration.setReceiverType(type: KtType) {
fun KtCallableDeclaration.setReceiverType(type: KotlinType) {
if (type.isError()) return
val typeReference = KtPsiFactory(getProject()).createType(IdeDescriptorRenderers.SOURCE_CODE.renderType(type))
setReceiverTypeReference(typeReference)
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.idea.k2jsrun;
import com.intellij.execution.configurations.*;
import com.intellij.openapi.project.Project;
import org.jetbrains.kotlin.idea.KtIcons;
import org.jetbrains.kotlin.idea.KotlinIcons;
public final class K2JSRunConfigurationType extends ConfigurationTypeBase {
public static K2JSRunConfigurationType getInstance() {
@@ -26,7 +26,7 @@ public final class K2JSRunConfigurationType extends ConfigurationTypeBase {
}
public K2JSRunConfigurationType() {
super("K2JSConfigurationType", "Kotlin (JavaScript - experimental)", "Kotlin to JavaScript configuration", KtIcons.LAUNCH);
super("K2JSConfigurationType", "Kotlin (JavaScript - experimental)", "Kotlin to JavaScript configuration", KotlinIcons.LAUNCH);
addFactory(new K2JSConfigurationFactory());
}
@@ -46,7 +46,7 @@ import org.jetbrains.kotlin.resolve.calls.model.ArgumentMatch
import org.jetbrains.kotlin.resolve.calls.util.DelegatingCall
import org.jetbrains.kotlin.resolve.descriptorUtil.hasDefaultValue
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.typeUtil.containsError
import java.awt.Color
import java.util.*
@@ -276,7 +276,7 @@ abstract class KotlinParameterInfoWithCallHandlerBase<TArgumentList : KtElement,
return "..."
}
private fun parameterTypeToRender(descriptor: ValueParameterDescriptor): KtType {
private fun parameterTypeToRender(descriptor: ValueParameterDescriptor): KotlinType {
var type = descriptor.varargElementType ?: descriptor.type
if (type.containsError()) {
val original = descriptor.original
@@ -33,7 +33,7 @@ import org.jetbrains.kotlin.psi.ValueArgument
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
import java.util.*
@@ -41,7 +41,7 @@ public class AddFunctionParametersFix(
private val callElement: KtCallElement,
functionDescriptor: FunctionDescriptor,
private val hasTypeMismatches: Boolean) : ChangeFunctionSignatureFix(callElement, functionDescriptor) {
private val typesToShorten = ArrayList<KtType>()
private val typesToShorten = ArrayList<KotlinType>()
override fun getText(): String {
val parameters = functionDescriptor.valueParameters
@@ -38,7 +38,7 @@ import org.jetbrains.kotlin.psi.KtClass
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtNamedFunction
import org.jetbrains.kotlin.psi.KtPsiFactory
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
import org.jetbrains.kotlin.types.typeUtil.supertypes
import java.util.*
@@ -158,8 +158,8 @@ class AddFunctionToSupertypeFix private constructor(
}
private fun getSuperClasses(classDescriptor: ClassDescriptor): List<ClassDescriptor> {
val supertypes = classDescriptor.defaultType.supertypes().sortedWith(object : Comparator<KtType> {
override fun compare(o1: KtType, o2: KtType): Int {
val supertypes = classDescriptor.defaultType.supertypes().sortedWith(object : Comparator<KotlinType> {
override fun compare(o1: KotlinType, o2: KotlinType): Int {
return when {
o1 == o2 -> 0
KotlinTypeChecker.DEFAULT.isSubtypeOf(o1, o2) -> -1
@@ -33,13 +33,13 @@ import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintsUtil
import org.jetbrains.kotlin.resolve.calls.inference.InferenceErrorData
import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.Variance
import org.jetbrains.kotlin.utils.singletonOrEmptyList
public class AddGenericUpperBoundFix(
typeParameter: KtTypeParameter,
upperBound: KtType
upperBound: KotlinType
) : KotlinQuickFixAction<KtTypeParameter>(typeParameter) {
private val renderedUpperBound: String = IdeDescriptorRenderers.SOURCE_CODE.renderType(upperBound)
@@ -100,7 +100,7 @@ public class AddGenericUpperBoundFix(
}.filterNotNull()
}
private fun createAction(argument: KtType, upperBound: KtType): IntentionAction? {
private fun createAction(argument: KotlinType, upperBound: KotlinType): IntentionAction? {
if (!upperBound.constructor.isDenotable) return null
val typeParameterDescriptor = (argument.constructor.declarationDescriptor as? TypeParameterDescriptor) ?: return null
@@ -25,7 +25,7 @@ import com.intellij.openapi.ui.popup.PopupStep
import com.intellij.openapi.ui.popup.util.BaseListPopupStep
import com.intellij.psi.PsiFile
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.KtIcons
import org.jetbrains.kotlin.idea.KotlinIcons
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.util.application.executeWriteCommand
import org.jetbrains.kotlin.name.Name
@@ -109,7 +109,7 @@ public class AddNameToArgumentFix(argument: KtValueArgument) : KotlinQuickFixAct
return PopupStep.FINAL_CHOICE
}
override fun getIconFor(name: Name) = KtIcons.PARAMETER
override fun getIconFor(name: Name) = KotlinIcons.PARAMETER
override fun getTextFor(name: Name) = createArgumentWithName(name).text
}
@@ -33,13 +33,13 @@ import org.jetbrains.kotlin.idea.util.ShortenReferences;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm;
import org.jetbrains.kotlin.types.FlexibleTypesKt;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
public class CastExpressionFix extends KotlinQuickFixAction<KtExpression> {
private final KtType type;
private final KotlinType type;
public CastExpressionFix(@NotNull KtExpression element, @NotNull KtType type) {
public CastExpressionFix(@NotNull KtExpression element, @NotNull KotlinType type) {
super(element);
this.type = type;
}
@@ -63,7 +63,7 @@ public class CastExpressionFix extends KotlinQuickFixAction<KtExpression> {
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
if (!super.isAvailable(project, editor, file)) return false;
KtType expressionType = ResolutionUtils.analyze(getElement()).getType(getElement());
KotlinType expressionType = ResolutionUtils.analyze(getElement()).getType(getElement());
return expressionType != null
&& (
KotlinTypeChecker.DEFAULT.isSubtypeOf(type, expressionType) // downcast
@@ -104,7 +104,7 @@ public class CastExpressionFix extends KotlinQuickFixAction<KtExpression> {
@Nullable
@Override
public IntentionAction createAction(@NotNull Diagnostic diagnostic) {
DiagnosticWithParameters2<KtExpression, KtType, String> diagnosticWithParameters =
DiagnosticWithParameters2<KtExpression, KotlinType, String> diagnosticWithParameters =
Errors.SMARTCAST_IMPOSSIBLE.cast(diagnostic);
return new CastExpressionFix(diagnosticWithParameters.getPsiElement(), diagnosticWithParameters.getA());
}
@@ -117,7 +117,7 @@ public class CastExpressionFix extends KotlinQuickFixAction<KtExpression> {
@Nullable
@Override
public IntentionAction createAction(@NotNull Diagnostic diagnostic) {
DiagnosticWithParameters2<KtExpression, KtType, KtType> diagnosticWithParameters =
DiagnosticWithParameters2<KtExpression, KotlinType, KotlinType> diagnosticWithParameters =
ErrorsJvm.JAVA_TYPE_MISMATCH.cast(diagnostic);
return new CastExpressionFix(
diagnosticWithParameters.getPsiElement(), FlexibleTypesKt.flexibility(diagnosticWithParameters.getB()).getUpperBound()
@@ -28,10 +28,10 @@ import org.jetbrains.kotlin.idea.core.quickfix.QuickFixUtil;
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers;
import org.jetbrains.kotlin.idea.util.ShortenReferences;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
public class ChangeAccessorTypeFix extends KotlinQuickFixAction<KtPropertyAccessor> {
private KtType type;
private KotlinType type;
public ChangeAccessorTypeFix(@NotNull KtPropertyAccessor element) {
super(element);
@@ -41,7 +41,7 @@ public class ChangeAccessorTypeFix extends KotlinQuickFixAction<KtPropertyAccess
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
KtProperty property = PsiTreeUtil.getParentOfType(getElement(), KtProperty.class);
if (property == null) return false;
KtType type = QuickFixUtil.getDeclarationReturnType(property);
KotlinType type = QuickFixUtil.getDeclarationReturnType(property);
if (super.isAvailable(project, editor, file) && type != null && !type.isError()) {
this.type = type;
return true;
@@ -38,7 +38,7 @@ import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.resolve.BindingContext;
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.TypeProjection;
import org.jetbrains.kotlin.types.TypeUtils;
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
@@ -49,35 +49,35 @@ import java.util.List;
import static org.jetbrains.kotlin.idea.project.PlatformKt.getPlatform;
public class ChangeFunctionLiteralReturnTypeFix extends KotlinQuickFixAction<KtFunctionLiteralExpression> {
private final KtType type;
private final KotlinType type;
private final KtTypeReference functionLiteralReturnTypeRef;
private IntentionAction appropriateQuickFix = null;
public ChangeFunctionLiteralReturnTypeFix(@NotNull KtFunctionLiteralExpression functionLiteralExpression, @NotNull KtType type) {
public ChangeFunctionLiteralReturnTypeFix(@NotNull KtFunctionLiteralExpression functionLiteralExpression, @NotNull KotlinType type) {
super(functionLiteralExpression);
this.type = type;
functionLiteralReturnTypeRef = functionLiteralExpression.getFunctionLiteral().getTypeReference();
AnalysisResult analysisResult = ResolutionUtils.analyzeFullyAndGetResult(functionLiteralExpression.getContainingJetFile());
BindingContext context = analysisResult.getBindingContext();
KtType functionLiteralType = context.getType(functionLiteralExpression);
KotlinType functionLiteralType = context.getType(functionLiteralExpression);
assert functionLiteralType != null : "Type of function literal not available in binding context";
KotlinBuiltIns builtIns = analysisResult.getModuleDescriptor().getBuiltIns();
ClassDescriptor functionClass = builtIns.getFunction(functionLiteralType.getArguments().size() - 1);
List<KtType> functionClassTypeParameters = new LinkedList<KtType>();
List<KotlinType> functionClassTypeParameters = new LinkedList<KotlinType>();
for (TypeProjection typeProjection: functionLiteralType.getArguments()) {
functionClassTypeParameters.add(typeProjection.getType());
}
// Replacing return type:
functionClassTypeParameters.remove(functionClassTypeParameters.size() - 1);
functionClassTypeParameters.add(type);
KtType eventualFunctionLiteralType = TypeUtils.substituteParameters(functionClass, functionClassTypeParameters);
KotlinType eventualFunctionLiteralType = TypeUtils.substituteParameters(functionClass, functionClassTypeParameters);
KtProperty correspondingProperty = PsiTreeUtil.getParentOfType(functionLiteralExpression, KtProperty.class);
if (correspondingProperty != null && QuickFixUtil.canEvaluateTo(correspondingProperty.getInitializer(), functionLiteralExpression)) {
KtTypeReference correspondingPropertyTypeRef = correspondingProperty.getTypeReference();
KtType propertyType = context.get(BindingContext.TYPE, correspondingPropertyTypeRef);
KotlinType propertyType = context.get(BindingContext.TYPE, correspondingPropertyTypeRef);
if (propertyType != null && !KotlinTypeChecker.DEFAULT.isSubtypeOf(eventualFunctionLiteralType, propertyType)) {
appropriateQuickFix = new ChangeVariableTypeFix(correspondingProperty, eventualFunctionLiteralType);
}
@@ -91,7 +91,7 @@ public class ChangeFunctionLiteralReturnTypeFix extends KotlinQuickFixAction<KtF
KtParameter correspondingParameter = QuickFixUtil.getParameterDeclarationForValueArgument(resolvedCall, valueArgument);
if (correspondingParameter != null) {
KtTypeReference correspondingParameterTypeRef = correspondingParameter.getTypeReference();
KtType parameterType = context.get(BindingContext.TYPE, correspondingParameterTypeRef);
KotlinType parameterType = context.get(BindingContext.TYPE, correspondingParameterTypeRef);
if (parameterType != null && !KotlinTypeChecker.DEFAULT.isSubtypeOf(eventualFunctionLiteralType, parameterType)) {
appropriateQuickFix = new ChangeParameterTypeFix(correspondingParameter, eventualFunctionLiteralType);
}
@@ -103,7 +103,7 @@ public class ChangeFunctionLiteralReturnTypeFix extends KotlinQuickFixAction<KtF
KtFunction parentFunction = PsiTreeUtil.getParentOfType(functionLiteralExpression, KtFunction.class, true);
if (parentFunction != null && QuickFixUtil.canFunctionOrGetterReturnExpression(parentFunction, functionLiteralExpression)) {
KtTypeReference parentFunctionReturnTypeRef = parentFunction.getTypeReference();
KtType parentFunctionReturnType = context.get(BindingContext.TYPE, parentFunctionReturnTypeRef);
KotlinType parentFunctionReturnType = context.get(BindingContext.TYPE, parentFunctionReturnTypeRef);
if (parentFunctionReturnType != null && !KotlinTypeChecker.DEFAULT.isSubtypeOf(eventualFunctionLiteralType, parentFunctionReturnType)) {
appropriateQuickFix = new ChangeFunctionReturnTypeFix(parentFunction, eventualFunctionLiteralType);
}
@@ -28,12 +28,12 @@ import org.jetbrains.kotlin.idea.core.KotlinNameSuggester
import org.jetbrains.kotlin.idea.refactoring.changeSignature.*
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtFunctionLiteral
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
class ChangeFunctionLiteralSignatureFix private constructor(
functionLiteral: KtFunctionLiteral,
functionDescriptor: FunctionDescriptor,
private val parameterTypes: List<KtType>
private val parameterTypes: List<KotlinType>
) : ChangeFunctionSignatureFix(functionLiteral, functionDescriptor) {
override fun getText() = "Change the signature of function literal"
@@ -62,7 +62,7 @@ class ChangeFunctionLiteralSignatureFix private constructor(
}
companion object : KotlinSingleIntentionActionFactoryWithDelegate<KtFunctionLiteral, Data>() {
data class Data(val functionLiteral: KtFunctionLiteral, val descriptor: FunctionDescriptor, val parameterTypes: List<KtType>)
data class Data(val functionLiteral: KtFunctionLiteral, val descriptor: FunctionDescriptor, val parameterTypes: List<KotlinType>)
override fun getElementOfInterest(diagnostic: Diagnostic): KtFunctionLiteral? {
val diagnosticWithParameters = Errors.EXPECTED_PARAMETERS_NUMBER_MISMATCH.cast(diagnostic)
@@ -44,7 +44,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt;
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
import org.jetbrains.kotlin.resolve.dataClassUtils.DataClassUtilsKt;
import org.jetbrains.kotlin.types.ErrorUtils;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
import java.util.LinkedList;
@@ -55,10 +55,10 @@ import static org.jetbrains.kotlin.idea.project.PlatformKt.getPlatform;
import static org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt.getBuiltIns;
public class ChangeFunctionReturnTypeFix extends KotlinQuickFixAction<KtFunction> {
private final KtType type;
private final KotlinType type;
private final ChangeFunctionLiteralReturnTypeFix changeFunctionLiteralReturnTypeFix;
public ChangeFunctionReturnTypeFix(@NotNull KtFunction element, @NotNull KtType type) {
public ChangeFunctionReturnTypeFix(@NotNull KtFunction element, @NotNull KotlinType type) {
super(element);
this.type = type;
if (element instanceof KtFunctionLiteral) {
@@ -145,7 +145,7 @@ public class ChangeFunctionReturnTypeFix extends KotlinQuickFixAction<KtFunction
if (resolvedCall == null) return null;
KtFunction componentFunction = (KtFunction) DescriptorToSourceUtils
.descriptorToDeclaration(resolvedCall.getCandidateDescriptor());
KtType expectedType = context.get(BindingContext.TYPE, entry.getTypeReference());
KotlinType expectedType = context.get(BindingContext.TYPE, entry.getTypeReference());
if (componentFunction != null && expectedType != null) {
return new ChangeFunctionReturnTypeFix(componentFunction, expectedType);
}
@@ -207,17 +207,17 @@ public class ChangeFunctionReturnTypeFix extends KotlinQuickFixAction<KtFunction
if (function != null) {
FunctionDescriptor descriptor = (FunctionDescriptor) ResolutionUtils.resolveToDescriptor(function);
KtType matchingReturnType = QuickFixUtil.findLowerBoundOfOverriddenCallablesReturnTypes(descriptor);
KotlinType matchingReturnType = QuickFixUtil.findLowerBoundOfOverriddenCallablesReturnTypes(descriptor);
if (matchingReturnType != null) {
actions.add(new ChangeFunctionReturnTypeFix(function, matchingReturnType));
}
KtType functionType = descriptor.getReturnType();
KotlinType functionType = descriptor.getReturnType();
if (functionType == null) return actions;
List<FunctionDescriptor> overriddenMismatchingFunctions = new LinkedList<FunctionDescriptor>();
for (FunctionDescriptor overriddenFunction: descriptor.getOverriddenDescriptors()) {
KtType overriddenFunctionType = overriddenFunction.getReturnType();
KotlinType overriddenFunctionType = overriddenFunction.getReturnType();
if (overriddenFunctionType == null) continue;
if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(functionType, overriddenFunctionType)) {
overriddenMismatchingFunctions.add(overriddenFunction);
@@ -27,14 +27,14 @@ import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers;
import org.jetbrains.kotlin.idea.util.ShortenReferences;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
public class ChangeParameterTypeFix extends KotlinQuickFixAction<KtParameter> {
private final KtType type;
private final KotlinType type;
private final String containingDeclarationName;
private final boolean isPrimaryConstructorParameter;
public ChangeParameterTypeFix(@NotNull KtParameter element, @NotNull KtType type) {
public ChangeParameterTypeFix(@NotNull KtParameter element, @NotNull KotlinType type) {
super(element);
this.type = type;
KtNamedDeclaration declaration = PsiTreeUtil.getParentOfType(element, KtNamedDeclaration.class);
@@ -33,13 +33,13 @@ import org.jetbrains.kotlin.psi.KtFile;
import org.jetbrains.kotlin.psi.KtParameter;
import org.jetbrains.kotlin.psi.KtPsiFactoryKt;
import org.jetbrains.kotlin.psi.KtTypeReference;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
public class ChangeTypeFix extends KotlinQuickFixAction<KtTypeReference> {
private final KtType type;
private final KotlinType type;
private final String renderedType;
public ChangeTypeFix(@NotNull KtTypeReference element, KtType type) {
public ChangeTypeFix(@NotNull KtTypeReference element, KotlinType type) {
super(element);
this.type = type;
renderedType = IdeDescriptorRenderers.SOURCE_CODE.renderType(type);
@@ -70,7 +70,7 @@ public class ChangeTypeFix extends KotlinQuickFixAction<KtTypeReference> {
@Nullable
@Override
public IntentionAction createAction(@NotNull Diagnostic diagnostic) {
DiagnosticWithParameters1<KtParameter, KtType> diagnosticWithParameters = Errors.EXPECTED_PARAMETER_TYPE_MISMATCH.cast(diagnostic);
DiagnosticWithParameters1<KtParameter, KotlinType> diagnosticWithParameters = Errors.EXPECTED_PARAMETER_TYPE_MISMATCH.cast(diagnostic);
KtTypeReference typeReference = diagnosticWithParameters.getPsiElement().getTypeReference();
assert typeReference != null : "EXPECTED_PARAMETER_TYPE_MISMATCH reported on parameter without explicitly declared type";
return new ChangeTypeFix(typeReference, diagnosticWithParameters.getA());
@@ -40,7 +40,7 @@ import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils;
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
import org.jetbrains.kotlin.types.ErrorUtils;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
import java.util.ArrayList;
@@ -50,9 +50,9 @@ import java.util.List;
public class ChangeVariableTypeFix extends KotlinQuickFixAction<KtVariableDeclaration> {
private final static Logger LOG = Logger.getInstance(ChangeVariableTypeFix.class);
private final KtType type;
private final KotlinType type;
public ChangeVariableTypeFix(@NotNull KtVariableDeclaration element, @NotNull KtType type) {
public ChangeVariableTypeFix(@NotNull KtVariableDeclaration element, @NotNull KotlinType type) {
super(element);
this.type = type;
}
@@ -121,7 +121,7 @@ public class ChangeVariableTypeFix extends KotlinQuickFixAction<KtVariableDeclar
KtFunction componentFunction = (KtFunction) DescriptorToSourceUtils
.descriptorToDeclaration(resolvedCall.getCandidateDescriptor());
if (componentFunction == null) return null;
KtType expectedType = resolvedCall.getCandidateDescriptor().getReturnType();
KotlinType expectedType = resolvedCall.getCandidateDescriptor().getReturnType();
return expectedType == null ? null : new ChangeVariableTypeFix(entry, expectedType);
}
};
@@ -141,16 +141,16 @@ public class ChangeVariableTypeFix extends KotlinQuickFixAction<KtVariableDeclar
if (!(descriptor instanceof PropertyDescriptor)) return actions;
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) descriptor;
KtType
KotlinType
lowerBoundOfOverriddenPropertiesTypes = QuickFixUtil.findLowerBoundOfOverriddenCallablesReturnTypes(propertyDescriptor);
KtType propertyType = propertyDescriptor.getReturnType();
KotlinType propertyType = propertyDescriptor.getReturnType();
assert propertyType != null : "Property type cannot be null if it mismatch something";
List<PropertyDescriptor> overriddenMismatchingProperties = new LinkedList<PropertyDescriptor>();
boolean canChangeOverriddenPropertyType = true;
for (PropertyDescriptor overriddenProperty: propertyDescriptor.getOverriddenDescriptors()) {
KtType overriddenPropertyType = overriddenProperty.getReturnType();
KotlinType overriddenPropertyType = overriddenProperty.getReturnType();
if (overriddenPropertyType != null) {
if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(propertyType, overriddenPropertyType)) {
overriddenMismatchingProperties.add(overriddenProperty);
@@ -38,7 +38,7 @@ 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.resolve.scopes.LexicalScope;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
import org.jetbrains.kotlin.types.typeUtil.TypeUtilsKt;
import java.util.Collections;
@@ -64,21 +64,21 @@ public class QuickFixFactoryForTypeMismatchError extends JetIntentionActionsFact
KtExpression expression = (KtExpression) diagnosticElement;
KtType expectedType;
KtType expressionType;
KotlinType expectedType;
KotlinType expressionType;
if (diagnostic.getFactory() == Errors.TYPE_MISMATCH) {
DiagnosticWithParameters2<KtExpression, KtType, KtType> diagnosticWithParameters = Errors.TYPE_MISMATCH.cast(diagnostic);
DiagnosticWithParameters2<KtExpression, KotlinType, KotlinType> diagnosticWithParameters = Errors.TYPE_MISMATCH.cast(diagnostic);
expectedType = diagnosticWithParameters.getA();
expressionType = diagnosticWithParameters.getB();
}
else if (diagnostic.getFactory() == Errors.NULL_FOR_NONNULL_TYPE) {
DiagnosticWithParameters1<KtConstantExpression, KtType> diagnosticWithParameters =
DiagnosticWithParameters1<KtConstantExpression, KotlinType> diagnosticWithParameters =
Errors.NULL_FOR_NONNULL_TYPE.cast(diagnostic);
expectedType = diagnosticWithParameters.getA();
expressionType = TypeUtilsKt.makeNullable(expectedType);
}
else if (diagnostic.getFactory() == Errors.CONSTANT_EXPECTED_TYPE_MISMATCH) {
DiagnosticWithParameters2<KtConstantExpression, String, KtType> diagnosticWithParameters =
DiagnosticWithParameters2<KtConstantExpression, String, KotlinType> diagnosticWithParameters =
Errors.CONSTANT_EXPECTED_TYPE_MISMATCH.cast(diagnostic);
expectedType = diagnosticWithParameters.getB();
expressionType = context.getType(expression);
@@ -105,7 +105,7 @@ public class QuickFixFactoryForTypeMismatchError extends JetIntentionActionsFact
if (QuickFixUtil.canEvaluateTo(initializer, expression) ||
(getter != null && QuickFixUtil.canFunctionOrGetterReturnExpression(property.getGetter(), expression))) {
LexicalScope scope = UtilsKt.getResolutionScope(property, context, ResolutionUtils.getResolutionFacade(property));
KtType typeToInsert = TypeUtils.approximateWithResolvableType(expressionType, scope, false);
KotlinType typeToInsert = TypeUtils.approximateWithResolvableType(expressionType, scope, false);
actions.add(new ChangeVariableTypeFix(property, typeToInsert));
}
}
@@ -119,7 +119,7 @@ public class QuickFixFactoryForTypeMismatchError extends JetIntentionActionsFact
: PsiTreeUtil.getParentOfType(expression, KtFunction.class, true);
if (function instanceof KtFunction && QuickFixUtil.canFunctionOrGetterReturnExpression(function, expression)) {
LexicalScope scope = UtilsKt.getResolutionScope(function, context, ResolutionUtils.getResolutionFacade(function));
KtType typeToInsert = TypeUtils.approximateWithResolvableType(expressionType, scope, false);
KotlinType typeToInsert = TypeUtils.approximateWithResolvableType(expressionType, scope, false);
actions.add(new ChangeFunctionReturnTypeFix((KtFunction) function, typeToInsert));
}
@@ -154,14 +154,14 @@ public class QuickFixFactoryForTypeMismatchError extends JetIntentionActionsFact
ValueArgument valueArgument = CallUtilKt.getValueArgumentForExpression(resolvedCall.getCall(), argumentExpression);
if (valueArgument != null) {
KtParameter correspondingParameter = QuickFixUtil.getParameterDeclarationForValueArgument(resolvedCall, valueArgument);
KtType valueArgumentType = diagnostic.getFactory() == Errors.NULL_FOR_NONNULL_TYPE
KotlinType valueArgumentType = diagnostic.getFactory() == Errors.NULL_FOR_NONNULL_TYPE
? expressionType
: context.getType(valueArgument.getArgumentExpression());
if (correspondingParameter != null && valueArgumentType != null) {
KtCallableDeclaration callable = PsiTreeUtil.getParentOfType(correspondingParameter, KtCallableDeclaration.class, true);
LexicalScope scope = callable != null ? UtilsKt.getResolutionScope(callable, context, ResolutionUtils
.getResolutionFacade(callable)) : null;
KtType typeToInsert = TypeUtils.approximateWithResolvableType(valueArgumentType, scope, true);
KotlinType typeToInsert = TypeUtils.approximateWithResolvableType(valueArgumentType, scope, true);
actions.add(new ChangeParameterTypeFix(correspondingParameter, typeToInsert));
}
}
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.idea.JetBundle;
import org.jetbrains.kotlin.idea.core.quickfix.QuickFixUtil;
import org.jetbrains.kotlin.idea.intentions.SpecifyTypeExplicitlyIntention;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
public class RemovePartsFromPropertyFix extends KotlinQuickFixAction<KtProperty> {
private final boolean removeInitializer;
@@ -85,13 +85,13 @@ public class RemovePartsFromPropertyFix extends KotlinQuickFixAction<KtProperty>
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
KtType type = QuickFixUtil.getDeclarationReturnType(getElement());
KotlinType type = QuickFixUtil.getDeclarationReturnType(getElement());
return super.isAvailable(project, editor, file) && type != null && !type.isError();
}
@Override
public void invoke(@NotNull Project project, Editor editor, KtFile file) throws IncorrectOperationException {
KtType type = QuickFixUtil.getDeclarationReturnType(getElement());
KotlinType type = QuickFixUtil.getDeclarationReturnType(getElement());
KtProperty newElement = (KtProperty) getElement().copy();
KtPropertyAccessor getter = newElement.getGetter();
if (removeGetter && getter != null) {
@@ -102,7 +102,7 @@ public class RemovePartsFromPropertyFix extends KotlinQuickFixAction<KtProperty>
newElement.deleteChildInternal(setter.getNode());
}
KtExpression initializer = newElement.getInitializer();
KtType typeToAdd = null;
KotlinType typeToAdd = null;
if (removeInitializer && initializer != null) {
PsiElement nameIdentifier = newElement.getNameIdentifier();
assert nameIdentifier != null;
@@ -40,7 +40,7 @@ import org.jetbrains.kotlin.renderer.DescriptorRenderer
import org.jetbrains.kotlin.renderer.render
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.types.IndexedParametersSubstitution
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf
import org.jetbrains.kotlin.utils.addIfNotNull
import java.util.*
@@ -75,7 +75,7 @@ public object SuperClassNotInitialized : JetIntentionActionsFactory() {
.map { it.substitute(substitutor) as ConstructorDescriptor }
if (substitutedConstructors.isNotEmpty()) {
val parameterTypes: List<List<KtType>> = substitutedConstructors.map {
val parameterTypes: List<List<KotlinType>> = substitutedConstructors.map {
it.getValueParameters().map { it.getType() }
}
@@ -66,7 +66,7 @@ import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.scopes.*
import org.jetbrains.kotlin.resolve.scopes.utils.asJetScope
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeProjectionImpl
import org.jetbrains.kotlin.types.Variance
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
@@ -83,7 +83,7 @@ private val ATTRIBUTE_FUNCTION_NAME = "FUNCTION_NAME"
/**
* Represents a single choice for a type (e.g. parameter type or return type).
*/
class TypeCandidate(val theType: KtType, scope: KtScope? = null) {
class TypeCandidate(val theType: KotlinType, scope: KtScope? = null) {
public val typeParameters: Array<TypeParameterDescriptor>
var renderedType: String? = null
private set
@@ -117,7 +117,7 @@ data class RenderedTypeParameter(
val text: String
)
fun List<TypeCandidate>.getTypeByRenderedType(renderedType: String): KtType? =
fun List<TypeCandidate>.getTypeByRenderedType(renderedType: String): KotlinType? =
firstOrNull { it.renderedType == renderedType }?.theType
class CallableBuilderConfiguration(
@@ -166,7 +166,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
val types = typeInfo.getPossibleTypes(this).asReversed()
// We have to use semantic equality here
data class EqWrapper(val _type: KtType) {
data class EqWrapper(val _type: KotlinType) {
override fun equals(other: Any?) = this === other
|| other is EqWrapper && KotlinTypeChecker.DEFAULT.equalTypes(_type, other._type)
override fun hashCode() = 0 // no good way to compute hashCode() that would agree with our equals()
@@ -291,7 +291,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
val fakeFunction: FunctionDescriptor?
// figure out type substitutions for type parameters
val substitutionMap = LinkedHashMap<KtType, KtType>()
val substitutionMap = LinkedHashMap<KotlinType, KotlinType>()
if (config.enableSubstitutions) {
collectSubstitutionsForReceiverTypeParameters(receiverType, substitutionMap)
val typeArgumentsForFakeFunction = callableInfo.typeParameterInfos
@@ -372,8 +372,8 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
}
private fun collectSubstitutionsForReceiverTypeParameters(
receiverType: KtType?,
result: MutableMap<KtType, KtType>
receiverType: KotlinType?,
result: MutableMap<KotlinType, KotlinType>
) {
if (placement is CallablePlacement.NoReceiver) return
@@ -386,8 +386,8 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
private fun collectSubstitutionsForCallableTypeParameters(
fakeFunction: FunctionDescriptor,
typeArguments: Set<KtType>,
result: MutableMap<KtType, KtType>) {
typeArguments: Set<KotlinType>,
result: MutableMap<KotlinType, KotlinType>) {
for ((typeArgument, typeParameter) in typeArguments zip fakeFunction.getTypeParameters()) {
result[typeArgument] = typeParameter.getDefaultType()
}
@@ -842,7 +842,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
return typeParameters
}
private fun replaceWithLongerName(typeRef: KtTypeReference, theType: KtType) {
private fun replaceWithLongerName(typeRef: KtTypeReference, theType: KotlinType) {
val fullyQualifiedReceiverTypeRef = KtPsiFactory(typeRef).createType(theType.renderLong(typeParameterNameMap))
typeRef.replace(fullyQualifiedReceiverTypeRef)
}
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtTypeReference
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.types.ErrorUtils
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.Variance
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
import org.jetbrains.kotlin.types.typeUtil.supertypes
@@ -37,7 +37,7 @@ import java.util.*
*/
abstract class TypeInfo(val variance: Variance) {
object Empty: TypeInfo(Variance.INVARIANT) {
override fun getPossibleTypes(builder: CallableBuilder): List<KtType> = Collections.emptyList()
override fun getPossibleTypes(builder: CallableBuilder): List<KotlinType> = Collections.emptyList()
}
class ByExpression(val expression: KtExpression, variance: Variance): TypeInfo(variance) {
@@ -45,7 +45,7 @@ abstract class TypeInfo(val variance: Variance) {
KotlinNameSuggester.suggestNamesByExpressionOnly(expression, { true }).toTypedArray()
}
override fun getPossibleTypes(builder: CallableBuilder): List<KtType> =
override fun getPossibleTypes(builder: CallableBuilder): List<KotlinType> =
expression.guessTypes(
context = builder.currentFileContext,
module = builder.currentFileModule,
@@ -54,24 +54,24 @@ abstract class TypeInfo(val variance: Variance) {
}
class ByTypeReference(val typeReference: KtTypeReference, variance: Variance): TypeInfo(variance) {
override fun getPossibleTypes(builder: CallableBuilder): List<KtType> =
override fun getPossibleTypes(builder: CallableBuilder): List<KotlinType> =
builder.currentFileContext[BindingContext.TYPE, typeReference].getPossibleSupertypes(variance, builder)
}
class ByType(val theType: KtType, variance: Variance): TypeInfo(variance) {
override fun getPossibleTypes(builder: CallableBuilder): List<KtType> =
class ByType(val theType: KotlinType, variance: Variance): TypeInfo(variance) {
override fun getPossibleTypes(builder: CallableBuilder): List<KotlinType> =
theType.getPossibleSupertypes(variance, builder)
}
class ByReceiverType(variance: Variance): TypeInfo(variance) {
override fun getPossibleTypes(builder: CallableBuilder): List<KtType> =
override fun getPossibleTypes(builder: CallableBuilder): List<KotlinType> =
(builder.placement as CallablePlacement.WithReceiver).receiverTypeCandidate.theType.getPossibleSupertypes(variance, builder)
}
abstract class DelegatingTypeInfo(val delegate: TypeInfo): TypeInfo(delegate.variance) {
override val substitutionsAllowed: Boolean = delegate.substitutionsAllowed
override val possibleNamesFromExpression: Array<String> get() = delegate.possibleNamesFromExpression
override fun getPossibleTypes(builder: CallableBuilder): List<KtType> = delegate.getPossibleTypes(builder)
override fun getPossibleTypes(builder: CallableBuilder): List<KotlinType> = delegate.getPossibleTypes(builder)
}
class NoSubstitutions(delegate: TypeInfo): DelegatingTypeInfo(delegate) {
@@ -85,9 +85,9 @@ abstract class TypeInfo(val variance: Variance) {
open val substitutionsAllowed: Boolean = true
open val staticContextRequired: Boolean = false
open val possibleNamesFromExpression: Array<String> get() = ArrayUtil.EMPTY_STRING_ARRAY
abstract fun getPossibleTypes(builder: CallableBuilder): List<KtType>
abstract fun getPossibleTypes(builder: CallableBuilder): List<KotlinType>
protected fun KtType?.getPossibleSupertypes(variance: Variance, callableBuilder: CallableBuilder): List<KtType> {
protected fun KotlinType?.getPossibleSupertypes(variance: Variance, callableBuilder: CallableBuilder): List<KotlinType> {
if (this == null || ErrorUtils.containsErrorType(this)) {
return Collections.singletonList(callableBuilder.currentFileModule.builtIns.anyType)
}
@@ -101,13 +101,13 @@ abstract class TypeInfo(val variance: Variance) {
fun TypeInfo(expressionOfType: KtExpression, variance: Variance): TypeInfo = TypeInfo.ByExpression(expressionOfType, variance)
fun TypeInfo(typeReference: KtTypeReference, variance: Variance): TypeInfo = TypeInfo.ByTypeReference(typeReference, variance)
fun TypeInfo(theType: KtType, variance: Variance): TypeInfo = TypeInfo.ByType(theType, variance)
fun TypeInfo(theType: KotlinType, variance: Variance): TypeInfo = TypeInfo.ByType(theType, variance)
fun TypeInfo.noSubstitutions(): TypeInfo = (this as? TypeInfo.NoSubstitutions) ?: TypeInfo.NoSubstitutions(this)
fun TypeInfo.forceNotNull(): TypeInfo {
class ForcedNotNull(delegate: TypeInfo): TypeInfo.DelegatingTypeInfo(delegate) {
override fun getPossibleTypes(builder: CallableBuilder): List<KtType> =
override fun getPossibleTypes(builder: CallableBuilder): List<KotlinType> =
super.getPossibleTypes(builder).map { it.makeNotNullable() }
}
@@ -40,11 +40,11 @@ import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
import java.util.*
internal fun KtType.contains(inner: KtType): Boolean {
internal fun KotlinType.contains(inner: KotlinType): Boolean {
return KotlinTypeChecker.DEFAULT.equalTypes(this, inner) || getArguments().any { inner in it.getType() }
}
private fun KtType.render(typeParameterNameMap: Map<TypeParameterDescriptor, String>, fq: Boolean): String {
private fun KotlinType.render(typeParameterNameMap: Map<TypeParameterDescriptor, String>, fq: Boolean): String {
val substitution = typeParameterNameMap
.mapValues {
val name = Name.identifier(it.value)
@@ -63,7 +63,7 @@ private fun KtType.render(typeParameterNameMap: Map<TypeParameterDescriptor, Str
override fun getDeclarationDescriptor() = wrappingTypeParameter
}
val wrappingType = object : KtType by typeParameter.defaultType {
val wrappingType = object : KotlinType by typeParameter.defaultType {
override fun getConstructor() = wrappingTypeConstructor
}
@@ -76,8 +76,8 @@ private fun KtType.render(typeParameterNameMap: Map<TypeParameterDescriptor, Str
return renderer.renderType(typeToRender)
}
internal fun KtType.renderShort(typeParameterNameMap: Map<TypeParameterDescriptor, String>) = render(typeParameterNameMap, false)
internal fun KtType.renderLong(typeParameterNameMap: Map<TypeParameterDescriptor, String>) = render(typeParameterNameMap, true)
internal fun KotlinType.renderShort(typeParameterNameMap: Map<TypeParameterDescriptor, String>) = render(typeParameterNameMap, false)
internal fun KotlinType.renderLong(typeParameterNameMap: Map<TypeParameterDescriptor, String>) = render(typeParameterNameMap, true)
internal fun getTypeParameterNamesNotInScope(typeParameters: Collection<TypeParameterDescriptor>, scope: KtScope): List<TypeParameterDescriptor> {
return typeParameters.filter { typeParameter ->
@@ -86,13 +86,13 @@ internal fun getTypeParameterNamesNotInScope(typeParameters: Collection<TypePara
}
}
fun KtType.containsStarProjections(): Boolean = arguments.any { it.isStarProjection || it.type.containsStarProjections() }
fun KotlinType.containsStarProjections(): Boolean = arguments.any { it.isStarProjection || it.type.containsStarProjections() }
fun KtType.getTypeParameters(): Set<TypeParameterDescriptor> {
val visitedTypes = HashSet<KtType>()
fun KotlinType.getTypeParameters(): Set<TypeParameterDescriptor> {
val visitedTypes = HashSet<KotlinType>()
val typeParameters = LinkedHashSet<TypeParameterDescriptor>()
fun traverseTypes(type: KtType) {
fun traverseTypes(type: KotlinType) {
if (!visitedTypes.add(type)) return
val arguments = type.arguments
@@ -116,7 +116,7 @@ fun KtExpression.guessTypes(
module: ModuleDescriptor,
pseudocode: Pseudocode? = null,
coerceUnusedToUnit: Boolean = true
): Array<KtType> {
): Array<KotlinType> {
if (coerceUnusedToUnit
&& this !is KtDeclaration
&& isUsedAsStatement(context)
@@ -204,7 +204,7 @@ fun KtExpression.guessTypes(
}
}
private fun KtNamedDeclaration.guessType(context: BindingContext): Array<KtType> {
private fun KtNamedDeclaration.guessType(context: BindingContext): Array<KotlinType> {
val expectedTypes = SearchUtils.findAllReferences(this, getUseScope())!!.asSequence().map { ref ->
if (ref is KtSimpleNameReference) {
context[BindingContext.EXPECTED_EXPRESSION_TYPE, ref.expression]
@@ -212,7 +212,7 @@ private fun KtNamedDeclaration.guessType(context: BindingContext): Array<KtType>
else {
null
}
}.filterNotNullTo(HashSet<KtType>())
}.filterNotNullTo(HashSet<KotlinType>())
if (expectedTypes.isEmpty() || expectedTypes.any { expectedType -> ErrorUtils.containsErrorType(expectedType) }) {
return arrayOf()
@@ -228,11 +228,11 @@ private fun KtNamedDeclaration.guessType(context: BindingContext): Array<KtType>
}
/**
* Encapsulates a single type substitution of a <code>KtType</code> by another <code>KtType</code>.
* Encapsulates a single type substitution of a <code>KotlinType</code> by another <code>KotlinType</code>.
*/
internal class JetTypeSubstitution(public val forType: KtType, public val byType: KtType)
internal class JetTypeSubstitution(public val forType: KotlinType, public val byType: KotlinType)
internal fun KtType.substitute(substitution: JetTypeSubstitution, variance: Variance): KtType {
internal fun KotlinType.substitute(substitution: JetTypeSubstitution, variance: Variance): KotlinType {
val nullable = isMarkedNullable()
val currentType = makeNotNullable()
@@ -248,7 +248,7 @@ internal fun KtType.substitute(substitution: JetTypeSubstitution, variance: Vari
val (projection, typeParameter) = pair
TypeProjectionImpl(Variance.INVARIANT, projection.getType().substitute(substitution, typeParameter.getVariance()))
}
return KtTypeImpl.create(getAnnotations(), getConstructor(), isMarkedNullable(), newArguments, getMemberScope())
return KotlinTypeImpl.create(getAnnotations(), getConstructor(), isMarkedNullable(), newArguments, getMemberScope())
}
}
@@ -268,7 +268,7 @@ fun KtCallExpression.getParameterInfos(): List<ParameterInfo> {
}
}
private fun TypePredicate.getRepresentativeTypes(): Set<KtType> {
private fun TypePredicate.getRepresentativeTypes(): Set<KotlinType> {
return when (this) {
is SingleType -> Collections.singleton(targetType)
is AllSubtypes -> Collections.singleton(upperBound)
@@ -276,7 +276,7 @@ private fun TypePredicate.getRepresentativeTypes(): Set<KtType> {
if (typeSets.isEmpty()) AllTypes.getRepresentativeTypes()
else typeSets.map { it.getRepresentativeTypes() }.reduce { a, b -> a intersect b }
}
is ForSomeType -> typeSets.flatMapTo(LinkedHashSet<KtType>()) { it.getRepresentativeTypes() }
is ForSomeType -> typeSets.flatMapTo(LinkedHashSet<KotlinType>()) { it.getRepresentativeTypes() }
is AllTypes -> emptySet()
else -> throw AssertionError("Invalid type predicate: ${this}")
}
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.guessT
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtForExpression
import org.jetbrains.kotlin.types.KtTypeImpl
import org.jetbrains.kotlin.types.KotlinTypeImpl
import org.jetbrains.kotlin.types.TypeProjectionImpl
import org.jetbrains.kotlin.types.Variance
import org.jetbrains.kotlin.util.OperatorNameConventions
@@ -52,7 +52,7 @@ object CreateIteratorFunctionActionFactory : CreateCallableMemberFromUsageFactor
val returnJetTypeParameterType = TypeProjectionImpl(returnJetTypeParameterTypes[0])
val returnJetTypeArguments = Collections.singletonList(returnJetTypeParameterType)
val newReturnJetType = KtTypeImpl.create(returnJetType.annotations,
val newReturnJetType = KotlinTypeImpl.create(returnJetType.annotations,
returnJetType.constructor,
returnJetType.isMarkedNullable,
returnJetTypeArguments,
@@ -40,7 +40,7 @@ import org.jetbrains.kotlin.psi.psiUtil.parents
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.scopes.utils.asJetScope
import org.jetbrains.kotlin.resolve.source.getPsi
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
import java.util.*
@@ -131,7 +131,7 @@ object CreateParameterByRefActionFactory : CreateParameterFromUsageFactory<KtSim
}
}
fun KtType.hasTypeParametersToAdd(functionDescriptor: FunctionDescriptor, context: BindingContext): Boolean {
fun KotlinType.hasTypeParametersToAdd(functionDescriptor: FunctionDescriptor, context: BindingContext): Boolean {
val typeParametersToAdd = LinkedHashSet(getTypeParameters())
typeParametersToAdd.removeAll(functionDescriptor.typeParameters)
if (typeParametersToAdd.isEmpty()) return false
@@ -48,7 +48,7 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
import org.jetbrains.kotlin.resolve.scopes.receivers.ThisReceiver
import org.jetbrains.kotlin.resolve.scopes.utils.asJetScope
import org.jetbrains.kotlin.types.ErrorUtils
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.utils.addIfNotNull
import java.util.*
@@ -214,7 +214,7 @@ private fun ConstructedExpressionWrapper.processValueParameterUsages(
private data class IntroduceValueForParameter(
val parameter: ValueParameterDescriptor,
val value: KtExpression,
val valueType: KtType?)
val valueType: KotlinType?)
private fun ConstructedExpressionWrapper.processTypeParameterUsages(resolvedCall: ResolvedCall<out CallableDescriptor>) {
val typeParameters = resolvedCall.resultingDescriptor.original.typeParameters
@@ -267,7 +267,7 @@ private fun ConstructedExpressionWrapper.processTypeParameterUsages(resolvedCall
}
}
private fun ConstructedExpressionWrapperWithIntroduceFeature.wrapExpressionForSafeCall(receiver: KtExpression, receiverType: KtType?) {
private fun ConstructedExpressionWrapperWithIntroduceFeature.wrapExpressionForSafeCall(receiver: KtExpression, receiverType: KotlinType?) {
val qualified = expression as? KtQualifiedExpression
if (qualified != null) {
if (qualified.receiverExpression[RECEIVER_VALUE_KEY]) {
@@ -322,7 +322,7 @@ private fun KtExpression?.shouldKeepValue(usageCount: Int): Boolean {
private class Argument(
val expression: KtExpression,
val expressionType: KtType?,
val expressionType: KotlinType?,
val isNamed: Boolean = false,
val isDefaultValue: Boolean = false)
@@ -501,7 +501,7 @@ private fun dropArgumentsForDefaultValues(result: KtElement) {
}
}
private fun arrayOfFunctionName(elementType: KtType): String {
private fun arrayOfFunctionName(elementType: KotlinType): String {
return when {
KotlinBuiltIns.isInt(elementType) -> "kotlin.intArrayOf"
KotlinBuiltIns.isLong(elementType) -> "kotlin.longArrayOf"
@@ -629,7 +629,7 @@ private class ConstructedExpressionWrapperWithIntroduceFeature(
public fun introduceValue(
value: KtExpression,
valueType: KtType?,
valueType: KotlinType?,
usages: Collection<KtExpression>,
nameSuggestion: String? = null,
safeCall: Boolean = false
@@ -660,7 +660,7 @@ private class ConstructedExpressionWrapperWithIntroduceFeature(
val resolutionScope = bindingContext[BindingContext.RESOLUTION_SCOPE, expressionToBeReplaced]
if (usages.isNotEmpty()) {
var explicitType: KtType? = null
var explicitType: KotlinType? = null
if (valueType != null && !ErrorUtils.containsErrorType(valueType)) {
val valueTypeWithoutExpectedType = value.computeTypeInContext(
resolutionScope!!,
@@ -56,7 +56,7 @@ import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.KotlinType;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
@@ -402,7 +402,7 @@ public class JetRefactoringUtil {
if (addExpression) {
KtExpression expression = (KtExpression)element;
BindingContext bindingContext = ResolutionUtils.analyze(expression, BodyResolveMode.FULL);
KtType expressionType = bindingContext.getType(expression);
KotlinType expressionType = bindingContext.getType(expression);
if (expressionType == null || !KotlinBuiltIns.isUnit(expressionType)) {
expressions.add(expression);
}
@@ -44,7 +44,7 @@ import org.jetbrains.kotlin.load.java.JvmAbi
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.utils.addToStdlib.singletonOrEmptyList
import java.util.ArrayList
import java.util.HashMap
@@ -53,7 +53,7 @@ import java.util.LinkedHashSet
public open class JetChangeInfo(
val methodDescriptor: JetMethodDescriptor,
private var name: String = methodDescriptor.getName(),
val newReturnType: KtType? = methodDescriptor.baseDescriptor.getReturnType(),
val newReturnType: KotlinType? = methodDescriptor.baseDescriptor.getReturnType(),
var newReturnTypeText: String = methodDescriptor.renderOriginalReturnType(),
var newVisibility: Visibility = methodDescriptor.getVisibility(),
parameterInfos: List<JetParameterInfo> = methodDescriptor.getParameters(),

Some files were not shown because too many files have changed in this diff Show More