diff --git a/annotations/com/intellij/codeInsight/editorActions/annotations.xml b/annotations/com/intellij/codeInsight/editorActions/annotations.xml index 65656bcd42e..889d139f2f3 100644 --- a/annotations/com/intellij/codeInsight/editorActions/annotations.xml +++ b/annotations/com/intellij/codeInsight/editorActions/annotations.xml @@ -19,6 +19,39 @@ name='com.intellij.codeInsight.editorActions.CopyPastePostProcessor T extractTransferableData(java.awt.datatransfer.Transferable) 0'> + + + + + + + + + + + + + + + + + + + + + + + + + @@ -39,6 +72,26 @@ name='com.intellij.codeInsight.editorActions.CopyPastePostProcessor void processTransferableData(com.intellij.openapi.project.Project, com.intellij.openapi.editor.Editor, com.intellij.openapi.editor.RangeMarker, int, com.intellij.openapi.util.Ref<java.lang.Boolean>, T) 5'> + + + + + + + + + + + + + + + diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index 808fb2a6898..79c5bea046e 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -6,7 +6,7 @@ @snapshot@ JetBrains Inc. - + JUnit org.jetbrains.plugins.gradle diff --git a/idea/src/org/jetbrains/jet/plugin/codeInsight/KotlinCopyPasteReferenceProcessor.kt b/idea/src/org/jetbrains/jet/plugin/codeInsight/KotlinCopyPasteReferenceProcessor.kt index 3ada61534df..087c3b91ce4 100644 --- a/idea/src/org/jetbrains/jet/plugin/codeInsight/KotlinCopyPasteReferenceProcessor.kt +++ b/idea/src/org/jetbrains/jet/plugin/codeInsight/KotlinCopyPasteReferenceProcessor.kt @@ -65,16 +65,18 @@ import org.jetbrains.jet.lang.psi.psiUtil.getReceiverExpression import org.jetbrains.jet.utils.* //NOTE: this class is based on CopyPasteReferenceProcessor and JavaCopyPasteReferenceProcessor -public class KotlinCopyPasteReferenceProcessor() : CopyPastePostProcessor { +public class KotlinCopyPasteReferenceProcessor() : CopyPastePostProcessor() { - override fun extractTransferableData(content: Transferable): ReferenceTransferableData? { - //NOTE: copied code - var referenceData: ReferenceTransferableData? = null + override fun extractTransferableData(content: Transferable): List { if (CodeInsightSettings.getInstance()!!.ADD_IMPORTS_ON_PASTE != CodeInsightSettings.NO) { try { val flavor = ReferenceData.getDataFlavor() if (flavor != null) { - referenceData = content.getTransferData(flavor) as? ReferenceTransferableData + val referenceData = content.getTransferData(flavor) as? ReferenceTransferableData + if (referenceData != null) { + // copy to prevent changing of original by convertLineSeparators + return listOf(referenceData.clone()) + } } } catch (ignored: UnsupportedFlavorException) { @@ -83,12 +85,7 @@ public class KotlinCopyPasteReferenceProcessor() : CopyPastePostProcessor { if (file !is JetFile) { - return null + return listOf() } val collectedData = try { @@ -111,14 +108,14 @@ public class KotlinCopyPasteReferenceProcessor() : CopyPastePostProcessor, - value: ReferenceTransferableData? + values: List ) { if (DumbService.getInstance(project)!!.isDumb()) { return @@ -197,7 +194,10 @@ public class KotlinCopyPasteReferenceProcessor() : CopyPastePostProcessor { +public class ConvertJavaCopyPastePostProcessor() : CopyPastePostProcessor() { - override fun extractTransferableData(content: Transferable): TextBlockTransferableData? { + override fun extractTransferableData(content: Transferable): List { try { if (content.isDataFlavorSupported(CopiedCode.DATA_FLAVOR)) { - return (content.getTransferData(CopiedCode.DATA_FLAVOR) as TextBlockTransferableData) + return listOf(content.getTransferData(CopiedCode.DATA_FLAVOR) as TextBlockTransferableData) } } catch (e: Throwable) { LOG.error(e) } - return null + return listOf() } - public override fun collectTransferableData(file: PsiFile, editor: Editor, startOffsets: IntArray, endOffsets: IntArray): TextBlockTransferableData? { - if (!(file is PsiJavaFile)) { - return null + public override fun collectTransferableData(file: PsiFile, editor: Editor, startOffsets: IntArray, endOffsets: IntArray): List { + if (file !is PsiJavaFile) { + return listOf() } val lightFile = PsiFileFactory.getInstance(file.getProject())!!.createFileFromText(file.getText()!!, file) - return CopiedCode(lightFile as? PsiJavaFile, startOffsets, endOffsets) + return listOf(CopiedCode(lightFile as? PsiJavaFile, startOffsets, endOffsets)) } - public override fun processTransferableData(project: Project, editor: Editor, bounds: RangeMarker, caretOffset: Int, indented: Ref, value: TextBlockTransferableData) { + public override fun processTransferableData(project: Project, editor: Editor, bounds: RangeMarker, caretOffset: Int, indented: Ref, values: List) { + assert(values.size() == 1) + + val value = values.first() + if (value !is CopiedCode) return diff --git a/idea/src/org/jetbrains/jet/plugin/search/ideaExtensions/JetTargetElementEvaluator.kt b/idea/src/org/jetbrains/jet/plugin/search/ideaExtensions/JetTargetElementEvaluator.kt index bad8b885348..e454e5e7d4e 100644 --- a/idea/src/org/jetbrains/jet/plugin/search/ideaExtensions/JetTargetElementEvaluator.kt +++ b/idea/src/org/jetbrains/jet/plugin/search/ideaExtensions/JetTargetElementEvaluator.kt @@ -23,8 +23,6 @@ import com.intellij.psi.PsiReference import org.jetbrains.jet.lang.psi.JetClass public class JetTargetElementEvaluator : TargetElementEvaluator { - override fun includeSelfInGotoImplementation(element: PsiElement): Boolean = - !(element is JetClass && element.isAbstract()) - - override fun getElementByReference(ref: PsiReference?, flags: Int): PsiElement? = null + override fun includeSelfInGotoImplementation(element: PsiElement): Boolean = !(element is JetClass && element.isAbstract()) + override fun getElementByReference(ref: PsiReference, flags: Int): PsiElement? = null } diff --git a/idea/tests/org/jetbrains/jet/plugin/JetLightCodeInsightFixtureTestCase.java b/idea/tests/org/jetbrains/jet/plugin/JetLightCodeInsightFixtureTestCase.java index a0363a0ce8f..dde7b7e1c8d 100644 --- a/idea/tests/org/jetbrains/jet/plugin/JetLightCodeInsightFixtureTestCase.java +++ b/idea/tests/org/jetbrains/jet/plugin/JetLightCodeInsightFixtureTestCase.java @@ -95,6 +95,7 @@ public abstract class JetLightCodeInsightFixtureTestCase extends LightCodeInsigh return getTestName(false).startsWith("AllFilesPresentIn"); } + @NotNull protected String fileName() { return getTestName(false) + ".kt"; } diff --git a/idea/tests/org/jetbrains/jet/plugin/debugger/AbstractSmartStepIntoTest.kt b/idea/tests/org/jetbrains/jet/plugin/debugger/AbstractSmartStepIntoTest.kt index b6fba70052f..9b70b5b983d 100644 --- a/idea/tests/org/jetbrains/jet/plugin/debugger/AbstractSmartStepIntoTest.kt +++ b/idea/tests/org/jetbrains/jet/plugin/debugger/AbstractSmartStepIntoTest.kt @@ -16,8 +16,6 @@ package org.jetbrains.jet.plugin.debugger -import com.intellij.debugger.SourcePosition -import com.intellij.psi.PsiElement import com.intellij.debugger.actions.SmartStepTarget import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture @@ -36,7 +34,7 @@ abstract class AbstractSmartStepIntoTest : LightCodeInsightFixtureTestCase() { fixture.configureByFile(path) val offset = fixture.getCaretOffset() - val line = fixture.getDocument(fixture.getFile())!!.getLineNumber(offset) + val line = fixture.getDocument(fixture.getFile()!!)!!.getLineNumber(offset) val position = MockSourcePosition(_file = fixture.getFile(), _line = line, _offset = offset, _editor = fixture.getEditor()) diff --git a/idea/tests/org/jetbrains/jet/plugin/debugger/evaluate/AbstractEditorForEvaluateExpressionTest.kt b/idea/tests/org/jetbrains/jet/plugin/debugger/evaluate/AbstractEditorForEvaluateExpressionTest.kt index f14e9613ad4..ca6421eb3f6 100644 --- a/idea/tests/org/jetbrains/jet/plugin/debugger/evaluate/AbstractEditorForEvaluateExpressionTest.kt +++ b/idea/tests/org/jetbrains/jet/plugin/debugger/evaluate/AbstractEditorForEvaluateExpressionTest.kt @@ -20,7 +20,6 @@ import org.jetbrains.jet.checkers.AbstractJetPsiCheckerTest import org.jetbrains.jet.completion.AbstractJvmBasicCompletionTest import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture import com.intellij.psi.PsiElement -import org.jetbrains.jet.lang.psi.JetExpressionCodeFragment import com.intellij.openapi.util.io.FileUtil import java.io.File import org.jetbrains.jet.lang.psi.JetPsiFactory @@ -29,7 +28,6 @@ import org.jetbrains.jet.lang.psi.JetFile import com.intellij.openapi.application.ApplicationManager import org.jetbrains.jet.lang.resolve.name.FqName import org.jetbrains.jet.InTextDirectivesUtils -import com.intellij.debugger.engine.evaluation.CodeFragmentKind import org.jetbrains.jet.lang.psi.JetCodeFragment abstract class AbstractCodeFragmentHighlightingTest : AbstractJetPsiCheckerTest() { @@ -64,7 +62,7 @@ private fun JavaCodeInsightTestFixture.configureByCodeFragment(filePath: String) val elementAt = getFile()?.findElementAt(getCaretOffset()) val file = createCodeFragment(filePath, elementAt!!) - configureFromExistingVirtualFile(file.getVirtualFile()) + configureFromExistingVirtualFile(file.getVirtualFile()!!) } private fun createCodeFragment(filePath: String, contextElement: PsiElement): JetCodeFragment { diff --git a/idea/tests/org/jetbrains/jet/plugin/javaFacade/JetJavaFacadeTest.java b/idea/tests/org/jetbrains/jet/plugin/javaFacade/JetJavaFacadeTest.java index cb75d83c0c9..6f42c0b2b22 100644 --- a/idea/tests/org/jetbrains/jet/plugin/javaFacade/JetJavaFacadeTest.java +++ b/idea/tests/org/jetbrains/jet/plugin/javaFacade/JetJavaFacadeTest.java @@ -306,6 +306,7 @@ public class JetJavaFacadeTest extends JetLightCodeInsightFixtureTestCase { lightClass.getDelegate(); } + @NotNull @Override protected String fileName() { return getTestName(true) + ".kt"; diff --git a/idea/tests/org/jetbrains/jet/plugin/navigation/AbstractKotlinGotoTest.java b/idea/tests/org/jetbrains/jet/plugin/navigation/AbstractKotlinGotoTest.java index 42d97aebdec..9defd6cdeaa 100644 --- a/idea/tests/org/jetbrains/jet/plugin/navigation/AbstractKotlinGotoTest.java +++ b/idea/tests/org/jetbrains/jet/plugin/navigation/AbstractKotlinGotoTest.java @@ -71,6 +71,7 @@ public abstract class AbstractKotlinGotoTest extends JetLightCodeInsightFixtureT return dirPath; } + @NotNull @Override protected String fileName() { return getTestName(true) + ".kt"; diff --git a/update_dependencies.xml b/update_dependencies.xml index 84b4f3cbf1e..72f1d766947 100644 --- a/update_dependencies.xml +++ b/update_dependencies.xml @@ -1,6 +1,6 @@ - - + + @@ -19,7 +19,7 @@ - + @@ -265,21 +265,32 @@ - - - - - - - - - - - - - + - + + + + + + + + + + + + + + + + + + + + + +