making LambdaArgument methods nullable
overridden `LambdaArgument.getArgumentExpression` removed because it is already nullable in parent #EA-117013
This commit is contained in:
@@ -173,7 +173,7 @@ class EffectsExtractingVisitor(
|
|||||||
valueArgumentsByIndex?.mapTo(arguments) {
|
valueArgumentsByIndex?.mapTo(arguments) {
|
||||||
val valueArgument = (it as? ExpressionValueArgument)?.valueArgument ?: return null
|
val valueArgument = (it as? ExpressionValueArgument)?.valueArgument ?: return null
|
||||||
when (valueArgument) {
|
when (valueArgument) {
|
||||||
is KtLambdaArgument -> ESLambda(valueArgument.getLambdaExpression())
|
is KtLambdaArgument -> valueArgument.getLambdaExpression()?.let { ESLambda(it) } ?: return null
|
||||||
else -> extractOrGetCached(valueArgument.getArgumentExpression() ?: return null)
|
else -> extractOrGetCached(valueArgument.getArgumentExpression() ?: return null)
|
||||||
}
|
}
|
||||||
} ?: return null
|
} ?: return null
|
||||||
|
|||||||
@@ -20,9 +20,7 @@ import com.intellij.lang.ASTNode
|
|||||||
|
|
||||||
class KtLambdaArgument(node: ASTNode) : KtValueArgument(node), LambdaArgument {
|
class KtLambdaArgument(node: ASTNode) : KtValueArgument(node), LambdaArgument {
|
||||||
|
|
||||||
override fun getArgumentExpression() = super.getArgumentExpression()!!
|
override fun getLambdaExpression(): KtLambdaExpression? = getArgumentExpression()?.unpackFunctionLiteral()
|
||||||
|
|
||||||
override fun getLambdaExpression(): KtLambdaExpression = getArgumentExpression().unpackFunctionLiteral()!!
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun KtExpression.unpackFunctionLiteral(allowParentheses: Boolean = false): KtLambdaExpression? {
|
fun KtExpression.unpackFunctionLiteral(allowParentheses: Boolean = false): KtLambdaExpression? {
|
||||||
|
|||||||
@@ -37,9 +37,7 @@ interface ValueArgument {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface LambdaArgument : ValueArgument {
|
interface LambdaArgument : ValueArgument {
|
||||||
fun getLambdaExpression(): KtLambdaExpression
|
fun getLambdaExpression(): KtLambdaExpression?
|
||||||
|
|
||||||
override fun getArgumentExpression(): KtExpression
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ValueArgumentName {
|
interface ValueArgumentName {
|
||||||
|
|||||||
@@ -31,11 +31,8 @@ import org.jetbrains.kotlin.resolve.scopes.MemberScopeImpl
|
|||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver
|
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver
|
||||||
import org.jetbrains.kotlin.storage.StorageManager
|
import org.jetbrains.kotlin.storage.StorageManager
|
||||||
import org.jetbrains.kotlin.storage.getValue
|
import org.jetbrains.kotlin.storage.getValue
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.*
|
||||||
import org.jetbrains.kotlin.types.Variance
|
|
||||||
import org.jetbrains.kotlin.types.createDynamicType
|
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
||||||
import org.jetbrains.kotlin.types.isDynamic
|
|
||||||
import org.jetbrains.kotlin.utils.Printer
|
import org.jetbrains.kotlin.utils.Printer
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@@ -53,7 +50,8 @@ class DynamicCallableDescriptors(storageManager: StorageManager, builtIns: Kotli
|
|||||||
override fun getContributedFunctions(name: Name, location: LookupLocation): Collection<SimpleFunctionDescriptor> {
|
override fun getContributedFunctions(name: Name, location: LookupLocation): Collection<SimpleFunctionDescriptor> {
|
||||||
if (isAugmentedAssignmentConvention(name)) return listOf()
|
if (isAugmentedAssignmentConvention(name)) return listOf()
|
||||||
if (call.callType == Call.CallType.INVOKE
|
if (call.callType == Call.CallType.INVOKE
|
||||||
&& call.valueArgumentList == null && call.functionLiteralArguments.isEmpty()) {
|
&& call.valueArgumentList == null && call.functionLiteralArguments.isEmpty()
|
||||||
|
) {
|
||||||
// this means that we are looking for "imaginary" invokes,
|
// this means that we are looking for "imaginary" invokes,
|
||||||
// e.g. in `+d` we are looking for property "plus" with member "invoke"
|
// e.g. in `+d` we are looking for property "plus" with member "invoke"
|
||||||
return listOf()
|
return listOf()
|
||||||
@@ -217,7 +215,10 @@ class DynamicCallableDescriptors(storageManager: StorageManager, builtIns: Kotli
|
|||||||
|
|
||||||
if (hasSpreadOperator) {
|
if (hasSpreadOperator) {
|
||||||
for (funLiteralArg in call.functionLiteralArguments) {
|
for (funLiteralArg in call.functionLiteralArguments) {
|
||||||
addParameter(funLiteralArg, getFunctionType(funLiteralArg.getLambdaExpression()), null)
|
addParameter(
|
||||||
|
funLiteralArg,
|
||||||
|
funLiteralArg.getLambdaExpression()?.let { getFunctionType(it) } ?: TypeUtils.CANT_INFER_FUNCTION_PARAM_TYPE,
|
||||||
|
null)
|
||||||
}
|
}
|
||||||
|
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -462,8 +462,8 @@ class PSICallResolver(
|
|||||||
oldCall.valueArguments.last()
|
oldCall.valueArguments.last()
|
||||||
} else {
|
} else {
|
||||||
if (externalLambdaArguments.size > 2) {
|
if (externalLambdaArguments.size > 2) {
|
||||||
externalLambdaArguments.drop(1).forEach {
|
externalLambdaArguments.drop(1).mapNotNull { it.getLambdaExpression() }.forEach {
|
||||||
context.trace.report(Errors.MANY_LAMBDA_EXPRESSION_ARGUMENTS.on(it.getLambdaExpression()))
|
context.trace.report(Errors.MANY_LAMBDA_EXPRESSION_ARGUMENTS.on(it))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-5
@@ -50,17 +50,13 @@ class ErrorExpressionGenerator(statementGenerator: StatementGenerator) : Stateme
|
|||||||
receiverExpression.genExpr()
|
receiverExpression.genExpr()
|
||||||
}
|
}
|
||||||
|
|
||||||
ktCall.valueArguments.forEach {
|
(ktCall.valueArguments + ktCall.lambdaArguments).forEach {
|
||||||
val ktArgument = it.getArgumentExpression()
|
val ktArgument = it.getArgumentExpression()
|
||||||
if (ktArgument != null) {
|
if (ktArgument != null) {
|
||||||
irErrorCall.addArgument(ktArgument.genExpr())
|
irErrorCall.addArgument(ktArgument.genExpr())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ktCall.lambdaArguments.forEach {
|
|
||||||
irErrorCall.addArgument(it.getArgumentExpression().genExpr())
|
|
||||||
}
|
|
||||||
|
|
||||||
irErrorCall
|
irErrorCall
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -76,7 +76,7 @@ class KtInvokeFunctionReference(expression: KtCallExpression) : KtSimpleReferenc
|
|||||||
|
|
||||||
val functionLiteralArguments = expression.lambdaArguments
|
val functionLiteralArguments = expression.lambdaArguments
|
||||||
for (functionLiteralArgument in functionLiteralArguments) {
|
for (functionLiteralArgument in functionLiteralArguments) {
|
||||||
val functionLiteralExpression = functionLiteralArgument.getArgumentExpression().unpackFunctionLiteral() ?: continue
|
val functionLiteralExpression = functionLiteralArgument.getLambdaExpression() ?: continue
|
||||||
list.add(getRange(functionLiteralExpression.leftCurlyBrace))
|
list.add(getRange(functionLiteralExpression.leftCurlyBrace))
|
||||||
val rightCurlyBrace = functionLiteralExpression.rightCurlyBrace
|
val rightCurlyBrace = functionLiteralExpression.rightCurlyBrace
|
||||||
if (rightCurlyBrace != null) {
|
if (rightCurlyBrace != null) {
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getValueArgumentsInParenthese
|
|||||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.isError
|
import org.jetbrains.kotlin.types.isError
|
||||||
|
import org.jetbrains.kotlin.utils.KotlinExceptionWithAttachments
|
||||||
import org.jetbrains.kotlin.utils.SmartList
|
import org.jetbrains.kotlin.utils.SmartList
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
@@ -56,7 +57,10 @@ inline fun <reified T : PsiElement> PsiElement.replaced(newElement: T): T {
|
|||||||
fun <T : PsiElement> T.copied(): T = copy() as T
|
fun <T : PsiElement> T.copied(): T = copy() as T
|
||||||
|
|
||||||
fun KtLambdaArgument.moveInsideParentheses(bindingContext: BindingContext): KtCallExpression {
|
fun KtLambdaArgument.moveInsideParentheses(bindingContext: BindingContext): KtCallExpression {
|
||||||
return moveInsideParenthesesAndReplaceWith(this.getArgumentExpression(), bindingContext)
|
val ktExpression = this.getArgumentExpression()
|
||||||
|
?: throw KotlinExceptionWithAttachments("no argument expression for $this")
|
||||||
|
.withAttachment("lambdaExpression", this.text)
|
||||||
|
return moveInsideParenthesesAndReplaceWith(ktExpression, bindingContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun KtLambdaArgument.moveInsideParenthesesAndReplaceWith(
|
fun KtLambdaArgument.moveInsideParenthesesAndReplaceWith(
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.psi.psiUtil.canPlaceAfterSimpleNameEntry
|
|||||||
import org.jetbrains.kotlin.psi.psiUtil.findDescendantOfType
|
import org.jetbrains.kotlin.psi.psiUtil.findDescendantOfType
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf
|
import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf
|
||||||
import org.jetbrains.kotlin.resolve.bindingContextUtil.isUsedAsExpression
|
import org.jetbrains.kotlin.resolve.bindingContextUtil.isUsedAsExpression
|
||||||
|
import org.jetbrains.kotlin.utils.KotlinExceptionWithAttachments
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
internal abstract class ReplacementPerformer<TElement : KtElement>(
|
internal abstract class ReplacementPerformer<TElement : KtElement>(
|
||||||
@@ -210,7 +211,10 @@ internal class ExpressionReplacementPerformer(
|
|||||||
|
|
||||||
val runExpression = psiFactory.createExpressionByPattern("run { $0 }", elementToBeReplaced) as KtCallExpression
|
val runExpression = psiFactory.createExpressionByPattern("run { $0 }", elementToBeReplaced) as KtCallExpression
|
||||||
val runAfterReplacement = elementToBeReplaced.replaced(runExpression)
|
val runAfterReplacement = elementToBeReplaced.replaced(runExpression)
|
||||||
val block = runAfterReplacement.lambdaArguments[0].getLambdaExpression().bodyExpression!!
|
val ktLambdaArgument = runAfterReplacement.lambdaArguments[0]
|
||||||
|
val block = ktLambdaArgument.getLambdaExpression()?.bodyExpression
|
||||||
|
?: throw KotlinExceptionWithAttachments("cant get body expression for $ktLambdaArgument")
|
||||||
|
.withAttachment("ktLambdaArgument", ktLambdaArgument.text)
|
||||||
elementToBeReplaced = block.statements.single()
|
elementToBeReplaced = block.statements.single()
|
||||||
return elementToBeReplaced
|
return elementToBeReplaced
|
||||||
|
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ private fun UsageReplacementStrategy.specialUsageProcessing(usage: KtSimpleNameE
|
|||||||
val grandParent = usageParent.parent
|
val grandParent = usageParent.parent
|
||||||
val specifySignature = SpecifyExplicitLambdaSignatureIntention()
|
val specifySignature = SpecifyExplicitLambdaSignatureIntention()
|
||||||
for (lambdaArgument in lambdaArguments) {
|
for (lambdaArgument in lambdaArguments) {
|
||||||
val lambdaExpression = lambdaArgument.getLambdaExpression()
|
val lambdaExpression = lambdaArgument.getLambdaExpression() ?: continue
|
||||||
val functionDescriptor =
|
val functionDescriptor =
|
||||||
lambdaExpression.functionLiteral.resolveToDescriptorIfAny() as? FunctionDescriptor ?: continue
|
lambdaExpression.functionLiteral.resolveToDescriptorIfAny() as? FunctionDescriptor ?: continue
|
||||||
if (functionDescriptor.valueParameters.isNotEmpty()) {
|
if (functionDescriptor.valueParameters.isNotEmpty()) {
|
||||||
|
|||||||
+3
-1
@@ -217,7 +217,9 @@ public class KotlinExpressionMover extends AbstractKotlinUpDownMover {
|
|||||||
List<KtLambdaArgument> functionLiterals = callExpression.getLambdaArguments();
|
List<KtLambdaArgument> functionLiterals = callExpression.getLambdaArguments();
|
||||||
if (functionLiterals.isEmpty()) return null;
|
if (functionLiterals.isEmpty()) return null;
|
||||||
|
|
||||||
return functionLiterals.get(0).getLambdaExpression().getBodyExpression();
|
KtLambdaExpression lambdaExpression = functionLiterals.get(0).getLambdaExpression();
|
||||||
|
if (lambdaExpression == null) return null;
|
||||||
|
return lambdaExpression.getBodyExpression();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
@@ -72,9 +72,9 @@ private fun getCounterpart(expression: KtCallExpression): String? {
|
|||||||
val callee = expression.calleeExpression as? KtNameReferenceExpression ?: return null
|
val callee = expression.calleeExpression as? KtNameReferenceExpression ?: return null
|
||||||
val calleeName = callee.getReferencedName()
|
val calleeName = callee.getReferencedName()
|
||||||
val counterpartName = counterpartNames[calleeName]
|
val counterpartName = counterpartNames[calleeName]
|
||||||
val lambdaArgument = expression.lambdaArguments.singleOrNull()
|
val lambdaExpression = expression.lambdaArguments.singleOrNull()?.getLambdaExpression()
|
||||||
if (counterpartName != null && lambdaArgument != null) {
|
if (counterpartName != null && lambdaExpression != null) {
|
||||||
if (lambdaArgument.getLambdaExpression().valueParameters.isNotEmpty()) {
|
if (lambdaExpression.valueParameters.isNotEmpty()) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
val bindingContext = callee.analyze(BodyResolveMode.PARTIAL)
|
val bindingContext = callee.analyze(BodyResolveMode.PARTIAL)
|
||||||
@@ -151,7 +151,7 @@ abstract class ConvertScopeFunctionFix(private val counterpartName: String) : Lo
|
|||||||
val bindingContext = callExpression.analyze()
|
val bindingContext = callExpression.analyze()
|
||||||
|
|
||||||
val lambda = callExpression.lambdaArguments.firstOrNull() ?: return
|
val lambda = callExpression.lambdaArguments.firstOrNull() ?: return
|
||||||
val functionLiteral = lambda.getLambdaExpression().functionLiteral
|
val functionLiteral = lambda.getLambdaExpression()?.functionLiteral ?: return
|
||||||
val lambdaDescriptor = bindingContext[FUNCTION, functionLiteral] ?: return
|
val lambdaDescriptor = bindingContext[FUNCTION, functionLiteral] ?: return
|
||||||
|
|
||||||
val replacements = ReplacementCollection()
|
val replacements = ReplacementCollection()
|
||||||
@@ -186,13 +186,13 @@ class ConvertScopeFunctionToParameter(counterpartName: String) : ConvertScopeFun
|
|||||||
) {
|
) {
|
||||||
val project = lambda.project
|
val project = lambda.project
|
||||||
val factory = KtPsiFactory(project)
|
val factory = KtPsiFactory(project)
|
||||||
val functionLiteral = lambda.getLambdaExpression().functionLiteral
|
val functionLiteral = lambda.getLambdaExpression()?.functionLiteral
|
||||||
val lambdaExtensionReceiver = lambdaDescriptor.extensionReceiverParameter
|
val lambdaExtensionReceiver = lambdaDescriptor.extensionReceiverParameter
|
||||||
val lambdaDispatchReceiver = lambdaDescriptor.dispatchReceiverParameter
|
val lambdaDispatchReceiver = lambdaDescriptor.dispatchReceiverParameter
|
||||||
|
|
||||||
var parameterName = "it"
|
var parameterName = "it"
|
||||||
val scopes = mutableSetOf<LexicalScope>()
|
val scopes = mutableSetOf<LexicalScope>()
|
||||||
if (needUniqueNameForParameter(lambda, scopes)) {
|
if (functionLiteral != null && needUniqueNameForParameter(lambda, scopes)) {
|
||||||
val parameterType = lambdaExtensionReceiver?.type ?: lambdaDispatchReceiver?.type
|
val parameterType = lambdaExtensionReceiver?.type ?: lambdaDispatchReceiver?.type
|
||||||
parameterName = findUniqueParameterName(parameterType, scopes)
|
parameterName = findUniqueParameterName(parameterType, scopes)
|
||||||
replacements.createParameter = {
|
replacements.createParameter = {
|
||||||
|
|||||||
@@ -47,16 +47,16 @@ class SimplifyCallChainFix(val newName: String) : LocalQuickFix {
|
|||||||
val lastArgumentPrefix = if (newName.startsWith("joinTo")) "transform = " else ""
|
val lastArgumentPrefix = if (newName.startsWith("joinTo")) "transform = " else ""
|
||||||
val arguments = secondCallExpression.valueArgumentList?.arguments.orEmpty().map { it.text } +
|
val arguments = secondCallExpression.valueArgumentList?.arguments.orEmpty().map { it.text } +
|
||||||
firstCallExpression.valueArgumentList?.arguments.orEmpty().map { "$lastArgumentPrefix${it.text}" }
|
firstCallExpression.valueArgumentList?.arguments.orEmpty().map { "$lastArgumentPrefix${it.text}" }
|
||||||
val lambdaArgument = firstCallExpression.lambdaArguments.singleOrNull()
|
val lambdaExpression = firstCallExpression.lambdaArguments.singleOrNull()?.getLambdaExpression()
|
||||||
|
|
||||||
val argumentsText = arguments.ifNotEmpty { joinToString(prefix = "(", postfix = ")") } ?: ""
|
val argumentsText = arguments.ifNotEmpty { joinToString(prefix = "(", postfix = ")") } ?: ""
|
||||||
val newQualifiedExpression = if (lambdaArgument != null) factory.createExpressionByPattern(
|
val newQualifiedExpression = if (lambdaExpression != null) factory.createExpressionByPattern(
|
||||||
"$0$1$2 $3 $4",
|
"$0$1$2 $3 $4",
|
||||||
receiverExpression ?: "",
|
receiverExpression ?: "",
|
||||||
operationSign,
|
operationSign,
|
||||||
newName,
|
newName,
|
||||||
argumentsText,
|
argumentsText,
|
||||||
lambdaArgument.getLambdaExpression().text
|
lambdaExpression.text
|
||||||
)
|
)
|
||||||
else factory.createExpressionByPattern(
|
else factory.createExpressionByPattern(
|
||||||
"$0$1$2 $3",
|
"$0$1$2 $3",
|
||||||
|
|||||||
+1
-1
@@ -76,7 +76,7 @@ class ConvertTryFinallyToUseCallIntention : SelfTargetingRangeIntention<KtTryExp
|
|||||||
else -> return
|
else -> return
|
||||||
}
|
}
|
||||||
val lambda = call.lambdaArguments.firstOrNull() ?: return
|
val lambda = call.lambdaArguments.firstOrNull() ?: return
|
||||||
val lambdaParameter = lambda.getLambdaExpression().valueParameters.firstOrNull() ?: return
|
val lambdaParameter = lambda.getLambdaExpression()?.valueParameters?.firstOrNull() ?: return
|
||||||
editor?.selectionModel?.setSelection(lambdaParameter.startOffset, lambdaParameter.endOffset)
|
editor?.selectionModel?.setSelection(lambdaParameter.startOffset, lambdaParameter.endOffset)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -22,13 +22,12 @@ import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
|||||||
import org.jetbrains.kotlin.idea.core.moveInsideParentheses
|
import org.jetbrains.kotlin.idea.core.moveInsideParentheses
|
||||||
import org.jetbrains.kotlin.psi.KtLambdaArgument
|
import org.jetbrains.kotlin.psi.KtLambdaArgument
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.containsInside
|
import org.jetbrains.kotlin.psi.psiUtil.containsInside
|
||||||
import org.jetbrains.kotlin.psi.unpackFunctionLiteral
|
|
||||||
|
|
||||||
class MoveLambdaInsideParenthesesIntention : SelfTargetingIntention<KtLambdaArgument>(
|
class MoveLambdaInsideParenthesesIntention : SelfTargetingIntention<KtLambdaArgument>(
|
||||||
KtLambdaArgument::class.java, "Move lambda argument into parentheses"
|
KtLambdaArgument::class.java, "Move lambda argument into parentheses"
|
||||||
), LowPriorityAction {
|
), LowPriorityAction {
|
||||||
override fun isApplicableTo(element: KtLambdaArgument, caretOffset: Int): Boolean {
|
override fun isApplicableTo(element: KtLambdaArgument, caretOffset: Int): Boolean {
|
||||||
val body = element.getArgumentExpression().unpackFunctionLiteral()?.bodyExpression ?: return true
|
val body = element.getLambdaExpression()?.bodyExpression ?: return true
|
||||||
return !body.textRange.containsInside(caretOffset)
|
return !body.textRange.containsInside(caretOffset)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ class ObjectLiteralToLambdaIntention : SelfTargetingRangeIntention<KtObjectLiter
|
|||||||
|
|
||||||
val callee = replaced.getCalleeExpressionIfAny()!! as KtNameReferenceExpression
|
val callee = replaced.getCalleeExpressionIfAny()!! as KtNameReferenceExpression
|
||||||
val callExpression = callee.parent as KtCallExpression
|
val callExpression = callee.parent as KtCallExpression
|
||||||
val functionLiteral = callExpression.lambdaArguments.single().getLambdaExpression()
|
val functionLiteral = callExpression.lambdaArguments.single().getLambdaExpression()!!
|
||||||
|
|
||||||
val returnLabel = callee.getReferencedNameAsName()
|
val returnLabel = callee.getReferencedNameAsName()
|
||||||
returnSaver.restore(functionLiteral, returnLabel)
|
returnSaver.restore(functionLiteral, returnLabel)
|
||||||
|
|||||||
+1
-1
@@ -101,7 +101,7 @@ abstract class WrapInWithReplacement : Replacement {
|
|||||||
val call = (e as? KtSimpleNameExpression)?.getQualifiedElement() ?: return e
|
val call = (e as? KtSimpleNameExpression)?.getQualifiedElement() ?: return e
|
||||||
val replacingExpression = KtPsiFactory(e).createExpressionByPattern("with($0) { $1 }", argumentText, call)
|
val replacingExpression = KtPsiFactory(e).createExpressionByPattern("with($0) { $1 }", argumentText, call)
|
||||||
val replace = call.replace(replacingExpression)
|
val replace = call.replace(replacingExpression)
|
||||||
return (replace as KtCallExpression).lambdaArguments.first().getLambdaExpression().bodyExpression!!.statements.first()
|
return (replace as KtCallExpression).lambdaArguments.first().getLambdaExpression()!!.bodyExpression!!.statements.first()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -328,7 +328,7 @@ internal object KotlinConverter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
is KtExpression -> KotlinConverter.convertExpression(element, givenParent, requiredType)
|
is KtExpression -> KotlinConverter.convertExpression(element, givenParent, requiredType)
|
||||||
is KtLambdaArgument -> KotlinConverter.convertExpression(element.getLambdaExpression(), givenParent, requiredType)
|
is KtLambdaArgument -> element.getLambdaExpression()?.let { KotlinConverter.convertExpression(it, givenParent, requiredType) }
|
||||||
is KtLightAnnotationForSourceEntry.LightExpressionValue<*> -> {
|
is KtLightAnnotationForSourceEntry.LightExpressionValue<*> -> {
|
||||||
val expression = element.originalExpression
|
val expression = element.originalExpression
|
||||||
when (expression) {
|
when (expression) {
|
||||||
|
|||||||
Reference in New Issue
Block a user