Skip to content

Commit

Permalink
Spotless Eclipse CDT 9.4.4 (log service) (#286)
Browse files Browse the repository at this point in the history
Added log service to Spotless Eclipse CDT.
  • Loading branch information
fvgh committed Aug 29, 2018
1 parent e3b3d3e commit 366c1b9
Show file tree
Hide file tree
Showing 5 changed files with 488 additions and 6 deletions.
6 changes: 5 additions & 1 deletion _ext/eclipse-cdt/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ext {

p2Dependencies = [
'org.eclipse.cdt.core':'+', // CodeFormatter and related
]
]

}

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


Expand Down
4 changes: 3 additions & 1 deletion _ext/eclipse-cdt/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Versions correspond to the Eclipse-CDT version used for the fat-JAR.
# See https://www.eclipse.org/cdt/ for further information about Eclipse-CDT versions.
# Patch version can be incremented independently for backward compatible patches of this library.
ext_version=9.4.3
ext_version=9.4.4
ext_artifactId=spotless-eclipse-cdt
ext_description=Eclipse's CDT C/C++ formatter bundled for Spotless
ext_org=diffplug
Expand All @@ -14,3 +14,5 @@ ext_VER_JAVA=1.8
VER_ECLIPSE_CDT=9.4
VER_SPOTLESS_ECLISPE_BASE=[3.0.0,4.0.0[
VER_ECLISPE_JFACE=[3.12.0,4.0.0[
VER_ECLISPE_PLATFORM=[3.6.0,4.0.0[
VER_IBM_ICU=[61,62[
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.formatter.CodeFormatter;
import org.eclipse.core.internal.filebuffers.FileBuffersPlugin;
import org.eclipse.equinox.log.ExtendedLogReaderService;
import org.eclipse.equinox.log.ExtendedLogService;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
import org.eclipse.text.edits.TextEdit;
Expand All @@ -33,13 +37,18 @@ public class EclipseCdtFormatterStepImpl {
private final CodeFormatter codeFormatter;

public EclipseCdtFormatterStepImpl(Properties settings) throws Exception {
LogErrorService logService = new LogErrorService();
SpotlessEclipseFramework.setup(
bundles -> {}, //CDT does not use the internal Eclipse feature
config -> {
config.changeSystemLineSeparator();
config.applyDefault();
config.add(ExtendedLogService.class, logService);
config.add(ExtendedLogReaderService.class, logService);
},
plugins -> {} //CDT does not use other Eclipse plugins
);
plugins -> {
plugins.applyDefault();
plugins.add(new FileBuffersPlugin());
plugins.add(new CCorePlugin());
});
Stream<Entry<Object, Object>> stream = settings.entrySet().stream();
Map<String, String> settingsMap = stream.collect(Collectors.toMap(
e -> String.valueOf(e.getKey()),
Expand Down
Loading

0 comments on commit 366c1b9

Please sign in to comment.