Importing code style formatting settings into eclipse from intellij-idea - java

I've recently implemented the maven Check style plugging into my project and have changed all of the formater Settings in intellij (Which I use) to conform to this style guide (which they now do).
However I need to produce a settings .xml file for eclipse, so that my colleagues can automatically format there code so that it also conforms to this style guide.
The problem I am finding is that I cannot see a way of exporting the settings from intellij and importing them into eclipse. and I cannot manually configure eclipse to conform with the nuances of the new style guide (Continuation indentation being the main problem).
Any help or Ideas would be fantastic. :)

I couldn't find a ready plugin for that in 2018. So here is a side by side code style configuration from UI perspective of Intellij IDEA 2017.3 and Eclipse OXYGEN.3 March 2018. If both configured this way the code will be formatted close enough, so for example github will show you code differences so that it make sense.
For our project we configured one XML for each IDE so they more or less match:
IntelliJ Config File is default of IDEA 2017.3 so not much to define in XML - enter link description here
Eclipse Config is modified a bit from the default to match IntelliJ - link
Here is also a PDF file to show all the options set in both IDEs side by side - link
There is also a project to solve this problem across more IDEs(Answer) : EditorConfig

There is a EditorConfig - independent format for editors/IDEs code style configuration.
There are EditorConfig plugins for most popular editors(see full list here).
You can see examples for IntelliJ IDEA(tutorial) and Eclipse(plugin page).

You can export settings in Intellij by clicking on File > Export Settings but they will be in .jar format.
According to this thread there is no easy way of importing settings.jar into eclipse.
Eclipse - import code format settings
I hope this helps :)

The exact data from JetBrains is here. Check out the Link
Hit like if this helps.

Related

Is there a possibility in IntelliJ (or other free IDE/Tool) to indent whole project (only indentation without formatting))

I want to format code in my project. First of all I want to make consistent indentation in all the java files.
I know there is CTRL+ALT+L option, but it also formats other things - spacing in braces and so on.
CTRL+ALT+I is what I want to do, but automatically on all classes in project.
I checked Eclipse plugin, JIndent tool and none of those tool meet the requirements.
What do I expect is having all java files in a consistent indentation style (2 spaces) and all other aspects of formatting not changed.
Thanks for any suggestions.
I would suggest to use Google Java code formatter which brings uniformity in both Eclipse and Intellij Idea IDE. I provide below the link.
https://github.com/google/google-java-format
You can install the plugin in eclipse and make changes in Eclipse Preference page. In case of Eclipse, you have to use the key command as CTRL+SHIFT+F
In case of Intellij IDE, you have to use the key command as CTRL+ALT+L to format the code.
You can see the screen shot for Eclipse preference Page below.
You can see the screen shot for Intellij Idea setting page below.

How to run google format by execute google-java-format Plugin in Intellij IDEA

Many questions regarding this issue can be found, for example this and this. But none of them are really solves the issue that how to run the plugin to reformat java code against java google format code style
Download and import intellij-java-google-style.xml to intellij only partly solves the issue, because using the code schema will not be 100% match against code formatted with the actual google code formatter. This is very annoying when using git hook for format check when commit.
The currently intelliJ IDEA I'm using is 2018.3.4 community version
Question 1:
How can I create a hot key combination, for example: Ctrl+Shift+J, to run the code format? I did a similar configuration for scala code format according to this question, and it works fine. The different thing is, the scala format plugin comes with a default mapping key, I changed the key combinations rather than create any.
Question 2:
Is that means any new lines will be automatically formed according to the google java code style after installed and enabled the google-java-format Plugin for intellij IDEA
Question 3:
When multiple code format plugins were installed, is that means the code format will be automatically applied to the corresponding code files? or further configuration is needed?
Question 1:
In the keymap settings there is an entry for that called Main Menu -> Code -> Reformat Code. It has a default hotkey mapped to it (in my IntelliJ 2019.1 EAP for Mac).
Question 2:
I don't use the git hook, but I do use the google code format and it's checked in our CI pipelines and sonar etc. I sometimes use this hotkey but I've also installed the save actions plugin and configured it to trigger format code (cvs changed lines only) on save. This way it is automatically formatted according to googles code style upon commit and I never have any conflicts.
Question 3:
Depends on the plugins I suppose. I think it's best to have no more than 1 code style plugin per language / file type to avoid conflicts.

