Skip to content

Commit 366c1b9

Browse files
authored
Spotless Eclipse CDT 9.4.4 (log service) (#286)
Added log service to Spotless Eclipse CDT.
1 parent e3b3d3e commit 366c1b9

File tree

5 files changed

+488
-6
lines changed

5 files changed

+488
-6
lines changed

_ext/eclipse-cdt/build.gradle

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ext {
77

88
p2Dependencies = [
99
'org.eclipse.cdt.core':'+', // CodeFormatter and related
10-
]
10+
]
1111

1212
}
1313

@@ -21,6 +21,10 @@ dependencies {
2121
compile ("org.eclipse.platform:org.eclipse.jface.text:${VER_ECLISPE_JFACE}") {
2222
exclude group: 'org.eclipse.platform', module: 'org.eclipse.swt'
2323
}
24+
// Required to by CCorePlugin calling CDTLogWriter
25+
compile "com.ibm.icu:icu4j:${VER_IBM_ICU}"
26+
// Required to by CCorePlugin calling PositionTrackerManager
27+
compile "org.eclipse.platform:org.eclipse.core.filebuffers:${VER_ECLISPE_PLATFORM}"
2428
}
2529

2630

_ext/eclipse-cdt/gradle.properties

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Versions correspond to the Eclipse-CDT version used for the fat-JAR.
22
# See https://www.eclipse.org/cdt/ for further information about Eclipse-CDT versions.
33
# Patch version can be incremented independently for backward compatible patches of this library.
4-
ext_version=9.4.3
4+
ext_version=9.4.4
55
ext_artifactId=spotless-eclipse-cdt
66
ext_description=Eclipse's CDT C/C++ formatter bundled for Spotless
77
ext_org=diffplug
@@ -14,3 +14,5 @@ ext_VER_JAVA=1.8
1414
VER_ECLIPSE_CDT=9.4
1515
VER_SPOTLESS_ECLISPE_BASE=[3.0.0,4.0.0[
1616
VER_ECLISPE_JFACE=[3.12.0,4.0.0[
17+
VER_ECLISPE_PLATFORM=[3.6.0,4.0.0[
18+
VER_IBM_ICU=[61,62[

_ext/eclipse-cdt/src/main/java/com/diffplug/spotless/extra/eclipse/cdt/EclipseCdtFormatterStepImpl.java

+13-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@
2121
import java.util.stream.Collectors;
2222
import java.util.stream.Stream;
2323

24+
import org.eclipse.cdt.core.CCorePlugin;
2425
import org.eclipse.cdt.core.formatter.CodeFormatter;
26+
import org.eclipse.core.internal.filebuffers.FileBuffersPlugin;
27+
import org.eclipse.equinox.log.ExtendedLogReaderService;
28+
import org.eclipse.equinox.log.ExtendedLogService;
2529
import org.eclipse.jface.text.Document;
2630
import org.eclipse.jface.text.IDocument;
2731
import org.eclipse.text.edits.TextEdit;
@@ -33,13 +37,18 @@ public class EclipseCdtFormatterStepImpl {
3337
private final CodeFormatter codeFormatter;
3438

3539
public EclipseCdtFormatterStepImpl(Properties settings) throws Exception {
40+
LogErrorService logService = new LogErrorService();
3641
SpotlessEclipseFramework.setup(
37-
bundles -> {}, //CDT does not use the internal Eclipse feature
3842
config -> {
39-
config.changeSystemLineSeparator();
43+
config.applyDefault();
44+
config.add(ExtendedLogService.class, logService);
45+
config.add(ExtendedLogReaderService.class, logService);
4046
},
41-
plugins -> {} //CDT does not use other Eclipse plugins
42-
);
47+
plugins -> {
48+
plugins.applyDefault();
49+
plugins.add(new FileBuffersPlugin());
50+
plugins.add(new CCorePlugin());
51+
});
4352
Stream<Entry<Object, Object>> stream = settings.entrySet().stream();
4453
Map<String, String> settingsMap = stream.collect(Collectors.toMap(
4554
e -> String.valueOf(e.getKey()),

0 commit comments

Comments
 (0)