Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I clone a class in intellij?

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.

[Edit]

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.

like image 769
Andrew Bucknell Avatar asked Sep 06 '25 06:09

Andrew Bucknell


1 Answers

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.

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)

like image 159
Mifeet Avatar answered Sep 07 '25 21:09

Mifeet