Skip to content

Java style for Eclipse formats imports incorrectly #273

@donce

Description

@donce

From https://google.github.io/styleguide/javaguide.html#s3.3.3-import-ordering-and-spacing:

If there are both static and non-static imports, a single blank line separates the two blocks.

Now, all imports are in a single block:

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import java.net.URI;
import java.util.Collections;
import org.eclipse.core.runtime.CoreException;
import org.junit.Test;

Empty line should be left between static and non-static imports, so it should be like this:

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;

import java.net.URI;
import java.util.Collections;
import org.eclipse.core.runtime.CoreException;
import org.junit.Test;

This formatting is done by this line in config:

<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="0"/>

The problem is that Eclipse doesn't seem to support custom spacing between static and non-static groups.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions