"Move lambda function into parentheses" intention - smaller availability range
This commit is contained in:
@@ -302,8 +302,6 @@ replace.with.infix.function.call.intention.error.resolution.failed=The element c
|
||||
replace.with.infix.function.call.intention.error.package.call=Cannot be applied with a package as the receiver
|
||||
replace.explicit.function.literal.param.with.it=Replace explicit parameter ''{0}'' with ''it''
|
||||
replace.explicit.function.literal.param.with.it.family=Replace Explicit Parameter with 'it'
|
||||
move.lambda.inside.parentheses=Move lambda function into parentheses
|
||||
move.lambda.inside.parentheses.family=Move Lambda Function Into Parentheses
|
||||
move.lambda.outside.parentheses=Move lambda expression out of parentheses
|
||||
move.lambda.outside.parentheses.family=Move Lambda Expression out of Parentheses
|
||||
replace.it.with.explicit.function.literal.param=Replace 'it' with explicit parameter
|
||||
|
||||
+6
-4
@@ -21,10 +21,12 @@ import org.jetbrains.kotlin.psi.JetFunctionLiteralArgument
|
||||
import org.jetbrains.kotlin.idea.util.psiModificationUtil.moveInsideParentheses
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeFully
|
||||
|
||||
public class MoveLambdaInsideParenthesesIntention : JetSelfTargetingOffsetIndependentIntention<JetFunctionLiteralArgument>(
|
||||
"move.lambda.inside.parentheses", javaClass()) {
|
||||
|
||||
override fun isApplicableTo(element: JetFunctionLiteralArgument): Boolean = true
|
||||
public class MoveLambdaInsideParenthesesIntention : JetSelfTargetingIntention<JetFunctionLiteralArgument>(javaClass(), "Move lambda function into parentheses") {
|
||||
override fun isApplicableTo(element: JetFunctionLiteralArgument, caretOffset: Int): Boolean {
|
||||
val lBrace = element.getFunctionLiteral().getLeftCurlyBrace()
|
||||
val rBrace = element.getFunctionLiteral().getRightCurlyBrace() ?: return false
|
||||
return caretOffset < lBrace.getTextRange().getEndOffset() || rBrace.getTextRange().containsOffset(caretOffset)
|
||||
}
|
||||
|
||||
override fun applyTo(element: JetFunctionLiteralArgument, editor: Editor) {
|
||||
element.moveInsideParentheses(element.analyzeFully())
|
||||
|
||||
Reference in New Issue
Block a user