How to avoid endless formatting cycle eclipse vs intellij [duplicate] - java

Few weeks ago I tried Intellij and I found it really awesome. Now, at my project there are two programmers (including me) using Intellij and few other programmers who are going to keep using Eclipse. Since this project is already very large and it's going to grow a lot, we need to use compatible Code Style and Code Formatting between Intellij and Eclipse. We do not want to have problems when one user edits some file and reformats it before saving. With Eclipse "alone" we used to have some exported configuration, and before anybody starts to work, the first step is just to import this configuration. We already tried to use External Code Formatter, but it didn't work on Intellij 9.
So, I have a bunch of questions here:
Is there any way to import eclipse formatting configuration on Intellij 9?
Anybody could share their experience managing this kind of situation? Do you guys have any other suggestion to manage this situation?

There is an updated plugin for IDEA, called Eclipse Code Formatter:
http://plugins.intellij.net/plugin/?idea&id=6546

I would recommend someone spends the time to configure their IntelliJ's code style to be the same as Eclipse. This will take a little time and effort but once it is done, you can export it just like in eclipse so that any other IDEA users can import it.
You could also search online to see if anyone has already done this and you can simply download the code style config and use it.
The only alternative I can think of would be to find a standardized code style template that is available for both eclipse and IntelliJ, like the Recommended Sun Java Code Style.

There seems to be a plugin for that (emerged from this discussion).

Related

Java Code generation conflicts in intellij vs eclipse [duplicate]

This question already has answers here:
How to create an Intellij and Eclipse compatible code style and code formatting configuration (for java code)?
(3 answers)
Closed 4 years ago.
I am working on a java project with a team. All of the members use eclipse and I use intellij. Everytime I push my code to github there are hundreds of diff lines unnecessarily due to formatting differences in eclipse and github.
Also hashcode and equals method generate different code style in intellij wrt eclipse.
How can I configure intellij to use same code formatting and code generation style used by eclipse?
My teammates use default settings of eclipse.
In eclipse, you can export the code formatter settings to XML.
Intellij allows you to import these settings. That works for most parts. But even on the intellij help pages you find information that some things won't work (but there is an intellij plugin supposed to help, too). See their blog for example.
For code generation, things are a bit different. But I think that intellij even asks you what "style" to use when generating these methods.
The other part that really requires attention: order of import statements. But that one is easily, as that link implies, you edit your IntelliJ settings once, and they match. For the formatter, theoretically, every time when eclipse releases a new release, you might have to export/import settings again. This is a never ending story ...
Leading to: be aware that fighting tooling is always an uphill battle. In our setup, enough people switched from eclipse to intellij to make it work. I wouldn't have made that step otherwise. And I researched such questions first, instead of first learning a new tool, ending up in large, annoying diffs.

IDEA - Custom Errors

While working on my code I was reminded of just how much IDEA does for me. This gave me the idea, what if I could add some custom compile time processing. In which, if my code is invalid it will prompt me with an error. Say for example I left a return type as a null when it should never be null. Basically framework and API checks to reduce production errors.
The problem is I have no clue where to start on doing this. I assume I need to develop a plugin but am having issues finding documentation. If someone would be so kind as to help me get started. As well maybe even provide links to example projects or existing projects (github if possible).
As well I plan to release this plugin as part of a few APIs I develop. So helping me will help others in the long run :)
You can create an intellij plugin that implements custom inspections.
Example here:
https://confluence.jetbrains.com/display/IDEADEV/Inspection+of+Code+Source
The inspections that you create can highlight code red, allow the user to disable them, and also prompt for fixes. Please see intellij plugin development API's for more details.
You can use standard java assertions for this:
https://docs.oracle.com/javase/8/docs/technotes/guides/language/assert.html

What are the advantages of IntelliJ over Eclipse? [duplicate]

