Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply eclipse-jdt-4.8.1 #960

Merged
merged 1 commit into from
Oct 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ This document is intended for Spotless developers.
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`).

## [Unreleased]
### Fixed
* [module-info formatting](https://github.com/diffplug/spotless/pull/958) in `eclipse-jdt` versions `4.20` and `4.21`. Note that the problem also affects older versions.

## [2.19.0] - 2021-10-02
* Added `wildcardsLast` option for Java `ImportOrderStep` ([#954](https://github.com/diffplug/spotless/pull/954))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ private static FormatterFunc apply(State state) throws Exception {
Class<?> formatterClazz = getClass(state);
Object formatter = formatterClazz.getConstructor(Properties.class).newInstance(state.getPreferences());
Method method = formatterClazz.getMethod(FORMATTER_METHOD, String.class);
return JVM_SUPPORT.suggestLaterVersionOnError(state.getSemanticVersion(), input -> (String) method.invoke(formatter, input));
FormatterFunc formatterFunc = getFormatterFunc(formatter, method);
return JVM_SUPPORT.suggestLaterVersionOnError(state.getSemanticVersion(), formatterFunc);
}

private static Class<?> getClass(State state) {
Expand All @@ -59,4 +60,11 @@ private static Class<?> getClass(State state) {
}
return state.loadClass(FORMATTER_CLASS_OLD);
}

private static FormatterFunc getFormatterFunc(Object formatter, Method method) {
if (1 == method.getParameterCount()) {
return input -> (String) method.invoke(formatter, input);
}
return (FormatterFunc.NeedsFile) (input, file) -> (String) method.invoke(formatter, input, file);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat trick, LGTM.

}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Spotless formatter based on JDT version 4.20.0 (see https://projects.eclipse.org/projects/eclipse.jdt)
# Compare tag in M2 pom with https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/log/?h=R4_20 to determine core version.
com.diffplug.spotless:spotless-eclipse-jdt:4.8.0
com.diffplug.spotless:spotless-eclipse-jdt:4.8.1
com.diffplug.spotless:spotless-eclipse-base:3.5.0
com.github.spotbugs:spotbugs-annotations:4.0.2
com.google.code.findbugs:jsr305:3.0.2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Spotless formatter based on JDT version 4.21.0 (see https://projects.eclipse.org/projects/eclipse.jdt)
# Compare tag in M2 pom with https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/log/?h=R4_21 to determine core version.
com.diffplug.spotless:spotless-eclipse-jdt:4.8.0
com.diffplug.spotless:spotless-eclipse-jdt:4.8.1
com.diffplug.spotless:spotless-eclipse-base:3.5.0
com.github.spotbugs:spotbugs-annotations:4.0.2
com.google.code.findbugs:jsr305:3.0.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

class EclipseJdtFormatterStepTest extends EclipseResourceHarness {
private final static String NON_SEMANTIC_ECLIPSE_VERSION = "4.7.3a";
private final static Jvm.Support<String> JVM_SUPPORT = Jvm.<String> support("Oldest Version").add(8, "4.6.1");
private final static Jvm.Support<String> JVM_SUPPORT = Jvm.<String> support("Oldest Version").add(8, "4.6.1").add(11, "4.20.0");
private final static String INPUT = "package p; class C{}";
private final static String EXPECTED = "package p;\nclass C {\n}";

Expand Down
2 changes: 2 additions & 0 deletions plugin-gradle/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `3.27.0`).

## [Unreleased]
### Fixed
* [module-info formatting](https://github.com/diffplug/spotless/pull/958) in `eclipse-jdt` versions `4.20` and `4.21`. Note that the problem also affects older versions.

## [5.16.0] - 2021-10-02
* Added `wildcardsLast()` option for Java `importOrder` ([#954](https://github.com/diffplug/spotless/pull/954))
Expand Down
2 changes: 2 additions & 0 deletions plugin-maven/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`).

## [Unreleased]
### Fixed
* [module-info formatting](https://github.com/diffplug/spotless/pull/958) in `eclipse-jdt` versions `4.20` and `4.21`. Note that the problem also affects older versions.

## [2.17.0] - 2021-10-04
### Added
Expand Down