"Move lambda argument into parentheses" intention - slightly wider range

This commit is contained in:
Valentin Kipyatkov
2015-04-28 15:43:06 +03:00
parent f631f97a22
commit 077307b518
2 changed files with 4 additions and 7 deletions
@@ -44,14 +44,11 @@ public class JetFunctionLiteralExpression extends JetExpressionImpl {
return getFunctionLiteral().getValueParameters();
}
@Nullable
public JetBlockExpression getBodyExpression() {
return getFunctionLiteral().getBodyExpression();
}
public boolean hasBlockBody() {
return getFunctionLiteral().hasBlockBody();
}
public boolean hasDeclaredReturnType() {
return getFunctionLiteral().getTypeReference() != null;
}
@@ -23,9 +23,9 @@ import org.jetbrains.kotlin.idea.caches.resolve.analyzeFully
public class MoveLambdaInsideParenthesesIntention : JetSelfTargetingIntention<JetFunctionLiteralArgument>(javaClass(), "Move lambda argument 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)
val body = element.getFunctionLiteral().getBodyExpression() ?: return true
val bodyRange = body.getTextRange()
return caretOffset <= bodyRange.getStartOffset() || caretOffset >= bodyRange.getEndOffset()
}
override fun applyTo(element: JetFunctionLiteralArgument, editor: Editor) {