Skip to content

SortImports option is ignored #42

@sherter

Description

@sherter

No matter which SortImports option I set (ONLY, ALSO or NO), the imports are never sorted and it always returns the same result. Am I missing something here?

public static void main(String[] args) throws FormatterException {
  JavaFormatterOptions options = new JavaFormatterOptions(JavadocFormatter.NONE, Style.GOOGLE, SortImports.ONLY);
  Formatter formatter = new Formatter(options);
  String result = formatter.formatSource("package com.google.example;\n" +
                "\n" +
                "import com.google.common.base.Preconditions;\n" +
                "\n" +
                "import org.junit.runner.RunWith;\n" +
                "import org.junit.runners.JUnit4;\n" +
                "\n" +
                "import java.util.List;\n" +
                "\n" +
                "import javax.annotations.Nullable;\n" +
                "\n" +
                "import static org.junit.Assert.fail;\n" +
                "import static com.google.truth.Truth.assertThat;\n" +
                "\n" +
                "@RunWith( JUnit4.class ) public class SomeTest  {}");
  System.out.println(result);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions