Copy paste: annotations for IDEA classes and corresponding changes in ConvertJavaCopyPastePostProcessor

This commit is contained in:
Pavel V. Talanov
2014-01-22 14:06:47 +04:00
parent 7daf7374f8
commit 11c1e29287
2 changed files with 125 additions and 8 deletions
@@ -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&lt;java.lang.Boolean&gt;, 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&lt;java.lang.Boolean&gt;, 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&lt;java.lang.Boolean&gt;, 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&lt;java.lang.Boolean&gt;, 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&lt;java.lang.Boolean&gt;, 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&lt;com.intellij.codeInsight.editorActions.ReferenceData&gt;) 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&lt;com.intellij.codeInsight.editorActions.ReferenceData&gt;) 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&lt;com.intellij.codeInsight.editorActions.ReferenceData&gt;) 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&lt;java.lang.Boolean&gt;, 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&lt;java.lang.Boolean&gt;, 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&lt;java.lang.Boolean&gt;, 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&lt;java.lang.Boolean&gt;, 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&lt;java.lang.Boolean&gt;, 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>
@@ -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)