From 9be8501b6054ab0beff64b2d2c93e3abf27360fd Mon Sep 17 00:00:00 2001 From: Natalia Ukhorskaya Date: Thu, 15 May 2014 16:22:43 +0400 Subject: [PATCH] Remove NotNull annotation --- annotations/com/intellij/psi/annotations.xml | 3 --- .../plugin/debugger/evaluate/KotlinEvaluationBuilder.kt | 4 +++- .../intentions/ConvertToForEachFunctionCallIntention.kt | 6 +++--- .../jet/plugin/intentions/InsertExplicitTypeArguments.kt | 3 ++- .../intentions/MakeTypeExplicitInLambdaIntention.kt | 2 +- .../jet/plugin/intentions/OperatorToFunctionIntention.kt | 2 +- .../jet/plugin/quickfix/CreateFunctionFromUsageFix.kt | 4 ++-- .../plugin/refactoring/extractFunction/ExtractionData.kt | 2 +- .../refactoring/extractFunction/extractFunctionUtils.kt | 8 ++++---- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/annotations/com/intellij/psi/annotations.xml b/annotations/com/intellij/psi/annotations.xml index 6312afc8d2a..b5f752134d5 100644 --- a/annotations/com/intellij/psi/annotations.xml +++ b/annotations/com/intellij/psi/annotations.xml @@ -17,9 +17,6 @@ - - - diff --git a/idea/src/org/jetbrains/jet/plugin/debugger/evaluate/KotlinEvaluationBuilder.kt b/idea/src/org/jetbrains/jet/plugin/debugger/evaluate/KotlinEvaluationBuilder.kt index 6f6c7defa34..227c5021a32 100644 --- a/idea/src/org/jetbrains/jet/plugin/debugger/evaluate/KotlinEvaluationBuilder.kt +++ b/idea/src/org/jetbrains/jet/plugin/debugger/evaluate/KotlinEvaluationBuilder.kt @@ -223,7 +223,9 @@ private fun createFileForDebugger(codeFragment: JetCodeFragment, .split(JetCodeFragment.IMPORT_SEPARATOR) .makeString("\n")) - fileText = fileText.replace("!FUNCTION!", extractedFunction.getText()) + val extractedFunctionText = extractedFunction.getText() + assert(extractedFunctionText != null, "Text of extracted function shouldn't be null") + fileText = fileText.replace("!FUNCTION!", extractedFunction.getText()!!) val virtualFile = LightVirtualFile("debugFile.kt", JetLanguage.INSTANCE, fileText) virtualFile.setCharset(CharsetToolkit.UTF8_CHARSET) diff --git a/idea/src/org/jetbrains/jet/plugin/intentions/ConvertToForEachFunctionCallIntention.kt b/idea/src/org/jetbrains/jet/plugin/intentions/ConvertToForEachFunctionCallIntention.kt index 2d6a9870526..1bb58e57946 100644 --- a/idea/src/org/jetbrains/jet/plugin/intentions/ConvertToForEachFunctionCallIntention.kt +++ b/idea/src/org/jetbrains/jet/plugin/intentions/ConvertToForEachFunctionCallIntention.kt @@ -33,7 +33,7 @@ public class ConvertToForEachFunctionCallIntention : JetSelfTargetingIntention): String { return when { statements.isEmpty() -> "" - statements.size() == 1 -> statements[0].getText() + statements.size() == 1 -> statements[0].getText() ?: throw AssertionError("Statements in ForExpression shouldn't be empty: expressionText = ${element.getText()}") else -> statements.fold(StringBuilder(), { acc, h -> acc.append("${h.getText()}\n") }).toString() } } @@ -50,7 +50,7 @@ public class ConvertToForEachFunctionCallIntention : JetSelfTargetingIntention "(${loopRange.getText()})" - else -> loopRange.getText() + else -> loopRange.getText() ?: throw AssertionError("LoopRange in ForExpression shouldn't be empty: expressionText = ${element.getText()}") } } @@ -59,7 +59,7 @@ public class ConvertToForEachFunctionCallIntention : JetSelfTargetingIntention buildStatements(body.getStatements()) - else -> body.getText() + else -> body.getText() ?: throw AssertionError("Body of ForExpression shouldn't be empty: expressionText = ${element.getText()}") }) element.replace(JetPsiFactory.createExpression(element.getProject(), "${buildReceiverText(element)}.forEach { $bodyText }")) diff --git a/idea/src/org/jetbrains/jet/plugin/intentions/InsertExplicitTypeArguments.kt b/idea/src/org/jetbrains/jet/plugin/intentions/InsertExplicitTypeArguments.kt index 2d33ee878ae..5248d503536 100644 --- a/idea/src/org/jetbrains/jet/plugin/intentions/InsertExplicitTypeArguments.kt +++ b/idea/src/org/jetbrains/jet/plugin/intentions/InsertExplicitTypeArguments.kt @@ -34,6 +34,7 @@ public class InsertExplicitTypeArguments : JetSelfTargetingIntention e.getTextRange()!!.getStartOffset() } diff --git a/idea/src/org/jetbrains/jet/plugin/refactoring/extractFunction/extractFunctionUtils.kt b/idea/src/org/jetbrains/jet/plugin/refactoring/extractFunction/extractFunctionUtils.kt index e3a3c490aed..ab2392a9956 100644 --- a/idea/src/org/jetbrains/jet/plugin/refactoring/extractFunction/extractFunctionUtils.kt +++ b/idea/src/org/jetbrains/jet/plugin/refactoring/extractFunction/extractFunctionUtils.kt @@ -412,7 +412,7 @@ private fun ExtractionData.inferParametersInfo( if (hasThisReceiver && extractThis) "this@${parameterType.getConstructor().getDeclarationDescriptor()!!.getName().asString()}" else - (thisExpr ?: ref).getText() + (thisExpr ?: ref).getText() ?: throw AssertionError("'this' reference shouldn't be empty: code fragment = ${getCodeFragmentText()}") val parameter = Parameter(argumentText, parameterName, mirrorVarName, parameterType, extractThis) @@ -623,7 +623,7 @@ fun ExtractionDescriptor.getFunctionText( return FunctionBuilder().let { builder -> builder.modifier(visibility) - builder.typeParams(typeParameters.map { it.originalDeclaration.getText() }) + builder.typeParams(typeParameters.map { it.originalDeclaration.getText()!! }) receiverParameter?.let { builder.receiver(descriptorRenderer.renderType(it.parameterType)) } @@ -637,7 +637,7 @@ fun ExtractionDescriptor.getFunctionText( if (isDefault()) builder.noReturnType() else builder.returnType(descriptorRenderer.renderType(this)) } - builder.typeConstraints(typeParameters.flatMap { it.originalConstraints }.map { it.getText() }) + builder.typeConstraints(typeParameters.flatMap { it.originalConstraints }.map { it.getText()!! }) if (withBody) { builder.blockBody(extractionData.getCodeFragmentText()) @@ -756,7 +756,7 @@ fun ExtractionDescriptor.generateFunction( is ExpressionEvaluation -> body.getStatements().last?.let { - val newExpr = it.replaced(JetPsiFactory.createReturn(project, it.getText())).getReturnedExpression()!! + val newExpr = it.replaced(JetPsiFactory.createReturn(project, it.getText() ?: throw AssertionError("Return expression shouldn't be empty: code fragment = ${body.getText()}"))).getReturnedExpression()!! val counterpartMap = createNameCounterpartMap(it, newExpr) nameByOffset.entrySet().forEach { it.setValue(counterpartMap[it.getValue()]!!) } }