Conversion on copy paste:
Copy element as text in case it can't be converted
This commit is contained in:
@@ -107,7 +107,13 @@ public class JavaCopyPastePostProcessor() : CopyPastePostProcessor<TextBlockTran
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
val elementToConvert = findTopMostParentWhollyInRange(currentRange, leafElement)
|
val elementToConvert = findTopMostParentWhollyInRange(currentRange, leafElement)
|
||||||
result.append(converter.elementToKotlin(elementToConvert))
|
val converted = converter.elementToKotlin(elementToConvert)
|
||||||
|
if (converted.isNotEmpty()) {
|
||||||
|
result.append(converted)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result.append(elementToConvert.getText())
|
||||||
|
}
|
||||||
val endOfConverted = elementToConvert.getTextRange()!!.getEndOffset()
|
val endOfConverted = elementToConvert.getTextRange()!!.getEndOffset()
|
||||||
currentRange = TextRange(endOfConverted, currentRange.getEndOffset())
|
currentRange = TextRange(endOfConverted, currentRange.getEndOffset())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
b - c + d
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
public static void main(String[]args){
|
||||||
|
a + <selection>b - c + d</selection> - e
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<caret>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
fun main(args: Array<String>) {
|
||||||
|
{
|
||||||
|
val a = Object()
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
class A {
|
||||||
|
public static void main(String[] args) <selection>{
|
||||||
|
Object a = new Object();</selection>
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun main(args: Array<String>) {
|
||||||
|
<caret>
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
class
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<selection>class Some</selection>InterestingClass {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<caret>
|
||||||
+15
@@ -36,6 +36,11 @@ public class JavaToKotlinCopyPasteConversionTestGenerated extends AbstractJavaTo
|
|||||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/copyPaste/conversion"), Pattern.compile("^(.+)\\.java$"), true);
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/copyPaste/conversion"), Pattern.compile("^(.+)\\.java$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("Arithmetic.java")
|
||||||
|
public void testArithmetic() throws Exception {
|
||||||
|
doTest("idea/testData/copyPaste/conversion/Arithmetic.java");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("Constructor.java")
|
@TestMetadata("Constructor.java")
|
||||||
public void testConstructor() throws Exception {
|
public void testConstructor() throws Exception {
|
||||||
doTest("idea/testData/copyPaste/conversion/Constructor.java");
|
doTest("idea/testData/copyPaste/conversion/Constructor.java");
|
||||||
@@ -66,6 +71,11 @@ public class JavaToKotlinCopyPasteConversionTestGenerated extends AbstractJavaTo
|
|||||||
doTest("idea/testData/copyPaste/conversion/OnlyClosingBrace.java");
|
doTest("idea/testData/copyPaste/conversion/OnlyClosingBrace.java");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("OnlyOneBraceFromBlock.java")
|
||||||
|
public void testOnlyOneBraceFromBlock() throws Exception {
|
||||||
|
doTest("idea/testData/copyPaste/conversion/OnlyOneBraceFromBlock.java");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("OnlyQualifier.java")
|
@TestMetadata("OnlyQualifier.java")
|
||||||
public void testOnlyQualifier() throws Exception {
|
public void testOnlyQualifier() throws Exception {
|
||||||
doTest("idea/testData/copyPaste/conversion/OnlyQualifier.java");
|
doTest("idea/testData/copyPaste/conversion/OnlyQualifier.java");
|
||||||
@@ -81,4 +91,9 @@ public class JavaToKotlinCopyPasteConversionTestGenerated extends AbstractJavaTo
|
|||||||
doTest("idea/testData/copyPaste/conversion/SeveralMethodsSample.java");
|
doTest("idea/testData/copyPaste/conversion/SeveralMethodsSample.java");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("SingleWordFromIdentifier.java")
|
||||||
|
public void testSingleWordFromIdentifier() throws Exception {
|
||||||
|
doTest("idea/testData/copyPaste/conversion/SingleWordFromIdentifier.java");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user