Make project compilable after types enhancement
This commit is contained in:
+1
-1
@@ -72,7 +72,7 @@ class AllClassesCompletion(private val parameters: CompletionParameters,
|
||||
}
|
||||
|
||||
private fun PsiClass.isSyntheticKotlinClass(): Boolean {
|
||||
if (!getName().contains('$')) return false // optimization to not analyze annotations of all classes
|
||||
if (!getName()!!.contains('$')) return false // optimization to not analyze annotations of all classes
|
||||
return getModifierList()?.findAnnotation(javaClass<kotlin.jvm.internal.KotlinSyntheticClass>().getName()) != null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,7 +289,7 @@ fun LookupElementFactory.createBackingFieldLookupElement(
|
||||
if (accessors.all { it.getBodyExpression() == null }) return null // makes no sense to access backing field - it's the same as accessing property directly
|
||||
|
||||
val bindingContext = resolutionFacade.analyze(declaration)
|
||||
if (!bindingContext[BindingContext.BACKING_FIELD_REQUIRED, property]) return null
|
||||
if (!bindingContext[BindingContext.BACKING_FIELD_REQUIRED, property]!!) return null
|
||||
|
||||
val lookupElement = createLookupElement(property, true)
|
||||
return object : LookupElementDecorator<LookupElement>(lookupElement) {
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ class KDocNameCompletionSession(parameters: CompletionParameters,
|
||||
val position = parameters.getPosition().getParentOfType<KDocName>(false) ?: return
|
||||
val declaration = position.getContainingDoc().getOwner() ?: return
|
||||
val kdocLink = position.getStrictParentOfType<KDocLink>()!!
|
||||
val declarationDescriptor = bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, declaration]
|
||||
val declarationDescriptor = bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, declaration]!!
|
||||
if (kdocLink.getTagIfSubject()?.knownTag == KDocKnownTag.PARAM) {
|
||||
addParamCompletions(position, declarationDescriptor)
|
||||
} else {
|
||||
|
||||
+2
-2
@@ -104,7 +104,7 @@ public class LookupElementFactory(
|
||||
val lookupObject = object : DeclarationLookupObjectImpl(null, psiClass, resolutionFacade) {
|
||||
override fun getIcon(flags: Int) = psiClass.getIcon(flags)
|
||||
}
|
||||
var element = LookupElementBuilder.create(lookupObject, psiClass.getName())
|
||||
var element = LookupElementBuilder.create(lookupObject, psiClass.getName()!!)
|
||||
.withInsertHandler(KotlinClassInsertHandler)
|
||||
|
||||
val typeParams = psiClass.getTypeParameters()
|
||||
@@ -123,7 +123,7 @@ public class LookupElementFactory(
|
||||
itemText = containerName.substringAfterLast('.') + "." + itemText
|
||||
containerName = containerName.substringBeforeLast('.', FqName.ROOT.toString())
|
||||
}
|
||||
element = element.withPresentableText(itemText)
|
||||
element = element.withPresentableText(itemText!!)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -134,7 +134,7 @@ class ParameterNameAndTypeCompletion(
|
||||
}
|
||||
|
||||
private fun addSuggestionsForJavaClass(psiClass: PsiClass, userPrefix: String, prefixMatcher: PrefixMatcher) {
|
||||
addSuggestions(psiClass.getName(), userPrefix, prefixMatcher, JavaClassType(psiClass))
|
||||
addSuggestions(psiClass.getName()!!, userPrefix, prefixMatcher, JavaClassType(psiClass))
|
||||
}
|
||||
|
||||
private fun addSuggestions(className: String, userPrefix: String, prefixMatcher: PrefixMatcher, type: Type) {
|
||||
|
||||
+2
-2
@@ -39,7 +39,7 @@ object CastReceiverInsertHandler : KotlinCallableInsertHandler() {
|
||||
val project = context.getProject()
|
||||
|
||||
val thisObj = if (descriptor.getExtensionReceiverParameter() != null) descriptor.getExtensionReceiverParameter() else descriptor.getDispatchReceiverParameter()
|
||||
val fqName = IdeDescriptorRenderers.SOURCE_CODE.renderClassifierName(thisObj.getType().getConstructor().getDeclarationDescriptor())
|
||||
val fqName = IdeDescriptorRenderers.SOURCE_CODE.renderClassifierName(thisObj!!.getType().getConstructor().getDeclarationDescriptor()!!)
|
||||
|
||||
val parentCast = JetPsiFactory(project).createExpression("(expr as $fqName)") as JetParenthesizedExpression
|
||||
val cast = parentCast.getExpression() as JetBinaryExpressionWithTypeRHS
|
||||
@@ -51,7 +51,7 @@ object CastReceiverInsertHandler : KotlinCallableInsertHandler() {
|
||||
|
||||
val expr = receiver.replace(parentCast) as JetParenthesizedExpression
|
||||
|
||||
ShortenReferences.DEFAULT.process((expr.getExpression() as JetBinaryExpressionWithTypeRHS).getRight())
|
||||
ShortenReferences.DEFAULT.process((expr.getExpression() as JetBinaryExpressionWithTypeRHS).getRight()!!)
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -50,7 +50,7 @@ object KotlinClassInsertHandler : BaseDeclarationInsertHandler() {
|
||||
|
||||
// first try to resolve short name for faster handling
|
||||
val token = file.findElementAt(startOffset)
|
||||
val nameRef = token.getParent() as? JetNameReferenceExpression
|
||||
val nameRef = token!!.getParent() as? JetNameReferenceExpression
|
||||
if (nameRef != null) {
|
||||
val bindingContext = nameRef.getResolutionFacade().analyze(nameRef, BodyResolveMode.PARTIAL)
|
||||
val target = bindingContext[BindingContext.SHORT_REFERENCE_TO_COMPANION_OBJECT, nameRef]
|
||||
|
||||
+2
-2
@@ -391,7 +391,7 @@ class SmartCompletion(
|
||||
null
|
||||
}
|
||||
|
||||
val scope = bindingContext.get(BindingContext.RESOLUTION_SCOPE, expressionWithType)
|
||||
val scope = bindingContext.get(BindingContext.RESOLUTION_SCOPE, expressionWithType)!!
|
||||
val iterableDetector = IterableTypesDetector(project, moduleDescriptor, scope)
|
||||
|
||||
return buildResultByTypeFilter(expressionWithType, receiver, Tail.RPARENTH) { iterableDetector.isIterable(it, loopVarType) }
|
||||
@@ -403,7 +403,7 @@ class SmartCompletion(
|
||||
if (operationToken != JetTokens.IN_KEYWORD && operationToken != JetTokens.NOT_IN || expressionWithType != binaryExpression.getRight()) return null
|
||||
|
||||
val leftOperandType = binaryExpression.getLeft()?.let { bindingContext.getType(it) } ?: return null
|
||||
val scope = bindingContext.get(BindingContext.RESOLUTION_SCOPE, expressionWithType)
|
||||
val scope = bindingContext.get(BindingContext.RESOLUTION_SCOPE, expressionWithType)!!
|
||||
val detector = TypesWithContainsDetector(scope, leftOperandType, project, moduleDescriptor)
|
||||
|
||||
return buildResultByTypeFilter(expressionWithType, receiver, null) { detector.hasContains(it) }
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ class TypesWithContainsDetector(
|
||||
}
|
||||
|
||||
private fun isGoodContainsFunction(function: FunctionDescriptor, freeTypeParams: Collection<TypeParameterDescriptor>): Boolean {
|
||||
if (!TypeUtils.equalTypes(function.getReturnType(), booleanType)) return false
|
||||
if (!TypeUtils.equalTypes(function.getReturnType()!!, booleanType)) return false
|
||||
val parameter = function.getValueParameters().singleOrNull() ?: return false
|
||||
val parameterType = HeuristicSignatures.correctedParameterType(function, parameter, moduleDescriptor, project) ?: parameter.getType()
|
||||
val fuzzyParameterType = FuzzyType(parameterType, function.getTypeParameters() + freeTypeParams)
|
||||
|
||||
@@ -270,7 +270,7 @@ fun LookupElementFactory.createLookupElement(
|
||||
element = element.keepOldArgumentListOnTab()
|
||||
}
|
||||
|
||||
if (descriptor is ValueParameterDescriptor && bindingContext[BindingContext.AUTO_CREATED_IT, descriptor]) {
|
||||
if (descriptor is ValueParameterDescriptor && bindingContext[BindingContext.AUTO_CREATED_IT, descriptor]!!) {
|
||||
element = element.assignSmartCompletionPriority(SmartCompletionItemPriority.IT)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user