Minor: convert CopiedCode to Kotlin
This commit is contained in:
+3
-3
@@ -62,7 +62,7 @@ public class ConvertJavaCopyPastePostProcessor() : CopyPastePostProcessor<TextBl
|
||||
|
||||
if (value !is CopiedCode) return
|
||||
|
||||
val sourceFile = value.getFile() ?: return
|
||||
val sourceFile = value.file ?: return
|
||||
|
||||
val targetFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument())
|
||||
if (targetFile !is JetFile) return
|
||||
@@ -89,8 +89,8 @@ public class ConvertJavaCopyPastePostProcessor() : CopyPastePostProcessor<TextBl
|
||||
ConverterSettings.defaultSettings,
|
||||
FilesConversionScope(listOf(fileCopiedFrom)),
|
||||
J2kPostProcessor(fileCopiedTo))
|
||||
val startOffsets = code.getStartOffsets()
|
||||
val endOffsets = code.getEndOffsets()
|
||||
val startOffsets = code.startOffsets
|
||||
val endOffsets = code.endOffsets
|
||||
assert(startOffsets.size == endOffsets.size) { "Must have the same size" }
|
||||
val result = StringBuilder()
|
||||
for (i in startOffsets.indices) {
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.plugin.conversion.copy;
|
||||
|
||||
import com.intellij.codeInsight.editorActions.TextBlockTransferableData;
|
||||
import com.intellij.psi.PsiJavaFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
|
||||
class CopiedCode implements TextBlockTransferableData {
|
||||
@NotNull
|
||||
public static final DataFlavor DATA_FLAVOR = new DataFlavor(ConvertJavaCopyPastePostProcessor.class,
|
||||
"class: ConvertJavaCopyPastePostProcessor");
|
||||
private final PsiJavaFile file;
|
||||
private final int[] startOffsets;
|
||||
private final int[] endOffsets;
|
||||
|
||||
public CopiedCode(@Nullable PsiJavaFile file, @NotNull int[] startOffsets, @NotNull int[] endOffsets) {
|
||||
this.file = file;
|
||||
this.startOffsets = startOffsets;
|
||||
this.endOffsets = endOffsets;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public DataFlavor getFlavor() {
|
||||
return DATA_FLAVOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOffsetCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOffsets(int[] offsets, int index) {
|
||||
return index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setOffsets(int[] offsets, int index) {
|
||||
return index;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PsiJavaFile getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public int[] getStartOffsets() {
|
||||
return startOffsets;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public int[] getEndOffsets() {
|
||||
return endOffsets;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.plugin.conversion.copy
|
||||
|
||||
import com.intellij.codeInsight.editorActions.TextBlockTransferableData
|
||||
import com.intellij.psi.PsiJavaFile
|
||||
|
||||
import java.awt.datatransfer.DataFlavor
|
||||
|
||||
class CopiedCode(val file: PsiJavaFile?, val startOffsets: IntArray, val endOffsets: IntArray) : TextBlockTransferableData {
|
||||
|
||||
override fun getFlavor() = DATA_FLAVOR
|
||||
override fun getOffsetCount() = 0
|
||||
|
||||
public override fun getOffsets(offsets: IntArray?, index: Int) = index
|
||||
public override fun setOffsets(offsets: IntArray?, index: Int) = index
|
||||
|
||||
class object {
|
||||
val DATA_FLAVOR: DataFlavor = DataFlavor(javaClass<ConvertJavaCopyPastePostProcessor>(), "class: ConvertJavaCopyPastePostProcessor")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user