Copy paste: annotations for IDEA classes and corresponding changes in ConvertJavaCopyPastePostProcessor
This commit is contained in:
@@ -0,0 +1,118 @@
|
||||
<root>
|
||||
<item
|
||||
name='com.intellij.codeInsight.editorActions.CopyPastePostProcessor T collectTransferableData(com.intellij.psi.PsiFile, com.intellij.openapi.editor.Editor, int[], int[]) 0'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.codeInsight.editorActions.CopyPastePostProcessor T collectTransferableData(com.intellij.psi.PsiFile, com.intellij.openapi.editor.Editor, int[], int[]) 1'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.codeInsight.editorActions.CopyPastePostProcessor T collectTransferableData(com.intellij.psi.PsiFile, com.intellij.openapi.editor.Editor, int[], int[]) 2'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.codeInsight.editorActions.CopyPastePostProcessor T collectTransferableData(com.intellij.psi.PsiFile, com.intellij.openapi.editor.Editor, int[], int[]) 3'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.codeInsight.editorActions.CopyPastePostProcessor T extractTransferableData(java.awt.datatransfer.Transferable) 0'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
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) 0'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
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) 1'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
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) 2'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
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) 4'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
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'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.codeInsight.editorActions.CopyPasteReferenceProcessor TRef[] findReferencesToRestore(com.intellij.psi.PsiFile, com.intellij.openapi.editor.RangeMarker, com.intellij.codeInsight.editorActions.ReferenceData[])'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.codeInsight.editorActions.CopyPasteReferenceProcessor TRef[] findReferencesToRestore(com.intellij.psi.PsiFile, com.intellij.openapi.editor.RangeMarker, com.intellij.codeInsight.editorActions.ReferenceData[]) 0'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.codeInsight.editorActions.CopyPasteReferenceProcessor TRef[] findReferencesToRestore(com.intellij.psi.PsiFile, com.intellij.openapi.editor.RangeMarker, com.intellij.codeInsight.editorActions.ReferenceData[]) 1'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.codeInsight.editorActions.CopyPasteReferenceProcessor TRef[] findReferencesToRestore(com.intellij.psi.PsiFile, com.intellij.openapi.editor.RangeMarker, com.intellij.codeInsight.editorActions.ReferenceData[]) 2'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.codeInsight.editorActions.CopyPasteReferenceProcessor com.intellij.codeInsight.editorActions.ReferenceTransferableData collectTransferableData(com.intellij.psi.PsiFile, com.intellij.openapi.editor.Editor, int[], int[])'>
|
||||
<annotation name='org.jetbrains.annotations.Nullable'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.codeInsight.editorActions.CopyPasteReferenceProcessor com.intellij.codeInsight.editorActions.ReferenceTransferableData collectTransferableData(com.intellij.psi.PsiFile, com.intellij.openapi.editor.Editor, int[], int[]) 0'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.codeInsight.editorActions.CopyPasteReferenceProcessor com.intellij.codeInsight.editorActions.ReferenceTransferableData collectTransferableData(com.intellij.psi.PsiFile, com.intellij.openapi.editor.Editor, int[], int[]) 1'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.codeInsight.editorActions.CopyPasteReferenceProcessor com.intellij.codeInsight.editorActions.ReferenceTransferableData collectTransferableData(com.intellij.psi.PsiFile, com.intellij.openapi.editor.Editor, int[], int[]) 2'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.codeInsight.editorActions.CopyPasteReferenceProcessor com.intellij.codeInsight.editorActions.ReferenceTransferableData collectTransferableData(com.intellij.psi.PsiFile, com.intellij.openapi.editor.Editor, int[], int[]) 3'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.codeInsight.editorActions.CopyPasteReferenceProcessor void addReferenceData(com.intellij.psi.PsiFile, int, com.intellij.psi.PsiElement, java.util.ArrayList<com.intellij.codeInsight.editorActions.ReferenceData>) 0'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.codeInsight.editorActions.CopyPasteReferenceProcessor void addReferenceData(com.intellij.psi.PsiFile, int, com.intellij.psi.PsiElement, java.util.ArrayList<com.intellij.codeInsight.editorActions.ReferenceData>) 2'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.codeInsight.editorActions.CopyPasteReferenceProcessor void addReferenceData(com.intellij.psi.PsiFile, int, com.intellij.psi.PsiElement, java.util.ArrayList<com.intellij.codeInsight.editorActions.ReferenceData>) 3'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.codeInsight.editorActions.CopyPasteReferenceProcessor 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>, com.intellij.codeInsight.editorActions.ReferenceTransferableData) 0'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.codeInsight.editorActions.CopyPasteReferenceProcessor 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>, com.intellij.codeInsight.editorActions.ReferenceTransferableData) 1'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.codeInsight.editorActions.CopyPasteReferenceProcessor 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>, com.intellij.codeInsight.editorActions.ReferenceTransferableData) 2'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.codeInsight.editorActions.CopyPasteReferenceProcessor 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>, com.intellij.codeInsight.editorActions.ReferenceTransferableData) 4'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.codeInsight.editorActions.CopyPasteReferenceProcessor 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>, com.intellij.codeInsight.editorActions.ReferenceTransferableData) 5'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.codeInsight.editorActions.CopyPasteReferenceProcessor void restoreReferences(com.intellij.codeInsight.editorActions.ReferenceData[], TRef[]) 0'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.codeInsight.editorActions.CopyPasteReferenceProcessor void restoreReferences(com.intellij.codeInsight.editorActions.ReferenceData[], TRef[]) 1'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
</root>
|
||||
+7
-8
@@ -35,9 +35,9 @@ import com.intellij.psi.codeStyle.CodeStyleManager
|
||||
|
||||
public class ConvertJavaCopyPastePostProcessor() : CopyPastePostProcessor<TextBlockTransferableData> {
|
||||
|
||||
override fun extractTransferableData(content: Transferable?): TextBlockTransferableData? {
|
||||
override fun extractTransferableData(content: Transferable): TextBlockTransferableData? {
|
||||
try {
|
||||
if (content!!.isDataFlavorSupported(CopiedCode.DATA_FLAVOR)) {
|
||||
if (content.isDataFlavorSupported(CopiedCode.DATA_FLAVOR)) {
|
||||
return (content.getTransferData(CopiedCode.DATA_FLAVOR) as TextBlockTransferableData)
|
||||
}
|
||||
}
|
||||
@@ -47,24 +47,23 @@ public class ConvertJavaCopyPastePostProcessor() : CopyPastePostProcessor<TextBl
|
||||
return null
|
||||
}
|
||||
|
||||
public override fun collectTransferableData(file: PsiFile?, editor: Editor?, startOffsets: IntArray?, endOffsets: IntArray?): TextBlockTransferableData? {
|
||||
public override fun collectTransferableData(file: PsiFile, editor: Editor, startOffsets: IntArray, endOffsets: IntArray): TextBlockTransferableData? {
|
||||
if (!(file is PsiJavaFile)) {
|
||||
return null
|
||||
}
|
||||
|
||||
val lightFile = PsiFileFactory.getInstance(file.getProject())!!.createFileFromText(file.getText()!!, file)
|
||||
return CopiedCode(lightFile as? PsiJavaFile, startOffsets!!, endOffsets!!)
|
||||
return CopiedCode(lightFile as? PsiJavaFile, startOffsets, endOffsets)
|
||||
}
|
||||
|
||||
public override fun processTransferableData(project: Project?, editor: Editor?, bounds: RangeMarker?,
|
||||
caretOffset: Int, indented: Ref<Boolean>?, value: TextBlockTransferableData?) {
|
||||
public override fun processTransferableData(project: Project, editor: Editor, bounds: RangeMarker, caretOffset: Int, indented: Ref<Boolean>, value: TextBlockTransferableData) {
|
||||
if (value !is CopiedCode)
|
||||
return
|
||||
|
||||
if (value.getFile() == null)
|
||||
return
|
||||
|
||||
val file = PsiDocumentManager.getInstance(project!!).getPsiFile(editor!!.getDocument())
|
||||
val file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument())
|
||||
if (file !is JetFile)
|
||||
return
|
||||
|
||||
@@ -74,7 +73,7 @@ public class ConvertJavaCopyPastePostProcessor() : CopyPastePostProcessor<TextBl
|
||||
val text = convertCopiedCodeToKotlin(value, file.getProject())
|
||||
if (text.isNotEmpty()) {
|
||||
ApplicationManager.getApplication()!!.runWriteAction {
|
||||
val startOffset = bounds!!.getStartOffset()
|
||||
val startOffset = bounds.getStartOffset()
|
||||
editor.getDocument().replaceString(bounds.getStartOffset(), bounds.getEndOffset(), text)
|
||||
val endOffsetAfterCopy = startOffset + text.length()
|
||||
editor.getCaretModel().moveToOffset(endOffsetAfterCopy)
|
||||
|
||||
Reference in New Issue
Block a user