Switching from eclipse to IntelliJ Idea

I am using the latest version of IntelliJ idea ultimate edition 9.04

intellij- In this code, physical package folder is missing therefore a compiler error "this package does not exist", any shortcut key to create package instead of me manually creating the package folder?
in eclipse i could create using ctrl+1.

package net.jcip.examples; import net.jcip.annotations.*; /** * UnsafeSequence * * @author Brian Goetz and Tim Peierls */ @NotThreadSafe public class UnsafeSequence {     private int value;     /**      * Returns a unique value.      */     public int getNext() {         return value++;     } }


6 comments
Comment actions Permalink

Hello Aman,

Press Alt-Enter to show the quickfixes menu in IntelliJ IDEA.

I am using the latest version of IntelliJ idea ultimate edition 9.04

intellij- In this code, physical package folder is missing therefore a
compiler error "this package does not exist", any shortcut key to
create package instead of me manually creating the package folder? in
http://www.myeclipseide.com/ i could create using ctrl+1.

 
> import net.jcip.annotations.*;
> 
> /**
> * UnsafeSequence
> *
> * @author Brian Goetz and Tim Peierls
> */
> @NotThreadSafe
> public class UnsafeSequence {
> private int value;
> /**
> * Returns a unique value.
> */
> public int getNext() {
> return value++;
> }
> }
> ]]>


---
Original message URL:
http://devnet.jetbrains.net/message/5279862#5279862


--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Thanks Dmitry for reply. I have already tried it, the quick fix suggests to set the package name to "" instead of the package name defined by me. Please see the attachment.

My intention is the quick fix should create a package folder for me, instead of me manually creating it. This feature works well in Eclipse 3.6.1



Attachment(s):
Untitled.jpg
0
Comment actions Permalink

why don't you just create your class in the correct package from the start ?
eg : select "New class " option from the drop down menu, and then write your class name using package "my.MyClass" for example ?

IDEA would then directly create the class in the correct package, even though it may not exist (and the name is considered relative to the item you right clicked on initially)

0
Comment actions Permalink

The reason I am doing this way because I am copying the Java source files and dropping it directly under src. When I am copying multiple source files, I don't have the opportunity to create a class.

This feature is frequently used by me and may be many other developers, I would recommend this handy feature to be implemented in IntelliJ Idea.

Thanks

0
Comment actions Permalink

I think it's a valid request (I am actually surprised that there's no intention to move the class into the correct directory according to the package statement).
If the top-level class name does not match the containing file name, there is a pair of complementary intentions: "Rename file" and "Rename class".
IMHO it should work both ways for packages too.

0

Please sign in to leave a comment.