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
@@ -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())