• Stars
    star
    463
  • Rank 94,661 (Top 2 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 11 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

IntelliJ plugin - use Eclipse's code formatter directly from IntelliJ. https://plugins.jetbrains.com/plugin/6546

Adapter for Eclipse Code Formatter Donate

Allows using Eclipse's Java code formatter directly from IntelliJ. Solves the problem of maintaining a common code style in team environments where both IDEA and Eclipse are used.

Note: This project utilizes (and in some manners modifies) code licensed under EPL-2.0. For more information see lib/eclipse.


Sponsored by


Manage pull requests and conduct code reviews in your IDE with full source-tree context. Comment on any line, not just the diffs. Use jump-to-definition, your favorite keybindings, and code intelligence with more of your workflow.
Learn More


Instructions

  1. Install the plugin
  2. Configure it
    1. Configure Eclipse location (optional)
      • Install Eclipse
      • Got To IntelliJ Settings | Other Settings | Adapter for Eclipse Code Formatter
      • Set Eclipse installation folder (/Users/xxx/Eclipse.app/Contents/Eclipse for Mac)
      • Change Java formatter version to Configured Eclipse installation folder
    2. Configure formatter
      • Either, export formatter profiles to get a *.xml file

        1. Go to Eclipse | Windows | Preferences | Java | Code Style | Formatter
        2. Eclipse does not export default profiles, so you have to make your own via the New button
        3. Export the profile via the Export all... button
          • The result should look like this
      • Or, enable project specific formatter settings to get org.eclipse.jdt.core.prefs

        1. With your project open in Eclipse's workspace, right-click the project and choose Properties
        2. Go to Java Code Style | Formatter and select Enable project specific settings
        3. Click OK to save the settings
        4. Go to the .settings directory inside your project's directory. There you will find the org.eclipse.jdt.core.prefs file which contains the Eclipse formatter settings
          • The result should look like this
      • Or, export a Workspace Mechanic configuration to get a *.epf file

        • The result should look like this
      • Open a project in IntelliJ

      • Set path to the config file via IntelliJ | Settings | Other Settings | Adapter for Eclipse Code Formatter | Eclipse preference file

      • When using exported profiles (the xml file), select desired profile in the combobox Java formatter profile

    3. Check Optimizing Imports configuration
      • Set import order
        • Either, leave the default
        • Or, set path to Eclipse configuration file:
          • Go to Eclipse | Windows | Preferences | Java | Code Style | Organize Imports
            • Either, click on Export... , (example)
            • Or, enable project specific settings and use org.eclipse.jdt.ui.prefs file which should contain the line org.eclipse.jdt.ui.importorder=...
      • Set the value of Class count to use import with and Name count to use static import with in Settings | Editor | Code Style | Java | Imports for Idea 14 or Settings | Editor | Code Style | Imports for older Idea. Eclipse uses 99 by default
      • For versions lower than 4.0 - make sure to disable IntelliJ's Import Optimizing in the reformat dialog via Settings | Editor | Show "Reformat Code" dialog. The plugin will take care of imports anyway
      • For versions higher than 4.0 - imports will be reordered together with normal IntelliJ's import optimizing
      • Disable Optimize imports on the fly
  3. Format code as usual, notice the green bubble notification about successful formatting
    • notifications can be disabled at Settings | Notifications
  4. Use Ctrl + Alt + O as usual, it will use this plugin
  5. Use Ctrl + ~ for quick switch between formatters or icon at the main toolbar
  6. Give it 5 stars
  7. Make a donation

Possible problems with Java formatting

  • @formatter:off is not working See: #64
  • Nothing was formatted or formatting failed
    • Make sure you are using proper language level in Main Menu | File | Project Structure
  • Trailing spaces inside javadocs are stripped
    • Set Strip trailing spaces on save to None
  • File is formatted differently
    • The file is actually formatted fine, it just looks different in the editor, as the tab size and indendation are set differently in IntelliJ in Settings | Editor | Code Style | Java than in Eclipse. Using of either tab only or space only whitespace is recommended.
    • Or it is a bug
  • Eclipse indendation is configured for 2 spaces, but a new line gets indented by 4 spaces when Enter is pressed.
    • Change code style in IntelliJ. Not all things get formatted by this plugin when you type them.
  • If nothing helps

Troubleshooting

If it is mysteriously not working, go to Main Menu | Help | Edit Debug Settings and add:

krasa.formatter

Try to reformat something and create a new issue, including the log


YourKit-Logo

YourKit supports open source projects with its full-featured Java Profiler. YourKit, LLC is the creator of YourKit Java Profiler and YourKit .NET Profiler, innovative and intelligent tools for profiling Java and .NET applications.

More Repositories

1

StringManipulation

IntelliJ plugin - https://plugins.jetbrains.com/plugin/2162
Java
649
star
2

GrepConsole

IntelliJ plugin - https://plugins.jetbrains.com/plugin/7125
Java
406
star
3

MavenHelper

IntelliJ plugin - https://plugins.jetbrains.com/plugin/7179
Java
242
star
4

VisualVMLauncher

IntelliJ plugin - https://plugins.jetbrains.com/plugin/7115
Java
98
star
5

krasa-jaxb-tools

XJC / JAXB plugin for generation of Bean Validation Annotations (JSR-303) and replacing primitive types
Java
60
star
6

FrameSwitcher

IntelliJ plugin - https://plugins.jetbrains.com/plugin/7138?pr=idea
Java
38
star
7

IdeaIconPack

UX friendly old colorful icons for IntelliJ 2018.2+ solving https://youtrack.jetbrains.com/issue/IDEA-192025
Java
29
star
8

CpuUsageIndicator

IntelliJ plugin https://plugins.jetbrains.com/plugin/8580?pr=idea
Java
22
star
9

EditorGroups

IntelliJ plugin prototype of https://youtrack.jetbrains.com/issue/IDEA-12130#comment=27-2838171
Java
22
star
10

translator-generator-intellij-plugin

Work in progress, contributors welcomed.
Java
8
star
11

UsefulActions

IntelliJ plugin
Java
6
star
12

DevSupportApp

Wicket application for automatic merging, building (parametrized remote ssh scripts execution) , replacing tokens in branches, IntelliJ plugins repo...
Java
6
star
13

krasa-jaxb-tools-example

Sample project for https://github.com/krasa/krasa-jaxb-tools
Java
5
star
14

ProjectCommandLauncher

My personal IntelliJ plugin for an easier life
Java
4
star
15

my-intellij-settings

Theme configuration
4
star
16

NonProjectFilesUnlocker

Java
3
star
17

StringManipulation-Localization

IntelliJ plugin https://plugins.jetbrains.com/plugin/18291-string-manipulation--localization/
Kotlin
1
star
18

IconColumnExample

Java
1
star
19

WakeOnLan

Java
1
star
20

ArduinoLaserDistance

Arduino Uno + laser distance sensor + LCD
C++
1
star
21

EclipseCodeFormatter-from-GoogleCode

use this project https://github.com/krasa/EclipseCodeFormatter
Java
1
star
22

krasa-wicket-spring-boot-quickstart

Spring Boot + Wicket + Jetty
Java
1
star
23

Albion-Market-Client

Java
1
star