introduce functional variable: allow comments (IDEA-174183)

This commit is contained in:
Anna Kozlova
2017-06-09 16:51:20 +03:00
parent 1bf8d3d7a8
commit 404fe68c03
4 changed files with 18 additions and 1 deletions
@@ -60,7 +60,7 @@ public class IntroduceFunctionalVariableHandler extends IntroduceVariableHandler
showErrorMessage(project , editor, message);
return;
}
PsiElement anchorStatement = RefactoringUtil.getParentStatement(elements[0], false);
PsiElement anchorStatement = elements[0] instanceof PsiComment ? elements[0] : RefactoringUtil.getParentStatement(elements[0], false);
PsiElement tempContainer = checkAnchorStatement(project, editor, anchorStatement);
if (tempContainer == null) return;
@@ -0,0 +1,8 @@
class Test {
{
Runnable runnable = () -> {
//my comment
};
runnable.run();
}
}
@@ -0,0 +1,5 @@
class Test {
{
<selection>//my comment</selection>
}
}
@@ -63,6 +63,10 @@ public class IntroduceFunctionalVariableTest extends LightRefactoringTestCase {
doTest(0);
}
public void testRunnableFromComment() throws Exception {
doTest();
}
public void testIgnoreMethodObjectSuggestion() throws Exception {
try {
doTest();