rename Kt to Kotlin in KtType, KtIcons
This commit is contained in:
@@ -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"
|
||||
|
||||
+4
-4
@@ -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") {
|
||||
|
||||
+2
-2
@@ -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) {
|
||||
|
||||
+3
-3
@@ -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)
|
||||
|
||||
+4
-4
@@ -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)
|
||||
|
||||
+3
-3
@@ -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)
|
||||
}
|
||||
|
||||
+5
-5
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -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() }
|
||||
|
||||
+2
-2
@@ -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() {
|
||||
|
||||
|
||||
+2
-2
@@ -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
|
||||
|
||||
+2
-2
@@ -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) {
|
||||
|
||||
+2
-2
@@ -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) {
|
||||
|
||||
+3
-3
@@ -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() }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user