Introduce...: Allow semicolon extraction
#KT-7583 Fixed
This commit is contained in:
@@ -27,6 +27,7 @@ import com.intellij.refactoring.util.CommonRefactoringUtil;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.lexer.JetTokens;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
|
||||
@@ -100,7 +101,10 @@ public class CodeInsightUtils {
|
||||
}
|
||||
|
||||
for (PsiElement element : array) {
|
||||
if (!(element instanceof JetExpression || element instanceof PsiWhiteSpace || element instanceof PsiComment)) {
|
||||
if (!(element instanceof JetExpression
|
||||
|| element.getNode().getElementType() == JetTokens.SEMICOLON
|
||||
|| element instanceof PsiWhiteSpace
|
||||
|| element instanceof PsiComment)) {
|
||||
return PsiElement.EMPTY_ARRAY;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fun foo() {
|
||||
<selection>println("Hey!");</selection>
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fun foo() {
|
||||
__dummyTestFun__()
|
||||
}
|
||||
|
||||
private fun __dummyTestFun__() {
|
||||
println("Hey!");
|
||||
}
|
||||
+6
@@ -378,6 +378,12 @@ public class JetExtractionTestGenerated extends AbstractJetExtractionTest {
|
||||
doExtractFunctionTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("lineWithSemicolon.kt")
|
||||
public void testLineWithSemicolon() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/extractFunction/basic/lineWithSemicolon.kt");
|
||||
doExtractFunctionTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("localClassExtraction.kt")
|
||||
public void testLocalClassExtraction() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/extractFunction/basic/localClassExtraction.kt");
|
||||
|
||||
Reference in New Issue
Block a user