Intellij is showing only part of the expected documentation for builtin classes(javadoc)

I am having a weird problem with intellij. A handful of people in here, had similar issues in the past but none of the proposed solutions worked for me.
So I am trying to view the javadoc for a builtin class(in my example java.io.FileReader) but I am only getting information about the signature, not details about the method as it is usually happening. I have also tried things around quick and external documentation, I have even added an external doc url in the project settings but nothing happened.
In the screenshot you can see the output I am getting. Any help appreciated.
Looks like Eclipse uses a different approach for the documentation. Also I had a non-fully document API and thats, combined, the reason it was not working.
The solution is as follows: File -> Project structure -> SDKs -> Documentation paths -> Click the add button, with the earth on it -> Add an online documentation source.
If you click the other one, you need to space a folder in your filesystem.
Both work. Thank you for your help.
Ctrl + Q
This assumes you have the JDK (with documentation) downloaded and configured with IntelliJ for the relevant object/class/method.
Edit:
Turned out it was a problem with the Users' JDK.
The JDK source files didn't contain any comments (which IntelliJ uses to show JDK Documentation). This was resolved by installing the JDK Documentation and configuring it with IntelliJ.

Java decompiler plugin not working

I have the JD-eclipse-plugin installed. I want to decompile the classes within a jar-file. So I select the jar-file within Project-Explorer and click Decompiler in the Menu. However both decompilers (JAD and JD-core) are greyed out.
I also tried the steps shown in this blog on AVAJAVA Web Tutorials. I guess the blog is a bit outdated, however I can see within Windows-->Preferences-->Java-->Decompiler that Jad is correctly set up. But there is no JD-eclipse found within Preferences-->General-->Editors-->File Associations as you can see in the following image.. Now I right click the jar-file within Project-Explorer, but there is no such "Attach Source File".
Did I miss anything to set up the plugin?
EDIT: I´m using the following setup: Eclipse: Mars.1 Release (4.5.1); JadClipse 4.0.0; JDK 1.8
EDIT2: Forgot to mention that I use Tomcat and want to dive into the libraries from /WebContent/WEB-INF/lib. This is not working, I cannot further collapse the jar-files.
For Eclipse 2018-09 , the problem was related to " class without source
"
I had resolved this issue by going to:
Preferences
General
Editors
File Associations
Class without source
and setting decompliler viewer as default : see the following screen shot:
Obviously I mixed the actual JD-eclipse-plugin an a plugin called JadClipse for Eclipse which is a slightly different plugin from eclipse marketplace. Thus when I followed the installation instructions of JD-eclipse, I could set the options for the screenshot posted within the question. So I set JD-eclipse as default for both *.class-files with and those without source-code.
Second mistake I did was a pretty silly and obvious one, namely that I wanted to browse the jar-files from within WEB-INF-folder of my Tomcat instead of from within Java Resources. Thus I could not dive into the jar-files at all hindering me to get to the class-level and thus to decompile those classes contained within the jar.
I hope this helps anyone outside also having trouble with the plugin for eclipse.
I had the same problem but "class without source" did have decompliler viewer as default. So all I did was set class file viewer as default and then switched back and that fixed the issue.
I had to update all of my plugins. the Procyon decompiler has this symptom when running under java 11 or later.

My check style plugin in eclipse doesn't showcase a warning for hard coded value for string

I have configured check style plugin in eclipse juno.
I have a following snippet in my code:
articleView.setResponseType("HTML");
articleView.setImageFilePrefix(imageURL);
articleView.setUrlIndicator("Y");
In above code , I want to make checkstyle plugin to check is there any hard coded values or not like "HTML"
I am using built in sun check style xml file.
I have used following check style plugin version for eclipse juno :
"net.sf.eclipsecs-updatesite_6.4.0.201503042206-bin.zip"
How can I make my check style plugin to check is there any hard code values or not mean to say is there, any rule which we can define in check style xml fiel to check hard coded values for string.
Can any one help me out.
Thanks in advance.
Naresh.
How about this? I've copied and modified the existing sun checkstyle configuration and made it default.
Eclipse can do this without check style.
In the Preferences look at 'Java > Compiler > Errors/Warnings'. In the 'Code style' section change 'Non-externalized strings' to Warning or Error.

Categories

Resources