This question already has answers here:
Things possible in IntelliJ that aren't possible in Eclipse?
(41 answers)
Closed 8 years ago.
I have been working with Eclipse for quite some time and recently got several recommendations to use IntelliJ.
As I just saw that questions of the format of "Which IDE is better?" are frowned upon (not without a good reason) - I wanted to know objectively what are the advantages of IntelliJ over Eclipse.
I know what Eclipse does and frankly I'm not missing anything. But this is exactly what I said about Visual Studio 2005 (C#) before starting to work on Eclipse - and now I can't even write a Hello World in VS without getting annoyed ...
I'll narrow the question down to the world of Java SE and Java EE only. No Android, no GUI.
I'm looking for:
What does IntelliJ give me that Eclipse lacks?
What does Eclipse give me that IntelliJ lacks?
Try to be objective, and please only answer if you had substantial experience with both tools.
Thanks.
Edit: The scope of work I'm looking for is both for working on private projects and as part of a team of several developers working on the same product. But if I have to choose - I'll focus on teams only.
JUnit is a crucial part of the work (personally I started working in TDD several months ago - but lets not open that).
I'll also be interested to know about ANT/Maven related benefits if there are - although my prime motives are to know if I can benefit from things like: Quicker development (e.g. code generation, templates, auto complete etc.), Easier AUT, simpler Java EE application deployment during development (for UT) etc.
For me there are two points:
Refactorings (IntelliJ is great in the refactorings it provides)
Plugin stability, I've always found that when I have a stable install of Eclipse, I get a new plugin and everything comes down in flames and I have to reinstall everything.
IntelliJ allows me to navigate between Java, JSP, JS, CSS and pretty
must every other type of file. With Eclipse I need to install a plugin
to be able to navigate through file types other than Java.
#Rachel. Hmmm. In Eclipse Ctrl-Shift-R (on mac Command-Shift-R), open up "Open Resource" dialog where you can type whatever you want and it will match ANY file, not just Java. Ctrl-Shift-T will do the same, but limit it only to Java types.
This is the keymap of IntelliJIDEA.
Just read this article and you able to doing amazyng features with IntelliJ which you do not even dream of in Eclipse. For me, the most useful are Ctrl-Y , Ctrl-Enter, Ctrl-Alt-T, Shift-F6 and auto-completion.
Code navigation. (being able to find method and field declarations and usages.)
We have a J2EE project at work where both IntelliJ and Eclipse are in use so I have been able to compare the abilities of both.
IntelliJ allows me to navigate between Java, JSP, JS, CSS and pretty must every other type of file. With Eclipse I need to install a plugin to be able to navigate through file types other than Java.

Refactoring without eclipse

I am currently working on a source tree with hundreds of java modules that reference eachother. I can't want to import them all into Eclipse because it becomes very confusing and slow. Are there any stand alone linux tools that can help me refactor code? If not, how can I go about doing this effectively without Eclipse?
** Edit I would like a tool that someone has used. I realize there are a lot of tools out there that may or may not work. I was hoping SO could help me by narrowing the list.
**Edit I appreciate the help but I don't really want to justify not using Eclipse for this operation. I already use it to edit 20 or so of these modules at a time. I can't keep the amount of source I want to in the workspace effectively.
A quick google search returned RefactorIT. That's as good as place as any to start.
I am also curious how Eclipse would make it more confusing. I can't imagine that manually organizing code would be less confusing than having Eclipse's project explorer, for example.

Can I develop for Greenfoot using Intellij Idea?

I'm taking a Java course where I have to do some development for Greenfoot. I'm very accustomed to using vim for development in C / C++ and so have been using Intellij Idea with a vim plugin.
I despise the Greenfoot IDE.
Is it possible to use Intellij to develop for Greenfoot?
As you've found already you can add libraries and mess around to get some bits working, but it's not officially supported (so might change from release to release or break) and most likely never will be. It's more by accident than design that it works at all this way.
I've often wanted to use a professional IDE for doing Greenfoot work myself, but the simple answer is that Greenfoot is primarily focused for beginners, for a fun and interactive way of teaching Java to people who have never programmed previously. The developers could potentially focus their time in providing official support for coding in other IDE's, but the amount of work required means it's pretty much been decided it's not worth doing.
If you haven't noticed already, Greenfoot 2 is now out with a much improved editor that supports basic code completion and intelli-sense. It's still of course nowhere near the IntelliJ editor, nor will it ever be, but it certainly makes developing in it more tolerable if you're used to something more advanced.
I use IntelliJ and I do not think it would be supported, but I am not certain.
This site has a similar question
I was able to go into the Project Structure, dependencies tab, select add module library and do attach classes selecting the /lib/greenfoot/standalone directory. This allows me to compile the balloons scenario cleanly. However, to actually run the scenario's you still have to use the Greenfoot environment due to all the games it plays behind the scenes.
This link is about Greenfoot in Eclipse, but the steps also seem to work with IntelliJ.
Basically you add bluejcore.jar and greenfoot.jar (found in your installation directory of Greenfoot) as your project libraries and create a properties file (details in the link) for Greenfoot. Finally select GreenfootScenarioMain as main class, this allows you to launch Greenfoot programs from within IntelliJ.

Categories

Resources