Coming from Eclipse, how to do this in IntelliJ?
I have been using Eclipse for over 5+ years and decided to try out IntelliJ 11, due to my disappointment in Juno.
Two things that I really enjoyed in Eclipse I have trouble setting up in IntelliJ:
1) In Eclipse, if I make any kind of code modifications (adding or deleting), I can see some kind of colored marker on the editor overview or scrollbar to indicate that. In IntelliJ, I can see that configuration is in the Appearnaces editor section but the ability to set the marker error is disabled.
How can I configure that?
2) While in debug mode in Eclipse, if I click the red stop button, it KILLS the thread immediately, terminates the process, and destroys the server. In IntelliJ during debug mode, if I click the red button, it RESUMES out of debug mode, finishes the thread and then disconnects from the server.
The reason why I prefer Eclipse's method more is because if I notice during the debug session that some code is wrong, I can terminate the thread immediately without further processing my test data. In IntelliJ, it continues the thread and writes to my test data, which I could have prevented if the stop button would kill the process immediately.
Thanks for any help.
Please sign in to leave a comment.
Hello Gary,http://youtrack.jetbrains.com
For number (1), the project needs to be under version control. This is because IDEA uses the version control version as the baseline to diff against. (I'm not familiar with Eclipse, so I do not know if it provides this functionality using the file state at IDE startup as the diff baseline. If that is the case, and you want to see this in IDEA, I recommend opening a feature request. While you wait for the feature to be added, consider using a local VCS repository like Mercurial or subversion to work against.) In addition to the code being under version control, IDEA needs to know it is under version control. With version control systems (VCS) that place a metadata file or directory in the source code tree (such as the .git, .hg, .svn, CVS, etc.) IDEA will (usually) auto-detect the VCS and set it. For others that do not use metadata (such as TFS & Perforce) you need to set it. The quick way is either via the version control popup menu [Ctrl+Alt+` (back quote), ⌃V (Mac), or VCS > VCS Operations Popup]; or via the menu at VCS > Enable Version Control Integration. You can also configure this or modify it in the Version Control section of the project settings in the settings dialog [Ctrl+Alt+S (File > Settings) or ⌘, (IntelliJ IDEA > Preferences) on the Mac].
Once version control is set, you will get change markers on the left gutter (assuming the gutter is turned on in the Editor > Apperance settings). See Help > IntelliJ IDEA > IntelliJ IDEA Usage Guidelines > Version Control with IntelliJ IDEA > Viewing Changes Information > Using Change Markers to View and Navigate Through Changes in the Editor for more information on the additional functionality the marker provide (such as isolated diffs and rollbacks).
As for (2), one of the JetBrains developers can chime in on that. But IMHO, I think what IntelliJ IDEA is doing is far more desirable. It is issuing a graceful shutdown of the server. This will allow any resources to properly cleanup (if they need to) and be properly closed. This includes calling the contextDestroyed method on any ServletContextListeners. This will prevent corrupt files, hung processes or locks. I've worked on web applications where a hard kill caused all sorts of problems due to file locks and database locks.
At one point there was a separate kill button. Now however after clicking the stop button it becomes a kill button until the server is down. So it is primarily meant to be used to issue a kill when the server will not shutdown otherwise. I'm not sure if they made that change to reduce button clutter, or to prevent the type of problems I describe above due to a non-graceful shutdown. To my knowledge, there is no way to change this behavior shy of killing the process yourself in the task manager.
I hope that helps,
Mark
For 1), my source is in CVS. I would like to have the my changes be compared with CVS repo instead of my base code.
I am saddened to hear about 2) but maybe the answer to my next question will alleviate that a little.
In Eclipse, there is this feature called "Display View". While in debug, I can enter snippets of Java code in this window that allows me to evaluate or alter anything in the scope of my thread execution.
Does IntelliJ have this?
> While in debug, I can enter snippets of Java code in this window that allows me to evaluate or alter anything in the scope of my thread execution.
select any code, hit alt+F8
alternatively: click on 'Evaluate Expression' button in Debug tool window
alternatively: add expression to Watches panel of Debug tool window
Does that also let me introduce or modify variables that are in scope of my thread?
Yes, you can execute assignments in "evaluate expression" dialog.
Plus there is a "Set Value" popup menu on local variables shown in Debug tool window.
upd.
Please see more details in IDEA help:
http://www.jetbrains.com/idea/webhelp/evaluating-expressions.html
http://www.jetbrains.com/idea/webhelp/debug-tool-window-variables.html
http://www.jetbrains.com/idea/webhelp/setting-labels-to-variables-objects-and-watches.html
In the editor, changes are compared to the revision that is in CVS sandbox (i.e. the changes are compared to the revision that you last checked out or updated to.) So if you have version 2 in your sandbox and are editing it, the editor shows changes compared to that version 2 even if someone has since committed version 3 to the main repository. If you want to compare your changes to version 3 (or any other version) in the repository you can access the "Compare with Latest RepositoryVersion" or "Compare with..." (to compare with a branch or tag), or "Compare with Specified Revision..." to open a comparison in a diff window. Alternatively, if you are viewing the history, you can select a revision and select the "Compare with Local" button to see a diff. If you do an update (and merge) to get version 3, the editor will then show your changes as compared to version 3.
I hope that helps.
Reformat edited lines on save action.
So I googled around and found a way to reformat the code when manually saving a file. The macro I have set up is ctrl + alt + l and then ctrl + s.
I have two problems with this macro though.
1) I only want it to reformat the lines I have edited and not the entire file. I have "Only text changed to VCS" checked but I want IntelliJ to remember that. As soon as I check "Do not show this dialog in the future", it goes back to reformatting the entire class.
2) There is a quirk with the above macro that I noticed. What appears to happen is that it would start reformating the code, save immediately, and then reformatting finally completes. So as soon as saving action is done, the class file returns to show as being modified from the lagging reformat