如何在intellij中克隆一个类? [英] How do I clone a class in intellij?

查看:152
本文介绍了如何在intellij中克隆一个类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在intellij有一个scala项目。我想将一个新类克隆到源类所在的同一个包中,但我无法弄清楚如何执行此操作。我可以看到如何将其复制到新包中,但我想在同一个包中复制/克隆。

I have a scala project in intellij. I would like to clone a new class into the same package the source class is in, but I cant figure out how to do this. I can see how to copy it to a new package, but I want to copy/clone within the same package.

如果我在com.company.widgets包中有一个名为orderwidget的类,并且我想在com.company.widgets中创建productwidget,我需要能够克隆orderwidget并重命名它。复制不会起作用,因为包中已经存在orderwidget。

If I have a class called orderwidget in package com.company.widgets and I want to create productwidget in com.company.widgets, I need to be able to clone orderwidget and rename it. Copy wont work because orderwidget already exists in the package.

推荐答案

我使用的是drag&将您尝试复制的文件删除到项目视图中的父文件夹,按住 Ctrl 复制文件。

What I use is drag & drop the file you try to copy to the parent folder in Project view, holding Ctrl to copy the file.

我承认它在某些情况下有效但在其他情况下则不然。有时,Idea会为您提供一个对话框,询问新文件的名称;有时是没有,并给出文件已存在错误;有时它会复制文件但会弄乱它的内容(构思14.1.4)

I admit it works in some cases but doesn't in others. Sometimes Idea offers you a dialog asking for name of the new file; sometimes is doesn't and gives "File already exists" error; sometimes it copies the file but messes up it's contents (Idea 14.1.4)

这篇关于如何在intellij中克隆一个类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