Skip to content

Commit a8380dd

Browse files
committed
Move CppDefaults.FILE_FILTER to its only user: gradle CppExtension (continuation of #630 and #634). Preserve its eclipse-specific info in the EclipseCdtFormatterStep comments.
1 parent 1a19b3f commit a8380dd

File tree

3 files changed

+25
-17
lines changed

3 files changed

+25
-17
lines changed

lib-extra/src/main/java/com/diffplug/spotless/extra/cpp/EclipseCdtFormatterStep.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016 DiffPlug
2+
* Copyright 2016-2020 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,7 +23,13 @@
2323
import com.diffplug.spotless.extra.EclipseBasedStepBuilder;
2424
import com.diffplug.spotless.extra.EclipseBasedStepBuilder.State;
2525

26-
/** Formatter step which calls out to the Eclipse CDT formatter. */
26+
/**
27+
* Formatter step which calls out to the Eclipse CDT formatter.
28+
*
29+
* Eclipse-CDT <code>org.eclipse.core.contenttype.contentTypes</code>
30+
* extension <code>cSource</code>, <code>cHeader</code>, <code>cxxSource</code> and <code>cxxHeader</code>.
31+
* can handle: "c", "h", "C", "cpp", "cxx", "cc", "c++", "h", "hpp", "hh", "hxx", "inc"
32+
*/
2733
public final class EclipseCdtFormatterStep {
2834
// prevent direct instantiation
2935
private EclipseCdtFormatterStep() {}

lib/src/main/java/com/diffplug/spotless/cpp/CppDefaults.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,13 @@
1616
package com.diffplug.spotless.cpp;
1717

1818
import java.util.Arrays;
19-
import java.util.Collections;
20-
import java.util.List;
2119
import java.util.stream.Collectors;
2220

2321
/** Common utilities for C/C++ */
2422
public class CppDefaults {
2523
//Prevent instantiation
2624
private CppDefaults() {};
2725

28-
/** Filtering based on Eclipse-CDT <code>org.eclipse.core.contenttype.contentTypes</code> */
29-
/**
30-
* Filter based on Eclipse-CDT <code>org.eclipse.core.contenttype.contentTypes</code>
31-
* extension <code>cSource</code>, <code>cHeader</code>, <code>cxxSource</code> and <code>cxxHeader</code>.
32-
*/
33-
@Deprecated
34-
public static final List<String> FILE_FILTER = Collections.unmodifiableList(
35-
Arrays.asList("c", "h", "C", "cpp", "cxx", "cc", "c++", "h", "hpp", "hh", "hxx", "inc")
36-
.stream().map(s -> {
37-
return "**/*." + s;
38-
}).collect(Collectors.toList()));
39-
4026
/**
4127
* Default delimiter expression shall cover most valid and common starts of C/C++ declarations and definitions.
4228
* Furthermore it shall not conflict with terms commonly used within license headers.

plugin-gradle/src/main/java/com/diffplug/gradle/spotless/CppExtension.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717

1818
import static com.diffplug.gradle.spotless.PluginGradlePreconditions.requireElementsNonNull;
1919

20+
import java.util.Arrays;
21+
import java.util.Collections;
22+
import java.util.List;
23+
import java.util.stream.Collectors;
24+
2025
import org.gradle.api.Project;
2126

2227
import com.diffplug.spotless.cpp.CppDefaults;
@@ -79,11 +84,22 @@ protected void setupTask(SpotlessTask task) {
7984
* defined by the CDT plugin.
8085
*/
8186
noDefaultTarget();
82-
target(CppDefaults.FILE_FILTER.toArray());
87+
target(FILE_FILTER.toArray());
8388
}
8489
super.setupTask(task);
8590
}
8691

92+
/**
93+
* Filter based on Eclipse-CDT <code>org.eclipse.core.contenttype.contentTypes</code>
94+
* extension <code>cSource</code>, <code>cHeader</code>, <code>cxxSource</code> and <code>cxxHeader</code>.
95+
*/
96+
@Deprecated
97+
private static final List<String> FILE_FILTER = Collections.unmodifiableList(
98+
Arrays.asList("c", "h", "C", "cpp", "cxx", "cc", "c++", "h", "hpp", "hh", "hxx", "inc")
99+
.stream().map(s -> {
100+
return "**/*." + s;
101+
}).collect(Collectors.toList()));
102+
87103
@Override
88104
public LicenseHeaderConfig licenseHeader(String licenseHeader) {
89105
return licenseHeader(licenseHeader, CppDefaults.DELIMITER_EXPR);

0 commit comments

Comments
 (0)