Conversion on copy paste:

Introduce tests for conversion on copy paste
Don't insert additional end of line after each converted element (not needed since converter takes care of formatting)
Add test for some of the trivial cases of conversion on copy paste
This commit is contained in:
Pavel V. Talanov
2013-12-19 17:30:18 +04:00
parent a25ced9aa0
commit 1464d1f7ad
19 changed files with 277 additions and 4 deletions
@@ -0,0 +1,39 @@
class A {
fun someOther() = false
private fun formatElement(var element : PsiElement) : String {
element = JetPsiUtil.ascendIfPropertyAccessor(element)
if (element is JetNamedFunction || element is JetProperty)
{
val bindingContext = AnalyzerFacadeWithCache.analyzeFileWithCache((element.getContainingFile() as JetFile)).getBindingContext()
val declarationDescriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, element)
if (declarationDescriptor is CallableMemberDescriptor)
{
val containingDescriptor = declarationDescriptor.getContainingDeclaration()
if (containingDescriptor is ClassDescriptor)
{
return JetBundle.message("x.in.y", DescriptorRenderer.COMPACT.render(declarationDescriptor), DescriptorRenderer.SOURCE_CODE_SHORT_NAMES_IN_TYPES.render(containingDescriptor))
}
}
}
assert(element is PsiMethod) {"Method accepts only kotlin functions/properties and java methods, but '" + element.getText() + "' was found"}
return JetRefactoringUtil.formatPsiMethod((element as PsiMethod), true, false)
}
protected fun getDimensionServiceKey() : String {
return "#org.jetbrains.jet.plugin.refactoring.safeDelete.KotlinOverridingDialog"
}
public fun getSelected() : ArrayList<UsageInfo> {
val result = ArrayList<UsageInfo>()
for (i in 0..myChecked.length - 1) {
if (myChecked[i])
{
result.add(myOverridingMethods.get(i))
}
}
return result
}
}