Make project compilable after types enhancement
This commit is contained in:
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import java.util.*
|
||||
|
||||
public class AccessorForConstructorDescriptor(
|
||||
@@ -38,6 +39,8 @@ public class AccessorForConstructorDescriptor(
|
||||
|
||||
override fun isPrimary(): Boolean = false
|
||||
|
||||
override fun getReturnType(): JetType = super<AbstractAccessorForFunctionDescriptor>.getReturnType()!!
|
||||
|
||||
init {
|
||||
initialize(
|
||||
DescriptorUtils.getReceiverParameterType(getExtensionReceiverParameter()),
|
||||
|
||||
@@ -49,7 +49,7 @@ open class BranchedValue(
|
||||
open fun condJump(jumpLabel: Label, v: InstructionAdapter, jumpIfFalse: Boolean) {
|
||||
if (arg1 is CondJump) arg1.condJump(jumpLabel, v, jumpIfFalse) else arg1.put(operandType, v)
|
||||
arg2?.put(operandType, v)
|
||||
v.visitJumpInsn(patchOpcode(if (jumpIfFalse) opcode else negatedOperations[opcode], v), jumpLabel);
|
||||
v.visitJumpInsn(patchOpcode(if (jumpIfFalse) opcode else negatedOperations[opcode]!!, v), jumpLabel);
|
||||
}
|
||||
|
||||
open fun loopJump(jumpLabel: Label, v: InstructionAdapter, jumpIfFalse: Boolean) {
|
||||
|
||||
@@ -284,7 +284,7 @@ class RawFileMapping(val name: String, val path: String) {
|
||||
if (rangeMappings.isNotEmpty() && isLastMapped && couldFoldInRange(lastMappedWithNewIndex, source)) {
|
||||
rangeMapping = rangeMappings.last()
|
||||
rangeMapping.range += source - lastMappedWithNewIndex
|
||||
dest = lineMappings[lastMappedWithNewIndex] + source - lastMappedWithNewIndex
|
||||
dest = lineMappings[lastMappedWithNewIndex]!! + source - lastMappedWithNewIndex
|
||||
}
|
||||
else {
|
||||
dest = currentIndex + 1
|
||||
|
||||
+1
-1
@@ -139,7 +139,7 @@ public object LabelNormalizationMethodTransformer : MethodTransformer() {
|
||||
}
|
||||
|
||||
private fun isRemoved(labelNode: LabelNode): Boolean = removedLabelNodes.contains(labelNode)
|
||||
private fun getNew(oldLabelNode: LabelNode): LabelNode = newLabelNodes[oldLabelNode]
|
||||
private fun getNew(oldLabelNode: LabelNode): LabelNode = newLabelNodes[oldLabelNode]!!
|
||||
}
|
||||
|
||||
private fun InsnList.replaceNodeGetNext(oldNode: AbstractInsnNode, newNode: AbstractInsnNode): AbstractInsnNode? {
|
||||
|
||||
+3
-3
@@ -134,19 +134,19 @@ public class FixStackAnalyzer(
|
||||
val returnValue = pop()
|
||||
clearStack()
|
||||
val savedValues = savedStacks[beforeInlineMarker]
|
||||
pushAll(savedValues)
|
||||
pushAll(savedValues!!)
|
||||
push(returnValue)
|
||||
}
|
||||
else {
|
||||
val savedValues = savedStacks[beforeInlineMarker]
|
||||
pushAll(savedValues)
|
||||
pushAll(savedValues!!)
|
||||
}
|
||||
}
|
||||
|
||||
private fun FixStackFrame.executeRestoreStackInTryCatch(insn: AbstractInsnNode) {
|
||||
val saveNode = context.saveStackMarkerForRestoreMarker[insn]
|
||||
val savedValues = savedStacks.getOrElse(saveNode) {
|
||||
throw AssertionError("${indexOf(insn)}: Restore stack is unavailable for ${indexOf(saveNode)}")
|
||||
throw AssertionError("${indexOf(insn)}: Restore stack is unavailable for ${indexOf(saveNode!!)}")
|
||||
}
|
||||
pushAll(savedValues)
|
||||
}
|
||||
|
||||
+6
-6
@@ -39,7 +39,7 @@ internal class LocalVariablesManager(val context: FixStackContext, val methodNod
|
||||
}
|
||||
|
||||
fun allocateVariablesForSaveStackMarker(saveStackMarker: AbstractInsnNode, savedStackValues: List<BasicValue>): SavedStackDescriptor {
|
||||
val numRestoreStackMarkers = context.restoreStackMarkersForSaveMarker[saveStackMarker].size()
|
||||
val numRestoreStackMarkers = context.restoreStackMarkersForSaveMarker[saveStackMarker]!!.size()
|
||||
return allocateNewHandle(numRestoreStackMarkers, saveStackMarker, savedStackValues)
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ internal class LocalVariablesManager(val context: FixStackContext, val methodNod
|
||||
|
||||
fun getSavedStackDescriptorOrNull(restoreStackMarker: AbstractInsnNode): SavedStackDescriptor {
|
||||
val saveStackMarker = context.saveStackMarkerForRestoreMarker[restoreStackMarker]
|
||||
return allocatedHandles[saveStackMarker].savedStackDescriptor
|
||||
return allocatedHandles[saveStackMarker]!!.savedStackDescriptor
|
||||
}
|
||||
|
||||
private fun getFirstUnusedLocalVariableIndex(): Int =
|
||||
@@ -64,7 +64,7 @@ internal class LocalVariablesManager(val context: FixStackContext, val methodNod
|
||||
|
||||
fun markRestoreStackMarkerEmitted(restoreStackMarker: AbstractInsnNode) {
|
||||
val saveStackMarker = context.saveStackMarkerForRestoreMarker[restoreStackMarker]
|
||||
markEmitted(saveStackMarker)
|
||||
markEmitted(saveStackMarker!!)
|
||||
}
|
||||
|
||||
fun allocateVariablesForBeforeInlineMarker(beforeInlineMarker: AbstractInsnNode, savedStackValues: List<BasicValue>): SavedStackDescriptor {
|
||||
@@ -73,16 +73,16 @@ internal class LocalVariablesManager(val context: FixStackContext, val methodNod
|
||||
|
||||
fun getBeforeInlineDescriptor(afterInlineMarker: AbstractInsnNode): SavedStackDescriptor {
|
||||
val beforeInlineMarker = context.openingInlineMethodMarker[afterInlineMarker]
|
||||
return allocatedHandles[beforeInlineMarker].savedStackDescriptor
|
||||
return allocatedHandles[beforeInlineMarker]!!.savedStackDescriptor
|
||||
}
|
||||
|
||||
fun markAfterInlineMarkerEmitted(afterInlineMarker: AbstractInsnNode) {
|
||||
val beforeInlineMarker = context.openingInlineMethodMarker[afterInlineMarker]
|
||||
markEmitted(beforeInlineMarker)
|
||||
markEmitted(beforeInlineMarker!!)
|
||||
}
|
||||
|
||||
private fun markEmitted(saveStackMarker: AbstractInsnNode) {
|
||||
val allocatedHandle = allocatedHandles[saveStackMarker]
|
||||
val allocatedHandle = allocatedHandles[saveStackMarker]!!
|
||||
allocatedHandle.markRestoreNodeEmitted()
|
||||
if (allocatedHandle.isFullyEmitted()) {
|
||||
allocatedHandles.remove(saveStackMarker)
|
||||
|
||||
@@ -94,7 +94,7 @@ public open class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
|
||||
return INTERNAL_ERROR
|
||||
}
|
||||
catch (e: CliOptionProcessingException) {
|
||||
messageSeverityCollector.report(CompilerMessageSeverity.ERROR, e.getMessage(), CompilerMessageLocation.NO_LOCATION)
|
||||
messageSeverityCollector.report(CompilerMessageSeverity.ERROR, e.getMessage()!!, CompilerMessageLocation.NO_LOCATION)
|
||||
return INTERNAL_ERROR
|
||||
}
|
||||
catch (t: Throwable) {
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@ public class JavaAnnotationCallChecker : CallChecker {
|
||||
if (it.getArgumentExpression() != null) {
|
||||
context.trace.report(
|
||||
diagnostic.on(
|
||||
it.getArgumentExpression()
|
||||
it.getArgumentExpression()!!
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
+3
-3
@@ -172,7 +172,7 @@ public class PublicFieldAnnotationChecker: DeclarationChecker {
|
||||
if (descriptor !is PropertyDescriptor) {
|
||||
report()
|
||||
}
|
||||
else if (!bindingContext.get<PropertyDescriptor, Boolean>(BindingContext.BACKING_FIELD_REQUIRED, descriptor)) {
|
||||
else if (!bindingContext.get<PropertyDescriptor, Boolean>(BindingContext.BACKING_FIELD_REQUIRED, descriptor)!!) {
|
||||
report()
|
||||
}
|
||||
}
|
||||
@@ -301,7 +301,7 @@ public class JavaNullabilityWarningsChecker : AdditionalTypeChecker {
|
||||
val baseExpression = expression.getLeft()
|
||||
val baseExpressionType = baseExpression?.let{ c.trace.getType(it) } ?: return
|
||||
doIfNotNull(
|
||||
DataFlowValueFactory.createDataFlowValue(baseExpression, baseExpressionType, c),
|
||||
DataFlowValueFactory.createDataFlowValue(baseExpression!!, baseExpressionType, c),
|
||||
c
|
||||
) {
|
||||
c.trace.report(Errors.USELESS_ELVIS.on(expression, baseExpressionType))
|
||||
@@ -364,7 +364,7 @@ public class JavaNullabilityWarningsChecker : AdditionalTypeChecker {
|
||||
}
|
||||
else {
|
||||
doIfNotNull(dataFlowValue, c) {
|
||||
c.trace.report(Errors.UNNECESSARY_SAFE_CALL.on(c.call.getCallOperationNode().getPsi(), receiverArgument.getType()))
|
||||
c.trace.report(Errors.UNNECESSARY_SAFE_CALL.on(c.call.getCallOperationNode()!!.getPsi(), receiverArgument.getType()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,7 +289,7 @@ public object PositioningStrategies {
|
||||
|
||||
public val VARIANCE_IN_PROJECTION: PositioningStrategy<JetTypeProjection> = object : PositioningStrategy<JetTypeProjection>() {
|
||||
override fun mark(element: JetTypeProjection): List<TextRange> {
|
||||
return markNode(element.getProjectionNode())
|
||||
return markNode(element.getProjectionNode()!!)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,6 @@ public class KDocLink(node: ASTNode) : JetElementImpl(node) {
|
||||
return if (tag != null && tag.getSubjectLink() == this) tag else null
|
||||
}
|
||||
|
||||
override fun getReferences(): Array<out PsiReference>? =
|
||||
override fun getReferences(): Array<out PsiReference> =
|
||||
ReferenceProvidersRegistry.getReferencesFromProviders(this)
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.lexer.JetTokens
|
||||
public abstract class JetDoubleColonExpression(node: ASTNode) : JetExpressionImpl(node) {
|
||||
public fun getTypeReference(): JetTypeReference? = findChildByType(JetNodeTypes.TYPE_REFERENCE)
|
||||
|
||||
public fun getDoubleColonTokenReference(): PsiElement = findChildByType(JetTokens.COLONCOLON)
|
||||
public fun getDoubleColonTokenReference(): PsiElement = findChildByType(JetTokens.COLONCOLON)!!
|
||||
|
||||
override fun <R, D> accept(visitor: JetVisitor<R, D>, data: D): R {
|
||||
return visitor.visitDoubleColonExpression(this, data)
|
||||
|
||||
@@ -75,5 +75,5 @@ public class JetObjectDeclaration : JetClassOrObject {
|
||||
|
||||
public fun isObjectLiteral(): Boolean = getStub()?.isObjectLiteral() ?: (getParent() is JetObjectLiteralExpression)
|
||||
|
||||
public fun getObjectKeyword(): PsiElement = findChildByType(JetTokens.OBJECT_KEYWORD)
|
||||
public fun getObjectKeyword(): PsiElement = findChildByType(JetTokens.OBJECT_KEYWORD)!!
|
||||
}
|
||||
|
||||
@@ -251,7 +251,7 @@ public class JetPsiFactory(private val project: Project) {
|
||||
}
|
||||
|
||||
public fun createFunctionLiteralParameterList(text: String): JetParameterList {
|
||||
return (createExpression("{ $text -> 0}") as JetFunctionLiteralExpression).getFunctionLiteral().getValueParameterList()
|
||||
return (createExpression("{ $text -> 0}") as JetFunctionLiteralExpression).getFunctionLiteral().getValueParameterList()!!
|
||||
}
|
||||
|
||||
public fun createEnumEntry(text: String): JetEnumEntry {
|
||||
@@ -284,7 +284,7 @@ public class JetPsiFactory(private val project: Project) {
|
||||
}
|
||||
|
||||
public fun createPackageDirective(fqName: FqName): JetPackageDirective {
|
||||
return createFile("package ${fqName.asString()}").getPackageDirective()
|
||||
return createFile("package ${fqName.asString()}").getPackageDirective()!!
|
||||
}
|
||||
|
||||
public fun createPackageDirectiveIfNeeded(fqName: FqName): JetPackageDirective? {
|
||||
|
||||
@@ -39,7 +39,7 @@ public class KotlinStringLiteralTextEscaper(host: JetStringTemplateExpression):
|
||||
}
|
||||
when (child) {
|
||||
is JetLiteralStringTemplateEntry -> {
|
||||
val textRange = rangeInsideHost.intersection(childRange).shiftRight(-childRange.getStartOffset())
|
||||
val textRange = rangeInsideHost.intersection(childRange)!!.shiftRight(-childRange.getStartOffset())
|
||||
outChars.append(child.getText(), textRange.getStartOffset(), textRange.getEndOffset())
|
||||
textRange.getLength().times {
|
||||
sourceOffsetsList.add(sourceOffset++)
|
||||
|
||||
@@ -144,9 +144,9 @@ public fun JetElement.getCalleeHighlightingRange(): TextRange {
|
||||
) ?: return getTextRange()
|
||||
|
||||
val startOffset = annotationEntry.getAtSymbol()?.getTextRange()?.getStartOffset()
|
||||
?: annotationEntry.getCalleeExpression().startOffset
|
||||
?: annotationEntry.getCalleeExpression()!!.startOffset
|
||||
|
||||
return TextRange(startOffset, annotationEntry.getCalleeExpression().endOffset)
|
||||
return TextRange(startOffset, annotationEntry.getCalleeExpression()!!.endOffset)
|
||||
}
|
||||
|
||||
// ---------- Block expression -------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -210,7 +210,7 @@ public class LazyTopDownAnalyzer {
|
||||
}
|
||||
|
||||
override fun visitAnonymousInitializer(initializer: JetClassInitializer) {
|
||||
val classOrObject = PsiTreeUtil.getParentOfType<JetClassOrObject>(initializer, javaClass<JetClassOrObject>())
|
||||
val classOrObject = PsiTreeUtil.getParentOfType<JetClassOrObject>(initializer, javaClass<JetClassOrObject>())!!
|
||||
c.getAnonymousInitializers().put(initializer, lazyDeclarationResolver!!.resolveToDescriptor(classOrObject) as ClassDescriptorWithResolutionScopes)
|
||||
}
|
||||
|
||||
|
||||
@@ -226,7 +226,7 @@ public class TypeResolver(
|
||||
val receiverTypeRef = type.getReceiverTypeReference()
|
||||
val receiverType = if (receiverTypeRef == null) null else resolveType(c.noBareTypes(), receiverTypeRef)
|
||||
|
||||
val parameterTypes = type.getParameters().map { resolveType(c.noBareTypes(), it.getTypeReference()) }
|
||||
val parameterTypes = type.getParameters().map { resolveType(c.noBareTypes(), it.getTypeReference()!!) }
|
||||
|
||||
val returnTypeRef = type.getReturnTypeReference()
|
||||
val returnType = if (returnTypeRef != null)
|
||||
|
||||
@@ -176,7 +176,7 @@ class VarianceChecker(private val trace: BindingTrace) {
|
||||
for (argumentBinding in getArgumentBindings()) {
|
||||
if (argumentBinding == null || argumentBinding.typeParameterDescriptor == null) continue
|
||||
|
||||
val projectionKind = getEffectiveProjectionKind(argumentBinding.typeParameterDescriptor, argumentBinding.typeProjection)!!
|
||||
val projectionKind = getEffectiveProjectionKind(argumentBinding.typeParameterDescriptor!!, argumentBinding.typeProjection)!!
|
||||
val newPosition = when (projectionKind) {
|
||||
OUT -> position
|
||||
IN -> position.opposite()
|
||||
|
||||
@@ -77,7 +77,7 @@ public class CallCompleter(
|
||||
resolvedCall.variableCall.getCall().getCalleeExpression()
|
||||
else
|
||||
resolvedCall.getCall().getCalleeExpression()
|
||||
context.symbolUsageValidator.validateCall(resolvedCall.getResultingDescriptor(), context.trace, element)
|
||||
context.symbolUsageValidator.validateCall(resolvedCall.getResultingDescriptor(), context.trace, element!!)
|
||||
}
|
||||
|
||||
if (results.isSingleResult() && results.getResultingCall().getStatus().isSuccess()) {
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ class CapturingInClosureChecker : CallChecker {
|
||||
if (InlineUtil.isInlinedArgument(scopeDeclaration as JetFunction, context, false)) {
|
||||
val scopeContainerParent = scopeContainer.getContainingDeclaration()
|
||||
assert(scopeContainerParent != null) { "parent is null for " + scopeContainer }
|
||||
return !isCapturedVariable(variableParent, scopeContainerParent) || isCapturedInInline(context, scopeContainerParent, variableParent)
|
||||
return !isCapturedVariable(variableParent, scopeContainerParent!!) || isCapturedInInline(context, scopeContainerParent, variableParent)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
+2
-2
@@ -226,7 +226,7 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT
|
||||
if (argumentForParameter == null) return null
|
||||
|
||||
if (isDivisionByZero(resultingDescriptorName.asString(), argumentForParameter.value)) {
|
||||
val parentExpression: JetExpression = PsiTreeUtil.getParentOfType(receiverExpression, javaClass())
|
||||
val parentExpression: JetExpression = PsiTreeUtil.getParentOfType(receiverExpression, javaClass())!!
|
||||
trace.report(Errors.DIVISION_BY_ZERO.on(parentExpression))
|
||||
return ErrorValue.create("Division by zero")
|
||||
}
|
||||
@@ -406,7 +406,7 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT
|
||||
}
|
||||
|
||||
override fun visitClassLiteralExpression(expression: JetClassLiteralExpression, expectedType: JetType?): CompileTimeConstant<*>? {
|
||||
val jetType = trace.getType(expression)
|
||||
val jetType = trace.getType(expression)!!
|
||||
if (jetType.isError()) return null
|
||||
return KClassValue(jetType)
|
||||
}
|
||||
|
||||
+1
@@ -97,6 +97,7 @@ public class LazyScriptClassMemberScope protected constructor(
|
||||
|
||||
val returnType = scriptDescriptor.getScriptCodeDescriptor().getReturnType()
|
||||
assert(returnType != null) { "Return type not initialized for " + scriptDescriptor }
|
||||
returnType!!
|
||||
|
||||
propertyDescriptor.setType(
|
||||
returnType,
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ public class DeprecatedSymbolValidator : SymbolUsageValidator {
|
||||
override fun validateTypeUsage(targetDescriptor: ClassifierDescriptor, trace: BindingTrace, element: PsiElement) {
|
||||
// Do not check types in annotation entries to prevent cycles in resolve, rely on call message
|
||||
val annotationEntry = JetStubbedPsiUtil.getPsiOrStubParent(element, javaClass<JetAnnotationEntry>(), true)
|
||||
if (annotationEntry != null && annotationEntry.getCalleeExpression().getConstructorReferenceExpression() == element)
|
||||
if (annotationEntry != null && annotationEntry.getCalleeExpression()!!.getConstructorReferenceExpression() == element)
|
||||
return
|
||||
|
||||
// Do not check types in calls to super constructor in extends list, rely on call message
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ public class LockBasedLazyResolveStorageManager(private val storageManager: Stor
|
||||
storageManager.compute { trace.record<K>(slice, key) }
|
||||
}
|
||||
|
||||
override fun <K, V> get(slice: ReadOnlySlice<K, V>, key: K): V = storageManager.compute { trace.get<K, V>(slice, key) }
|
||||
override fun <K, V> get(slice: ReadOnlySlice<K, V>, key: K): V? = storageManager.compute { trace.get<K, V>(slice, key) }
|
||||
|
||||
override fun <K, V> getKeys(slice: WritableSlice<K, V>): Collection<K> = storageManager.compute { trace.getKeys<K, V>(slice) }
|
||||
|
||||
|
||||
+1
-1
@@ -214,7 +214,7 @@ public class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Express
|
||||
// This is needed for ControlStructureTypingVisitor#visitReturnExpression() to properly type-check returned expressions
|
||||
context.trace.record(EXPECTED_RETURN_TYPE, functionLiteral, expectedType)
|
||||
val typeOfBodyExpression = // Type-check the body
|
||||
components.expressionTypingServices.getBlockReturnedType(functionLiteral.getBodyExpression(), COERCION_TO_UNIT, newContext).type
|
||||
components.expressionTypingServices.getBlockReturnedType(functionLiteral.getBodyExpression()!!, COERCION_TO_UNIT, newContext).type
|
||||
|
||||
return declaredReturnType ?: computeReturnTypeBasedOnReturnExpressions(functionLiteral, context, typeOfBodyExpression)
|
||||
}
|
||||
|
||||
+1
-1
@@ -33,6 +33,6 @@ public class KotlinLightMethodForTraitFakeOverride(
|
||||
override fun getOrigin(): JetDeclaration = origin
|
||||
|
||||
override fun copy(): PsiElement {
|
||||
return KotlinLightMethodForTraitFakeOverride(getManager(), delegate, origin.copy() as JetDeclaration, getContainingClass())
|
||||
return KotlinLightMethodForTraitFakeOverride(getManager(), delegate, origin.copy() as JetDeclaration, getContainingClass()!!)
|
||||
}
|
||||
}
|
||||
|
||||
+9
-9
@@ -64,22 +64,22 @@ public object AnnotationSerializer {
|
||||
|
||||
override fun visitBooleanValue(value: BooleanValue, data: Unit) {
|
||||
setType(Type.BOOLEAN)
|
||||
setIntValue(if (value.getValue()) 1 else 0)
|
||||
setIntValue(if (value.getValue()!!) 1 else 0)
|
||||
}
|
||||
|
||||
override fun visitByteValue(value: ByteValue, data: Unit) {
|
||||
setType(Type.BYTE)
|
||||
setIntValue(value.getValue().toLong())
|
||||
setIntValue(value.getValue()!!.toLong())
|
||||
}
|
||||
|
||||
override fun visitCharValue(value: CharValue, data: Unit) {
|
||||
setType(Type.CHAR)
|
||||
setIntValue(value.getValue().toLong())
|
||||
setIntValue(value.getValue()!!.toLong())
|
||||
}
|
||||
|
||||
override fun visitDoubleValue(value: DoubleValue, data: Unit) {
|
||||
setType(Type.DOUBLE)
|
||||
setDoubleValue(value.getValue())
|
||||
setDoubleValue(value.getValue()!!)
|
||||
}
|
||||
|
||||
override fun visitEnumValue(value: EnumValue, data: Unit) {
|
||||
@@ -95,12 +95,12 @@ public object AnnotationSerializer {
|
||||
|
||||
override fun visitFloatValue(value: FloatValue, data: Unit) {
|
||||
setType(Type.FLOAT)
|
||||
setFloatValue(value.getValue())
|
||||
setFloatValue(value.getValue()!!)
|
||||
}
|
||||
|
||||
override fun visitIntValue(value: IntValue, data: Unit) {
|
||||
setType(Type.INT)
|
||||
setIntValue(value.getValue().toLong())
|
||||
setIntValue(value.getValue()!!.toLong())
|
||||
}
|
||||
|
||||
override fun visitKClassValue(value: KClassValue?, data: Unit?) {
|
||||
@@ -110,7 +110,7 @@ public object AnnotationSerializer {
|
||||
|
||||
override fun visitLongValue(value: LongValue, data: Unit) {
|
||||
setType(Type.LONG)
|
||||
setIntValue(value.getValue())
|
||||
setIntValue(value.getValue()!!)
|
||||
}
|
||||
|
||||
override fun visitNullValue(value: NullValue, data: Unit) {
|
||||
@@ -135,12 +135,12 @@ public object AnnotationSerializer {
|
||||
|
||||
override fun visitShortValue(value: ShortValue, data: Unit) {
|
||||
setType(Type.SHORT)
|
||||
setIntValue(value.getValue().toLong())
|
||||
setIntValue(value.getValue()!!.toLong())
|
||||
}
|
||||
|
||||
override fun visitStringValue(value: StringValue, data: Unit) {
|
||||
setType(Type.STRING)
|
||||
setStringValue(nameTable.getStringIndex(value.getValue()))
|
||||
setStringValue(nameTable.getStringIndex(value.getValue()!!))
|
||||
}
|
||||
}, Unit)
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ class LazyOperationsLog(
|
||||
}
|
||||
o.javaClass.getSimpleName() == "LazyJavaClassTypeConstructor" -> {
|
||||
val javaClass = o.field<Any>("this\$0").field<JavaClassImpl>("jClass")
|
||||
javaClass.getPsi().getName().appendQuoted()
|
||||
javaClass.getPsi().getName()!!.appendQuoted()
|
||||
}
|
||||
o.javaClass.getSimpleName() == "DeserializedType" -> {
|
||||
val typeDeserializer = o.field<TypeDeserializer>("typeDeserializer")
|
||||
@@ -161,7 +161,7 @@ class LazyOperationsLog(
|
||||
val text = when (typeProto.getConstructor().getKind()) {
|
||||
ProtoBuf.Type.Constructor.Kind.CLASS -> context.nameResolver.getFqName(typeProto.getConstructor().getId()).asString()
|
||||
ProtoBuf.Type.Constructor.Kind.TYPE_PARAMETER -> {
|
||||
val classifier = (o as JetType).getConstructor().getDeclarationDescriptor()
|
||||
val classifier = (o as JetType).getConstructor().getDeclarationDescriptor()!!
|
||||
"" + classifier.getName() + " in " + DescriptorUtils.getFqName(classifier.getContainingDeclaration())
|
||||
}
|
||||
else -> "???"
|
||||
|
||||
@@ -143,6 +143,7 @@ public class KotlinCliJavaFileManagerTest : PsiTestCase() {
|
||||
val pkg = root.createChildDirectory(this, "foo")
|
||||
val dir = myPsiManager.findDirectory(pkg)
|
||||
TestCase.assertNotNull(dir)
|
||||
dir!!
|
||||
dir.add(PsiFileFactory.getInstance(getProject()).createFileFromText(className + ".java", JavaFileType.INSTANCE, text))
|
||||
val coreJavaFileManagerExt = KotlinCliJavaFileManagerImpl(myPsiManager)
|
||||
coreJavaFileManagerExt.initIndex(JvmDependenciesIndex(listOf(JavaRoot(root, JavaRoot.RootType.SOURCE))))
|
||||
|
||||
@@ -194,9 +194,9 @@ public object InlineTestUtil {
|
||||
override fun getFileContents(): ByteArray = throw UnsupportedOperationException()
|
||||
override fun hashCode(): Int = throw UnsupportedOperationException()
|
||||
override fun equals(other: Any?): Boolean = throw UnsupportedOperationException()
|
||||
override fun toString(): String? = throw UnsupportedOperationException()
|
||||
override fun toString(): String = throw UnsupportedOperationException()
|
||||
}
|
||||
}.getClassHeader()
|
||||
}!!.getClassHeader()
|
||||
}
|
||||
|
||||
private class InlineInfo(val inlineMethods: Set<MethodInfo>, val classHeaders: Map<String, KotlinClassHeader>)
|
||||
|
||||
@@ -79,7 +79,7 @@ public abstract class AbstractDescriptorRendererTest : KotlinTestWithEnvironment
|
||||
is JetPrimaryConstructor -> {
|
||||
val jetClassOrObject: JetClassOrObject = declaringElement.getContainingClassOrObject()
|
||||
val classDescriptor = getDescriptor(jetClassOrObject, resolveSession) as ClassDescriptor
|
||||
addCorrespondingParameterDescriptor(classDescriptor.getUnsubstitutedPrimaryConstructor(), parameter)
|
||||
addCorrespondingParameterDescriptor(classDescriptor.getUnsubstitutedPrimaryConstructor()!!, parameter)
|
||||
}
|
||||
else -> super.visitParameter(parameter)
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public abstract class AbstractResolvedCallsTest : JetLiteFixture() {
|
||||
open protected fun buildCachedCall(
|
||||
bindingContext: BindingContext, jetFile: JetFile, text: String
|
||||
): Pair<PsiElement?, ResolvedCall<out CallableDescriptor>?> {
|
||||
val element = jetFile.findElementAt(text.indexOf("<caret>"))
|
||||
val element = jetFile.findElementAt(text.indexOf("<caret>"))!!
|
||||
val expression = element.getStrictParentOfType<JetExpression>()
|
||||
|
||||
val cachedCall = expression?.getParentResolvedCall(bindingContext, strict = false)
|
||||
|
||||
+1
-1
@@ -106,7 +106,7 @@ public class CapturedTypeApproximationTest() : JetLiteFixture() {
|
||||
val testSubstitutions = createTestSubstitutions(typeParameters)
|
||||
for (testSubstitution in testSubstitutions) {
|
||||
val typeSubstitutor = createTestSubstitutor(testSubstitution)
|
||||
val typeWithCapturedType = typeSubstitutor.substituteWithoutApproximation(TypeProjectionImpl(INVARIANT, type))!!.getType()
|
||||
val typeWithCapturedType = typeSubstitutor.substituteWithoutApproximation(TypeProjectionImpl(INVARIANT, type!!))!!.getType()
|
||||
|
||||
val (lower, upper) = approximateCapturedTypes(typeWithCapturedType)
|
||||
val substitution = approximateCapturedTypesIfNecessary(TypeProjectionImpl(INVARIANT, typeWithCapturedType))
|
||||
|
||||
@@ -63,7 +63,7 @@ fun DeclarationDescriptor.getCapturedTypeParameters(): Collection<TypeParameterD
|
||||
|
||||
public fun JetType.getContainedAndCapturedTypeParameterConstructors(): Collection<TypeConstructor> {
|
||||
// todo type arguments (instead of type parameters) of the type of outer class must be considered; KT-6325
|
||||
val typeParameters = getContainedTypeParameters() + getConstructor().getDeclarationDescriptor().getCapturedTypeParameters()
|
||||
val typeParameters = getContainedTypeParameters() + getConstructor().getDeclarationDescriptor()!!.getCapturedTypeParameters()
|
||||
return typeParameters.map { it.getTypeConstructor() }.toReadOnlyList()
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -170,7 +170,7 @@ public class MemberDeserializer(private val c: DeserializationContext) {
|
||||
}
|
||||
|
||||
private fun valueParameters(callable: Callable, kind: AnnotatedCallableKind): List<ValueParameterDescriptor> {
|
||||
val containerOfCallable = c.containingDeclaration.getContainingDeclaration().asProtoContainer()
|
||||
val containerOfCallable = c.containingDeclaration.getContainingDeclaration()!!.asProtoContainer()
|
||||
|
||||
return callable.getValueParameterList().mapIndexed { i, proto ->
|
||||
ValueParameterDescriptorImpl(
|
||||
|
||||
@@ -102,7 +102,7 @@ public fun CallableDescriptor.substituteExtensionIfCallable(
|
||||
return if (substitutors.any()) listOf(this) else listOf()
|
||||
}
|
||||
else {
|
||||
return substitutors.map { substitute(it) }.toList()
|
||||
return substitutors.map { substitute(it)!! }.toList()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -492,19 +492,19 @@ public abstract class ElementResolver protected constructor(
|
||||
) : BodiesResolveContext {
|
||||
override fun getFiles(): Collection<JetFile> = setOf()
|
||||
|
||||
override fun getDeclaredClasses(): Map<JetClassOrObject, ClassDescriptorWithResolutionScopes> = mapOf()
|
||||
override fun getDeclaredClasses(): MutableMap<JetClassOrObject, ClassDescriptorWithResolutionScopes> = hashMapOf()
|
||||
|
||||
override fun getAnonymousInitializers(): Map<JetClassInitializer, ClassDescriptorWithResolutionScopes> = mapOf()
|
||||
override fun getAnonymousInitializers(): MutableMap<JetClassInitializer, ClassDescriptorWithResolutionScopes> = hashMapOf()
|
||||
|
||||
override fun getSecondaryConstructors(): Map<JetSecondaryConstructor, ConstructorDescriptor> = mapOf()
|
||||
override fun getSecondaryConstructors(): MutableMap<JetSecondaryConstructor, ConstructorDescriptor> = hashMapOf()
|
||||
|
||||
override fun getProperties(): Map<JetProperty, PropertyDescriptor> = mapOf()
|
||||
override fun getProperties(): MutableMap<JetProperty, PropertyDescriptor> = hashMapOf()
|
||||
|
||||
override fun getFunctions(): Map<JetNamedFunction, SimpleFunctionDescriptor> = mapOf()
|
||||
override fun getFunctions(): MutableMap<JetNamedFunction, SimpleFunctionDescriptor> = hashMapOf()
|
||||
|
||||
override fun getDeclaringScope(declaration: JetDeclaration): JetScope? = declaringScopes(declaration)
|
||||
|
||||
override fun getScripts(): Map<JetScript, ScriptDescriptor> = mapOf()
|
||||
override fun getScripts(): MutableMap<JetScript, ScriptDescriptor> = hashMapOf()
|
||||
|
||||
override fun getOuterDataFlowInfo(): DataFlowInfo = DataFlowInfo.EMPTY
|
||||
|
||||
|
||||
+1
-1
@@ -108,7 +108,7 @@ private class ClassClsStubBuilder(
|
||||
val superTypeRefs = supertypeIds.filterNot {
|
||||
//TODO: filtering function types should go away
|
||||
KotlinBuiltIns.isNumberedFunctionClassFqName(it.asSingleFqName().toUnsafe())
|
||||
}.map { it.getShortClassName().ref() }.toTypedArray()
|
||||
}.map { it.getShortClassName().ref()!! }.toTypedArray()
|
||||
return when (classKind) {
|
||||
ProtoBuf.Class.Kind.OBJECT, ProtoBuf.Class.Kind.CLASS_OBJECT -> {
|
||||
KotlinObjectStubImpl(
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ public open class KotlinClsStubBuilder : ClsStubBuilder() {
|
||||
}
|
||||
|
||||
fun doBuildFileStub(file: VirtualFile): PsiFileStub<JetFile>? {
|
||||
val kotlinBinaryClass = KotlinBinaryClassCache.getKotlinBinaryClass(file)
|
||||
val kotlinBinaryClass = KotlinBinaryClassCache.getKotlinBinaryClass(file)!!
|
||||
val header = kotlinBinaryClass.getClassHeader()
|
||||
val classId = kotlinBinaryClass.getClassId()
|
||||
val packageFqName = classId.getPackageFqName()
|
||||
|
||||
+1
-1
@@ -216,7 +216,7 @@ class TypeClsStubBuilder(private val c: ClsStubBuilderContext) {
|
||||
val typeConstraintListStub = KotlinPlaceHolderStubImpl<JetTypeConstraintList>(parent, JetStubElementTypes.TYPE_CONSTRAINT_LIST)
|
||||
for ((name, type) in protosForTypeConstraintList) {
|
||||
val typeConstraintStub = KotlinPlaceHolderStubImpl<JetTypeConstraint>(typeConstraintListStub, JetStubElementTypes.TYPE_CONSTRAINT)
|
||||
KotlinNameReferenceExpressionStubImpl(typeConstraintStub, name.ref())
|
||||
KotlinNameReferenceExpressionStubImpl(typeConstraintStub, name.ref()!!)
|
||||
createTypeReferenceStub(typeConstraintStub, type)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -203,6 +203,6 @@ val ProtoBuf.Callable.annotatedCallableKind: AnnotatedCallableKind
|
||||
}
|
||||
}
|
||||
|
||||
fun Name.ref() = StringRef.fromString(this.asString())
|
||||
fun Name.ref() = StringRef.fromString(this.asString())!!
|
||||
|
||||
fun FqName.ref() = StringRef.fromString(this.asString())
|
||||
fun FqName.ref() = StringRef.fromString(this.asString())!!
|
||||
|
||||
+2
-2
@@ -147,7 +147,7 @@ public fun buildDecompiledText(
|
||||
|
||||
if (descriptor is CallableDescriptor) {
|
||||
//NOTE: assuming that only return types can be flexible
|
||||
if (descriptor.getReturnType().isFlexible()) {
|
||||
if (descriptor.getReturnType()!!.isFlexible()) {
|
||||
builder.append(" ").append(FLEXIBLE_TYPE_COMMENT)
|
||||
}
|
||||
}
|
||||
@@ -191,7 +191,7 @@ public fun buildDecompiledText(
|
||||
companionNeeded = false
|
||||
newlineExceptFirst()
|
||||
builder.append(subindent)
|
||||
appendDescriptor(companionObject, subindent)
|
||||
appendDescriptor(companionObject!!, subindent)
|
||||
}
|
||||
if (member is CallableMemberDescriptor
|
||||
&& member.getKind() != CallableMemberDescriptor.Kind.DECLARATION
|
||||
|
||||
+1
-1
@@ -90,7 +90,7 @@ private object DeclarationKindDetector : JetVisitor<AnnotationHostKind?, Unit?>(
|
||||
override fun visitProperty(d: JetProperty, _: Unit?) = detect(d, d.getValOrVarKeyword().getText()!!)
|
||||
|
||||
override fun visitMultiDeclaration(d: JetMultiDeclaration, _: Unit?) = detect(d, d.getValOrVarKeyword()?.getText() ?: "val",
|
||||
name = d.getEntries().map { it.getName() }.join(", ", "(", ")"))
|
||||
name = d.getEntries().map { it.getName()!! }.join(", ", "(", ")"))
|
||||
|
||||
override fun visitTypeParameter(d: JetTypeParameter, _: Unit?) = detect(d, "type parameter", newLineNeeded = false)
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ public class KDocReference(element: KDocName): JetMultiReference<KDocName>(eleme
|
||||
|
||||
override fun handleElementRename(newElementName: String?): PsiElement? {
|
||||
val textRange = getElement().getNameTextRange()
|
||||
val newText = textRange.replace(getElement().getText(), newElementName)
|
||||
val newText = textRange.replace(getElement().getText(), newElementName!!)
|
||||
val newLink = KDocElementFactory(getElement().getProject()).createNameFromText(newText)
|
||||
return getElement().replace(newLink)
|
||||
}
|
||||
@@ -181,5 +181,5 @@ private fun getOuterScope(descriptor: DeclarationDescriptorWithSource, resolutio
|
||||
return resolutionFacade.getFileTopLevelScope(containingFile)
|
||||
}
|
||||
}
|
||||
return getResolutionScope(resolutionFacade, parent)
|
||||
return getResolutionScope(resolutionFacade, parent!!)
|
||||
}
|
||||
|
||||
+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)
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ fun DeclarationDescriptorWithVisibility.isVisible(
|
||||
|
||||
val receiver = element.getReceiverExpression()
|
||||
val type = receiver?.let { bindingContext.getType(it) }
|
||||
val explicitReceiver = type?.let { ExpressionReceiver(receiver, it) }
|
||||
val explicitReceiver = type?.let { ExpressionReceiver(receiver!!, it) }
|
||||
|
||||
if (explicitReceiver != null) {
|
||||
val normalizeReceiver = ExpressionTypingUtils.normalizeReceiverValueForVisibility(explicitReceiver, bindingContext)
|
||||
|
||||
@@ -37,8 +37,8 @@ public class ExtraSteppingFilter : engine.ExtraSteppingFilter {
|
||||
}
|
||||
|
||||
val debugProcess = context.getDebugProcess()
|
||||
val positionManager = JetPositionManager(debugProcess)
|
||||
val location = context.getFrameProxy().location()
|
||||
val positionManager = JetPositionManager(debugProcess!!)
|
||||
val location = context.getFrameProxy()!!.location()
|
||||
return runReadAction {
|
||||
shouldFilter(positionManager, location)
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public abstract class ConfigureKotlinInProjectAction : AnAction() {
|
||||
if (project == null) return
|
||||
|
||||
if (ConfigureKotlinInProjectUtils.isProjectConfigured(project)) {
|
||||
Messages.showInfoMessage("All modules with kotlin files are configured", e.getPresentation().getText())
|
||||
Messages.showInfoMessage("All modules with kotlin files are configured", e.getPresentation().getText()!!)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -42,9 +42,9 @@ public abstract class ConfigureKotlinInProjectAction : AnAction() {
|
||||
|
||||
when {
|
||||
configurators.size() == 1 -> configurators.first().configure(project)
|
||||
configurators.isEmpty() -> Messages.showErrorDialog("There aren't configurators available", e.getPresentation().getText())
|
||||
configurators.isEmpty() -> Messages.showErrorDialog("There aren't configurators available", e.getPresentation().getText()!!)
|
||||
else -> {
|
||||
Messages.showErrorDialog("More than one configurator is available", e.getPresentation().getText())
|
||||
Messages.showErrorDialog("More than one configurator is available", e.getPresentation().getText()!!)
|
||||
ConfigureKotlinInProjectUtils.showConfigureKotlinNotificationIfNeeded(project)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,7 +303,7 @@ public class KotlinCopyPasteReferenceProcessor() : CopyPastePostProcessor<Kotlin
|
||||
importHelper.importDescriptor(file, descriptor)
|
||||
}
|
||||
for ((pointer, fqName) in bindingRequests) {
|
||||
val reference = pointer.getElement().getReference() as JetSimpleNameReference
|
||||
val reference = pointer.getElement()!!.getReference() as JetSimpleNameReference
|
||||
reference.bindToFqName(fqName, JetSimpleNameReference.ShorteningMode.DELAYED_SHORTENING)
|
||||
}
|
||||
performDelayedShortening(file.getProject())
|
||||
|
||||
+1
-1
@@ -87,7 +87,7 @@ public class KotlinRuntimeTypeCastSurrounder: KotlinExpressionSurrounder() {
|
||||
try {
|
||||
val factory = JetPsiFactory(myElement.getProject())
|
||||
|
||||
val fqName = DescriptorUtils.getFqName(type.getConstructor().getDeclarationDescriptor())
|
||||
val fqName = DescriptorUtils.getFqName(type.getConstructor().getDeclarationDescriptor()!!)
|
||||
val parentCast = factory.createExpression("(expr as " + fqName.asString() + ")") as JetParenthesizedExpression
|
||||
val cast = parentCast.getExpression() as JetBinaryExpressionWithTypeRHS
|
||||
cast.getLeft().replace(myElement)
|
||||
|
||||
@@ -126,7 +126,7 @@ public class KotlinCoverageExtension(): JavaCoverageEngineExtension() {
|
||||
}
|
||||
LOG.debug("Classfiles: [${existingClassFiles.map { it.getName() }.join()}]")
|
||||
return existingClassFiles.map {
|
||||
val relativePath = VfsUtilCore.getRelativePath(it, outputRoot)
|
||||
val relativePath = VfsUtilCore.getRelativePath(it, outputRoot!!)!!
|
||||
StringUtil.trimEnd(relativePath, ".class").replace("/", ".")
|
||||
}
|
||||
}
|
||||
@@ -175,13 +175,13 @@ public class KotlinCoverageExtension(): JavaCoverageEngineExtension() {
|
||||
val inTests = fileIndex.isInTestSourceContent(file.getVirtualFile())
|
||||
val compilerOutputExtension = CompilerModuleExtension.getInstance(module)
|
||||
return if (inTests)
|
||||
compilerOutputExtension.getCompilerOutputPathForTests()
|
||||
compilerOutputExtension!!.getCompilerOutputPathForTests()
|
||||
else
|
||||
compilerOutputExtension.getCompilerOutputPath()
|
||||
compilerOutputExtension!!.getCompilerOutputPath()
|
||||
}
|
||||
|
||||
private fun collectClassFilePrefixes(file: JetFile): Collection<String> {
|
||||
val result = file.getChildren().filter { it is JetClassOrObject }.map { (it as JetClassOrObject).getName() }
|
||||
val result = file.getChildren().filter { it is JetClassOrObject }.map { (it as JetClassOrObject).getName()!! }
|
||||
val packagePartFqName = PackagePartClassUtils.getPackagePartFqName(file)
|
||||
return result.union(arrayListOf(packagePartFqName.shortName().asString()))
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ public class JetPositionManager(private val myDebugProcess: DebugProcess) : Mult
|
||||
if (lineNumber >= 0) {
|
||||
val lambdaOrFunIfInside = getLambdaOrFunIfInside(location, psiFile as JetFile, lineNumber)
|
||||
if (lambdaOrFunIfInside != null) {
|
||||
return SourcePosition.createFromElement(lambdaOrFunIfInside.getBodyExpression())
|
||||
return SourcePosition.createFromElement(lambdaOrFunIfInside.getBodyExpression()!!)
|
||||
}
|
||||
return SourcePosition.createFromLine(psiFile, lineNumber)
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ class KotlinEditorTextProvider : EditorTextProvider {
|
||||
fun PsiElement.isCall() = this is JetCallExpression || this is JetOperationExpression || this is JetArrayAccessExpression
|
||||
|
||||
if (newExpression.isCall() ||
|
||||
newExpression is JetQualifiedExpression && newExpression.getSelectorExpression().isCall()) {
|
||||
newExpression is JetQualifiedExpression && newExpression.getSelectorExpression()!!.isCall()) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ private fun findAdditionalExpressions(position: SourcePosition): Set<TextWithImp
|
||||
if (offset < 0) return emptySet()
|
||||
|
||||
val elem = file.findElementAt(offset)
|
||||
val containingElement = getContainingElement(elem) ?: elem
|
||||
val containingElement = getContainingElement(elem!!) ?: elem
|
||||
|
||||
if (containingElement == null) return emptySet()
|
||||
|
||||
@@ -129,7 +129,7 @@ private fun shouldSkipLine(file: PsiFile, doc: Document, line: Int): Boolean {
|
||||
}
|
||||
|
||||
val elemAtOffset = file.findElementAt(start)
|
||||
val topmostElementAtOffset = CodeInsightUtils.getTopmostElementAtOffset(elemAtOffset, start)
|
||||
val topmostElementAtOffset = CodeInsightUtils.getTopmostElementAtOffset(elemAtOffset!!, start)
|
||||
return topmostElementAtOffset !is JetDeclaration
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ class KotlinFieldBreakpoint(
|
||||
override fun reload(psiFile: PsiFile?) {
|
||||
val property = getProperty(getSourcePosition())
|
||||
if (property != null) {
|
||||
setFieldName(property.getName())
|
||||
setFieldName(property.getName()!!)
|
||||
|
||||
if (property is JetProperty && property.isTopLevel()) {
|
||||
getProperties().myClassName = PackageClassUtils.getPackageClassFqName(property.getContainingJetFile().getPackageFqName()).asString()
|
||||
@@ -196,7 +196,7 @@ class KotlinFieldBreakpoint(
|
||||
descriptor = bindingContext.get(BindingContext.VALUE_PARAMETER_AS_PROPERTY, descriptor)
|
||||
}
|
||||
|
||||
if (bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, descriptor as PropertyDescriptor)) {
|
||||
if (bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, descriptor as PropertyDescriptor)!!) {
|
||||
BreakpointType.FIELD
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -106,7 +106,7 @@ public class KotlinSmartEnterHandler: SmartEnterProcessorWithFixers() {
|
||||
val settings = CodeStyleSettingsManager.getSettings(file.getProject())
|
||||
val old = settings.KEEP_SIMPLE_BLOCKS_IN_ONE_LINE
|
||||
settings.KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = false
|
||||
val elt = file.findElementAt(caretOffset - 1).getStrictParentOfType<JetBlockExpression>()
|
||||
val elt = file.findElementAt(caretOffset - 1)!!.getStrictParentOfType<JetBlockExpression>()
|
||||
if (elt != null) {
|
||||
reformat(elt)
|
||||
}
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ class DelegatingFindMemberUsagesHandler(
|
||||
return kotlinHandler.getPrimaryElements()
|
||||
}
|
||||
|
||||
override fun getSecondaryElements(): Array<out PsiElement>? {
|
||||
override fun getSecondaryElements(): Array<out PsiElement> {
|
||||
return kotlinHandler.getSecondaryElements()
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -119,7 +119,7 @@ public class KotlinFindClassUsagesHandler(
|
||||
var stringsToSearch: Collection<String>
|
||||
object: JavaFindUsagesHandler(psiClass, JavaFindUsagesHandlerFactory.getInstance(element.getProject())) {
|
||||
init {
|
||||
stringsToSearch = getStringsToSearch(psiClass)
|
||||
stringsToSearch = getStringsToSearch(psiClass)!!
|
||||
}
|
||||
}
|
||||
return stringsToSearch
|
||||
|
||||
@@ -30,7 +30,7 @@ public class KotlinTemplatesFactory : ProjectTemplatesFactory() {
|
||||
override fun getGroups() = arrayOf(KOTLIN_GROUP_NAME)
|
||||
override fun getGroupIcon(group: String) = JetIcons.SMALL_LOGO
|
||||
|
||||
override fun createTemplates(group: String, context: WizardContext?) =
|
||||
override fun createTemplates(group: String?, context: WizardContext?) =
|
||||
arrayOf(
|
||||
BuilderBasedTemplate(KotlinModuleBuilder(TargetPlatform.JVM, "Kotlin - JVM", "Kotlin module for JVM target")),
|
||||
BuilderBasedTemplate(KotlinModuleBuilder(TargetPlatform.JS, "Kotlin - JavaScript", "Kotlin module for JavaScript target"))
|
||||
|
||||
@@ -188,7 +188,7 @@ public class UnusedSymbolInspection : AbstractKotlinInspection() {
|
||||
|
||||
private fun isConventionalName(namedDeclaration: JetNamedDeclaration): Boolean {
|
||||
val name = namedDeclaration.getNameAsName()
|
||||
return name.getOperationSymbolsToSearch().isNotEmpty() || name == OperatorConventions.INVOKE
|
||||
return name!!.getOperationSymbolsToSearch().isNotEmpty() || name == OperatorConventions.INVOKE
|
||||
}
|
||||
|
||||
private fun hasNonTrivialUsages(declaration: JetNamedDeclaration): Boolean {
|
||||
@@ -200,7 +200,7 @@ public class UnusedSymbolInspection : AbstractKotlinInspection() {
|
||||
|
||||
for (name in listOf(declaration.getName()) + declaration.getAccessorNames() + declaration.getClassNameForCompanionObject().singletonOrEmptyList()) {
|
||||
assert(name != null) { "Name is null for " + declaration.getElementTextWithContext() }
|
||||
when (psiSearchHelper.isCheapEnoughToSearch(name, useScope, null, null)) {
|
||||
when (psiSearchHelper.isCheapEnoughToSearch(name!!, useScope, null, null)) {
|
||||
ZERO_OCCURRENCES -> {} // go on, check other names
|
||||
FEW_OCCURRENCES -> zeroOccurrences = false
|
||||
TOO_MANY_OCCURRENCES -> return true // searching usages is too expensive; behave like it is used
|
||||
|
||||
+1
-1
@@ -94,7 +94,7 @@ public class DeprecatedCallableAddReplaceWithIntention : JetSelfTargetingRangeIn
|
||||
}.toString()
|
||||
|
||||
var argument = psiFactory.createArgument(psiFactory.createExpression(argumentText))
|
||||
argument = annotationEntry.getValueArgumentList().addArgument(argument)
|
||||
argument = annotationEntry.getValueArgumentList()!!.addArgument(argument)
|
||||
argument = ShortenReferences.DEFAULT.process(argument) as JetValueArgument
|
||||
|
||||
PsiDocumentManager.getInstance(argument.getProject()).doPostponedOperationsAndUnblockDocument(editor.getDocument())
|
||||
|
||||
@@ -50,7 +50,7 @@ public class IterateExpressionIntention : JetSelfTargetingIntention<JetExpressio
|
||||
val bindingContext = expression.analyze(BodyResolveMode.PARTIAL)
|
||||
val type = bindingContext.getType(expression) ?: return null
|
||||
val moduleDescriptor = expression.getResolutionFacade().findModuleDescriptor(expression)
|
||||
val scope = bindingContext[BindingContext.RESOLUTION_SCOPE, expression]
|
||||
val scope = bindingContext[BindingContext.RESOLUTION_SCOPE, expression]!!
|
||||
val elementType = IterableTypesDetector(expression.getProject(), moduleDescriptor, scope).elementType(type)?.type ?: return null
|
||||
return Data(type, elementType)
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ fun isAutoCreatedItUsage(expression: JetSimpleNameExpression): Boolean {
|
||||
val context = expression.analyze()
|
||||
val reference = expression.getReference() as JetReference?
|
||||
val target = reference?.resolveToDescriptors(context)?.singleOrNull() as? ValueParameterDescriptor? ?: return false
|
||||
return context[BindingContext.AUTO_CREATED_IT, target]
|
||||
return context[BindingContext.AUTO_CREATED_IT, target]!!
|
||||
}
|
||||
|
||||
fun JetCallableDeclaration.canRemoveTypeSpecificationByVisibility(): Boolean {
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ fun JetWhenCondition.toExpression(subject: JetExpression?): JetExpression {
|
||||
factory.createExpressionByPattern("$0 == $1", subject, getExpression() ?: "")
|
||||
}
|
||||
else {
|
||||
getExpression()
|
||||
getExpression()!!
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,11 +30,11 @@ public class AddLoopLabelFix(loop: JetLoopExpression, val jumpExpression: JetEle
|
||||
override fun getText() = "Add label to loop"
|
||||
override fun getFamilyName() = getText()
|
||||
|
||||
override fun isAvailable(project: Project, editor: Editor?, file: PsiFile?): Boolean {
|
||||
override fun isAvailable(project: Project, editor: Editor, file: PsiFile): Boolean {
|
||||
return super.isAvailable(project, editor, file)
|
||||
}
|
||||
|
||||
override fun invoke(project: Project, editor: Editor, file: JetFile) {
|
||||
override fun invoke(project: Project, editor: Editor?, file: JetFile) {
|
||||
val usedLabels = collectUsedLabels(element)
|
||||
val labelName = getUniqueLabelName(usedLabels)
|
||||
|
||||
@@ -43,7 +43,7 @@ public class AddLoopLabelFix(loop: JetLoopExpression, val jumpExpression: JetEle
|
||||
|
||||
// TODO(yole) use createExpressionByPattern() once it's available
|
||||
val labeledLoopExpression = JetPsiFactory(project).createLabeledExpression(labelName)
|
||||
labeledLoopExpression.getBaseExpression().replace(element)
|
||||
labeledLoopExpression.getBaseExpression()!!.replace(element)
|
||||
element.replace(labeledLoopExpression)
|
||||
|
||||
// TODO(yole) We should initiate in-place rename for the label here, but in-place rename for labels is not yet implemented
|
||||
|
||||
@@ -86,7 +86,7 @@ public class AutoImportFix(element: JetSimpleNameExpression) : JetHintAction<Jet
|
||||
override fun isAvailable(project: Project, editor: Editor, file: PsiFile)
|
||||
= (super<JetHintAction>.isAvailable(project, editor, file)) && (anySuggestionFound ?: !suggestions.isEmpty())
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: JetFile?) {
|
||||
override fun invoke(project: Project, editor: Editor?, file: JetFile) {
|
||||
CommandProcessor.getInstance().runUndoTransparentAction {
|
||||
createAction(project, editor!!).execute()
|
||||
}
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ class DeprecatedEnumEntryDelimiterSyntaxFix(element: JetEnumEntry): JetIntention
|
||||
|
||||
override fun getText(): String = "Insert lacking comma(s) / semicolon(s)"
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: JetFile?) = insertLackingCommaSemicolon(element)
|
||||
override fun invoke(project: Project, editor: Editor?, file: JetFile) = insertLackingCommaSemicolon(element)
|
||||
|
||||
override fun isAvailable(project: Project, editor: Editor?, file: PsiFile): Boolean
|
||||
= super<JetIntentionAction>.isAvailable(project, editor, file) && DeclarationsChecker.enumEntryUsesDeprecatedOrNoDelimiter(element)
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ class DeprecatedEnumEntrySuperConstructorSyntaxFix(element: JetEnumEntry): JetIn
|
||||
|
||||
override fun getText(): String = "Change to short enum entry super constructor"
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: JetFile?) = changeConstructorToShort(element)
|
||||
override fun invoke(project: Project, editor: Editor?, file: JetFile) = changeConstructorToShort(element)
|
||||
|
||||
override fun isAvailable(project: Project, editor: Editor?, file: PsiFile): Boolean
|
||||
= super<JetIntentionAction>.isAvailable(project, editor, file) && DeclarationsChecker.enumEntryUsesDeprecatedSuperConstructor(element)
|
||||
|
||||
@@ -110,6 +110,7 @@ private class LambdaToFunctionExpression(
|
||||
assert(functionLiteralType != null && KotlinBuiltIns.isExactFunctionOrExtensionFunctionType(functionLiteralType)) {
|
||||
"Broken function type for expression: ${functionLiteralExpression.getText()}, at: ${DiagnosticUtils.atLocation(functionLiteralExpression)}"
|
||||
}
|
||||
functionLiteralType!!
|
||||
receiverType = KotlinBuiltIns.getReceiverType(functionLiteralType)?.let { IdeDescriptorRenderers.SOURCE_CODE.renderType(it) }
|
||||
returnType = KotlinBuiltIns.getReturnTypeFromFunctionType(functionLiteralType).let {
|
||||
if (KotlinBuiltIns.isUnit(it))
|
||||
|
||||
@@ -112,7 +112,7 @@ public abstract class DeprecatedSymbolUsageFixBase(
|
||||
if (pattern.isEmpty()) return null
|
||||
val importValues = replaceWithValue.argumentValue("imports"/*TODO: kotlin.ReplaceWith::imports.name*/) as? List<*> ?: return null
|
||||
if (importValues.any { it !is StringValue }) return null
|
||||
val imports = importValues.map { (it as StringValue).getValue() }
|
||||
val imports = importValues.map { (it as StringValue).getValue()!! }
|
||||
|
||||
// should not be available for descriptors with optional parameters if we cannot fetch default values for them (currently for library with no sources)
|
||||
if (descriptor is CallableDescriptor &&
|
||||
@@ -681,7 +681,7 @@ public abstract class DeprecatedSymbolUsageFixBase(
|
||||
var explicitType: JetType? = null
|
||||
if (valueType != null && !ErrorUtils.containsErrorType(valueType)) {
|
||||
val valueTypeWithoutExpectedType = value.analyzeInContext(
|
||||
resolutionScope,
|
||||
resolutionScope!!,
|
||||
dataFlowInfo = bindingContext.getDataFlowInfo(expressionToBeReplaced)
|
||||
).getType(value)
|
||||
if (valueTypeWithoutExpectedType == null || ErrorUtils.containsErrorType(valueTypeWithoutExpectedType)) {
|
||||
@@ -690,7 +690,7 @@ public abstract class DeprecatedSymbolUsageFixBase(
|
||||
}
|
||||
|
||||
val name = suggestName { name ->
|
||||
resolutionScope.getLocalVariable(Name.identifier(name)) == null && !isNameUsed(name)
|
||||
resolutionScope!!.getLocalVariable(Name.identifier(name)) == null && !isNameUsed(name)
|
||||
}
|
||||
|
||||
var declaration = psiFactory.createDeclarationByPattern<JetVariableDeclaration>("val $0 = $1", name, value)
|
||||
|
||||
@@ -31,7 +31,7 @@ public class DeprecatedTraitSyntaxFix(element: PsiElement): JetIntentionAction<P
|
||||
override fun getFamilyName() = "Replace 'trait' with 'interface'"
|
||||
override fun getText() = getFamilyName()
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: JetFile?)
|
||||
override fun invoke(project: Project, editor: Editor?, file: JetFile)
|
||||
= replaceWithInterfaceKeyword(element)
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public class DeprecatedTraitSyntaxFix(element: PsiElement): JetIntentionAction<P
|
||||
public fun createWholeProjectFixFactory(): JetSingleIntentionActionFactory = createIntentionFactory {
|
||||
JetWholeProjectForEachElementOfTypeFix.createByPredicate<JetClass>(
|
||||
predicate = { it.getNode().findChildByType(JetTokens.TRAIT_KEYWORD) != null },
|
||||
taskProcessor = { replaceWithInterfaceKeyword(it.getNode().findChildByType(JetTokens.TRAIT_KEYWORD).getPsi())},
|
||||
taskProcessor = { replaceWithInterfaceKeyword(it.getNode().findChildByType(JetTokens.TRAIT_KEYWORD)!!.getPsi())},
|
||||
name = "Replace 'trait' with 'interface' in whole project"
|
||||
)
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class RemoveExclExclCallFix(val psiElement: PsiElement) : ExclExclCallFix
|
||||
if (!FileModificationService.getInstance().prepareFileForWrite(file)) return
|
||||
|
||||
val postfixExpression = getExclExclPostfixExpression() ?: return
|
||||
val expression = JetPsiFactory(project).createExpression(postfixExpression.getBaseExpression().getText())
|
||||
val expression = JetPsiFactory(project).createExpression(postfixExpression.getBaseExpression()!!.getText())
|
||||
postfixExpression.replace(expression)
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ public class InsertDelegationCallQuickfix(val isThis: Boolean, element: JetSecon
|
||||
|
||||
private val keywordToUse = if (isThis) "this" else "super"
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: JetFile?) {
|
||||
override fun invoke(project: Project, editor: Editor?, file: JetFile) {
|
||||
val newDelegationCall = element.replaceImplicitDelegationCallWithExplicit(isThis)
|
||||
|
||||
val resolvedCall = newDelegationCall.getResolvedCall(newDelegationCall.analyze())
|
||||
@@ -55,7 +55,7 @@ public class InsertDelegationCallQuickfix(val isThis: Boolean, element: JetSecon
|
||||
editor?.moveCaret(leftParOffset + 1)
|
||||
}
|
||||
|
||||
override fun isAvailable(project: Project, editor: Editor?, file: PsiFile?): Boolean {
|
||||
override fun isAvailable(project: Project, editor: Editor?, file: PsiFile): Boolean {
|
||||
return super.isAvailable(project, editor, file) && element.hasImplicitDelegationCall()
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public class MigrateAnnotationMethodCallFix(
|
||||
override fun getText() = "Replace method call with property access"
|
||||
override fun getFamilyName() = getText()
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: JetFile?) = replaceWithSimpleCall(element)
|
||||
override fun invoke(project: Project, editor: Editor?, file: JetFile) = replaceWithSimpleCall(element)
|
||||
|
||||
companion object : JetSingleIntentionActionFactory() {
|
||||
override fun createAction(diagnostic: Diagnostic) = diagnostic.createIntentionForFirstParentOfType(::MigrateAnnotationMethodCallFix)
|
||||
|
||||
@@ -30,7 +30,7 @@ public class MissingConstructorKeywordFix(element: JetPrimaryConstructor) : JetI
|
||||
override fun getFamilyName(): String = getText()
|
||||
override fun getText(): String = "Add 'constructor' keyword"
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: JetFile?) {
|
||||
override fun invoke(project: Project, editor: Editor?, file: JetFile) {
|
||||
element.addConstructorKeyword()
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.psi.psiUtil.anyDescendantOfType
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
|
||||
public class ReplaceObsoleteLabelSyntaxFix(element: JetAnnotationEntry?) : JetIntentionAction<JetAnnotationEntry>(element), CleanupFix {
|
||||
public class ReplaceObsoleteLabelSyntaxFix(element: JetAnnotationEntry) : JetIntentionAction<JetAnnotationEntry>(element), CleanupFix {
|
||||
override fun getFamilyName(): String = "Update obsolete label syntax"
|
||||
override fun getText(): String = "Replace with label ${element.getCalleeExpression()?.getText() ?: ""}@"
|
||||
|
||||
@@ -65,7 +65,7 @@ public class ReplaceObsoleteLabelSyntaxFix(element: JetAnnotationEntry?) : JetIn
|
||||
|
||||
val baseExpression = (getParent() as? JetAnnotatedExpression)?.getBaseExpression() ?: return false
|
||||
|
||||
val nameExpression = getCalleeExpression().getConstructorReferenceExpression() ?: return false
|
||||
val nameExpression = getCalleeExpression()?.getConstructorReferenceExpression() ?: return false
|
||||
val labelName = nameExpression.getReferencedName()
|
||||
|
||||
return baseExpression.anyDescendantOfType<JetExpressionWithLabel> {
|
||||
|
||||
@@ -182,7 +182,7 @@ object ReplaceWithAnnotationAnalyzer {
|
||||
RedeclarationHandler.DO_NOTHING)
|
||||
is LocalVariableDescriptor -> {
|
||||
val declaration = DescriptorToSourceUtils.descriptorToDeclaration(descriptor) as JetDeclaration
|
||||
declaration.analyze()[BindingContext.RESOLUTION_SCOPE, declaration]
|
||||
declaration.analyze()[BindingContext.RESOLUTION_SCOPE, declaration]!!
|
||||
}
|
||||
|
||||
//TODO?
|
||||
|
||||
+3
-3
@@ -297,7 +297,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
|
||||
.subtract(substitutionMap.keySet())
|
||||
fakeFunction = createFakeFunctionDescriptor(scope, typeArgumentsForFakeFunction.size())
|
||||
collectSubstitutionsForCallableTypeParameters(fakeFunction, typeArgumentsForFakeFunction, substitutionMap)
|
||||
mandatoryTypeParametersAsCandidates = receiverTypeCandidate.singletonOrEmptyList() + typeArgumentsForFakeFunction.map { TypeCandidate(substitutionMap[it], scope) }
|
||||
mandatoryTypeParametersAsCandidates = receiverTypeCandidate.singletonOrEmptyList() + typeArgumentsForFakeFunction.map { TypeCandidate(substitutionMap[it]!!, scope) }
|
||||
}
|
||||
else {
|
||||
fakeFunction = null
|
||||
@@ -949,7 +949,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
|
||||
}
|
||||
is JetProperty -> {
|
||||
if (!declaration.hasInitializer() && containingElement is JetBlockExpression) {
|
||||
val defaultValueType = typeCandidates[callableInfo.returnTypeInfo].firstOrNull()?.theType
|
||||
val defaultValueType = typeCandidates[callableInfo.returnTypeInfo]!!.firstOrNull()?.theType
|
||||
?: KotlinBuiltIns.getInstance().getAnyType()
|
||||
val defaultValue = CodeInsightUtils.defaultInitializer(defaultValueType) ?: "null"
|
||||
val initializer = declaration.setInitializer(JetPsiFactory(declaration).createExpression(defaultValue))!!
|
||||
@@ -975,7 +975,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
|
||||
val caretModel = containingFileEditor.getCaretModel()
|
||||
caretModel.moveToOffset(jetFileToEdit.getNode().getStartOffset())
|
||||
|
||||
val declaration = declarationPointer.getElement()
|
||||
val declaration = declarationPointer.getElement()!!
|
||||
|
||||
val builder = TemplateBuilderImpl(jetFileToEdit)
|
||||
if (declaration is JetProperty) {
|
||||
|
||||
+2
-2
@@ -120,11 +120,11 @@ public abstract class CreateCallableFromUsageFixBase(
|
||||
}
|
||||
}
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: JetFile?) {
|
||||
override fun invoke(project: Project, editor: Editor?, file: JetFile) {
|
||||
val callableInfo = callableInfos.first()
|
||||
|
||||
val callableBuilder =
|
||||
CallableBuilderConfiguration(callableInfos, element as JetElement, file!!, editor!!, isExtension).createBuilder()
|
||||
CallableBuilderConfiguration(callableInfos, element as JetElement, file, editor!!, isExtension).createBuilder()
|
||||
|
||||
fun runBuilder(placement: CallablePlacement) {
|
||||
callableBuilder.placement = placement
|
||||
|
||||
+2
-2
@@ -80,7 +80,7 @@ public class CreateClassFromUsageFix(
|
||||
return true
|
||||
}
|
||||
|
||||
override fun invoke(project: Project, editor: Editor, file: JetFile) {
|
||||
override fun invoke(project: Project, editor: Editor?, file: JetFile) {
|
||||
fun createFileByPackage(psiPackage: PsiPackage): JetFile? {
|
||||
val directories = psiPackage.getDirectories().filter { it.canRefactor() }
|
||||
assert (directories.isNotEmpty()) { "Package '${psiPackage.getQualifiedName()}' must be refactorable" }
|
||||
@@ -103,7 +103,7 @@ public class CreateClassFromUsageFix(
|
||||
val filePath = "${targetDirectory.getVirtualFile().getPath()}/$fileName"
|
||||
CodeInsightUtils.showErrorHint(
|
||||
targetDirectory.getProject(),
|
||||
editor,
|
||||
editor!!,
|
||||
"File $filePath already exists but does not correspond to Kotlin file",
|
||||
"Create file",
|
||||
null
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ object CreateLocalVariableActionFactory: JetSingleIntentionActionFactory() {
|
||||
return object: CreateFromUsageFixBase(refExpr) {
|
||||
override fun getText(): String = JetBundle.message("create.local.variable.from.usage", propertyName)
|
||||
|
||||
override fun invoke(project: Project, editor: Editor, file: JetFile) {
|
||||
override fun invoke(project: Project, editor: Editor?, file: JetFile) {
|
||||
val assignment = refExpr.getAssignmentByLHS()
|
||||
val varExpected = assignment != null
|
||||
var originalElement = assignment ?: refExpr
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ public class CreateParameterFromUsageFix(
|
||||
return JetBundle.message("create.parameter.from.usage", parameterInfo.getName())
|
||||
}
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: JetFile?) {
|
||||
override fun invoke(project: Project, editor: Editor?, file: JetFile) {
|
||||
val config = object : JetChangeSignatureConfiguration {
|
||||
override fun configure(originalDescriptor: JetMethodDescriptor, bindingContext: BindingContext): JetMethodDescriptor {
|
||||
return originalDescriptor.modify { it.addParameter(parameterInfo) }
|
||||
|
||||
@@ -212,7 +212,7 @@ public class JetChangeInfo(
|
||||
public fun renderReturnType(inheritedCallable: JetCallableDefinitionUsage<PsiElement>): String {
|
||||
val typeSubstitutor = inheritedCallable.getOrCreateTypeSubstitutor() ?: return newReturnTypeText
|
||||
val currentBaseFunction = inheritedCallable.getBaseFunction().getCurrentCallableDescriptor() ?: return newReturnTypeText
|
||||
return currentBaseFunction.getReturnType().renderTypeWithSubstitution(typeSubstitutor, newReturnTypeText, false)
|
||||
return currentBaseFunction.getReturnType()!!.renderTypeWithSubstitution(typeSubstitutor, newReturnTypeText, false)
|
||||
}
|
||||
|
||||
public fun primaryMethodUpdated() {
|
||||
|
||||
+1
-1
@@ -171,7 +171,7 @@ public class JetChangeSignature(project: Project,
|
||||
val params = (preview.getParameterList().getParameters() zip ktChangeInfo.getNewParameters()).map {
|
||||
val (param, paramInfo) = it
|
||||
// Keep original default value for proper update of Kotlin usages
|
||||
KotlinAwareJavaParameterInfoImpl(paramInfo.getOldIndex(), param.getName(), param.getType(), paramInfo.defaultValueForCall)
|
||||
KotlinAwareJavaParameterInfoImpl(paramInfo.getOldIndex(), param.getName()!!, param.getType(), paramInfo.defaultValueForCall)
|
||||
}.toTypedArray()
|
||||
|
||||
return preview to JavaChangeInfoImpl(visibility,
|
||||
|
||||
+1
-1
@@ -99,7 +99,7 @@ public class JetChangeSignatureData(
|
||||
descriptorsForSignatureChange.map {
|
||||
val declaration = DescriptorToSourceUtilsIde.getAnyDeclaration(baseDeclaration.getProject(), it)
|
||||
assert(declaration != null) { "No declaration found for " + baseDescriptor }
|
||||
JetCallableDefinitionUsage<PsiElement>(declaration, it, null, null)
|
||||
JetCallableDefinitionUsage<PsiElement>(declaration!!, it, null, null)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ public abstract class AbstractKotlinInplaceIntroducer<D: JetNamedDeclaration>(
|
||||
|
||||
override fun updateTitle(declaration: D?) = updateTitle(declaration, null)
|
||||
|
||||
override fun saveSettings(declaration: D?) {
|
||||
override fun saveSettings(declaration: D) {
|
||||
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -309,7 +309,7 @@ val ControlFlow.possibleReturnTypes: List<JetType>
|
||||
returnType.isAnnotatedNotNull(), returnType.isAnnotatedNullable() ->
|
||||
listOf(approximateFlexibleTypes(returnType))
|
||||
else ->
|
||||
returnType.getCapability(javaClass<Flexibility>()).let { listOf(it.upperBound, it.lowerBound) }
|
||||
returnType.getCapability(javaClass<Flexibility>()).let { listOf(it!!.upperBound, it.lowerBound) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -520,7 +520,7 @@ private class MutableParameter(
|
||||
|
||||
private val defaultType: JetType by Delegates.lazy {
|
||||
writable = false
|
||||
TypeUtils.intersect(JetTypeChecker.DEFAULT, defaultTypes)
|
||||
TypeUtils.intersect(JetTypeChecker.DEFAULT, defaultTypes)!!
|
||||
}
|
||||
|
||||
private val parameterTypeCandidates: List<JetType> by Delegates.lazy {
|
||||
@@ -530,7 +530,7 @@ private class MutableParameter(
|
||||
|
||||
val typeList = if (defaultType.isNullabilityFlexible()) {
|
||||
val bounds = defaultType.getCapability(javaClass<Flexibility>())
|
||||
if (typePredicate(bounds.upperBound)) arrayListOf(bounds.upperBound, bounds.lowerBound) else arrayListOf(bounds.lowerBound)
|
||||
if (typePredicate(bounds!!.upperBound)) arrayListOf(bounds.upperBound, bounds.lowerBound) else arrayListOf(bounds.lowerBound)
|
||||
}
|
||||
else arrayListOf(defaultType)
|
||||
|
||||
|
||||
+2
-2
@@ -275,7 +275,7 @@ private fun makeCall(
|
||||
val inlinableCall = controlFlow.outputValues.size() <= 1
|
||||
val unboxingExpressions =
|
||||
if (inlinableCall) {
|
||||
controlFlow.outputValueBoxer.getUnboxingExpressions(callText)
|
||||
controlFlow.outputValueBoxer.getUnboxingExpressions(callText!!)
|
||||
}
|
||||
else {
|
||||
val varNameValidator = NewDeclarationNameValidator(block, anchorInBlock, NewDeclarationNameValidator.Target.VARIABLES)
|
||||
@@ -293,7 +293,7 @@ private fun makeCall(
|
||||
}
|
||||
|
||||
if (controlFlow.outputValues.isEmpty()) {
|
||||
anchor.replace(psiFactory.createExpression(callText))
|
||||
anchor.replace(psiFactory.createExpression(callText!!))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -135,7 +135,7 @@ public class KotlinInplaceParameterIntroducer(
|
||||
val parameterText = if (parameter == addedParameter){
|
||||
val parameterName = currentName ?: parameter.getName()
|
||||
val parameterType = currentType ?: parameter.getTypeReference()!!.getText()
|
||||
descriptor = descriptor.copy(newParameterName = parameterName, newParameterTypeText = parameterType)
|
||||
descriptor = descriptor.copy(newParameterName = parameterName!!, newParameterTypeText = parameterType)
|
||||
val modifier = if (valVar != JetValVar.None) "${valVar.name} " else ""
|
||||
val defaultValue = if (withDefaultValue) " = ${newArgumentValue.getText()}" else ""
|
||||
|
||||
@@ -250,7 +250,7 @@ public class KotlinInplaceParameterIntroducer(
|
||||
return descriptor.copy(
|
||||
originalRange = originalRange,
|
||||
occurrencesToReplace = if (replaceAll) getOccurrences().map { it.toRange() } else originalRange.singletonList(),
|
||||
newArgumentValue = getExpr()
|
||||
newArgumentValue = getExpr()!!
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user