Skip to content

Commit

Permalink
Move CppDefaults.FILE_FILTER to its only user: gradle CppExtension …
Browse files Browse the repository at this point in the history
…(continuation of #630 and #634). Preserve its eclipse-specific info in the EclipseCdtFormatterStep comments.
  • Loading branch information
nedtwigg committed Jul 2, 2020
1 parent 1a19b3f commit a8380dd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 DiffPlug
* Copyright 2016-2020 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -23,7 +23,13 @@
import com.diffplug.spotless.extra.EclipseBasedStepBuilder;
import com.diffplug.spotless.extra.EclipseBasedStepBuilder.State;

/** Formatter step which calls out to the Eclipse CDT formatter. */
/**
* Formatter step which calls out to the Eclipse CDT formatter.
*
* Eclipse-CDT <code>org.eclipse.core.contenttype.contentTypes</code>
* extension <code>cSource</code>, <code>cHeader</code>, <code>cxxSource</code> and <code>cxxHeader</code>.
* can handle: "c", "h", "C", "cpp", "cxx", "cc", "c++", "h", "hpp", "hh", "hxx", "inc"
*/
public final class EclipseCdtFormatterStep {
// prevent direct instantiation
private EclipseCdtFormatterStep() {}
Expand Down
14 changes: 0 additions & 14 deletions lib/src/main/java/com/diffplug/spotless/cpp/CppDefaults.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,13 @@
package com.diffplug.spotless.cpp;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/** Common utilities for C/C++ */
public class CppDefaults {
//Prevent instantiation
private CppDefaults() {};

/** Filtering based on Eclipse-CDT <code>org.eclipse.core.contenttype.contentTypes</code> */
/**
* Filter based on Eclipse-CDT <code>org.eclipse.core.contenttype.contentTypes</code>
* extension <code>cSource</code>, <code>cHeader</code>, <code>cxxSource</code> and <code>cxxHeader</code>.
*/
@Deprecated
public static final List<String> FILE_FILTER = Collections.unmodifiableList(
Arrays.asList("c", "h", "C", "cpp", "cxx", "cc", "c++", "h", "hpp", "hh", "hxx", "inc")
.stream().map(s -> {
return "**/*." + s;
}).collect(Collectors.toList()));

/**
* Default delimiter expression shall cover most valid and common starts of C/C++ declarations and definitions.
* Furthermore it shall not conflict with terms commonly used within license headers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@

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

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

import org.gradle.api.Project;

import com.diffplug.spotless.cpp.CppDefaults;
Expand Down Expand Up @@ -79,11 +84,22 @@ protected void setupTask(SpotlessTask task) {
* defined by the CDT plugin.
*/
noDefaultTarget();
target(CppDefaults.FILE_FILTER.toArray());
target(FILE_FILTER.toArray());
}
super.setupTask(task);
}

/**
* Filter based on Eclipse-CDT <code>org.eclipse.core.contenttype.contentTypes</code>
* extension <code>cSource</code>, <code>cHeader</code>, <code>cxxSource</code> and <code>cxxHeader</code>.
*/
@Deprecated
private static final List<String> FILE_FILTER = Collections.unmodifiableList(
Arrays.asList("c", "h", "C", "cpp", "cxx", "cc", "c++", "h", "hpp", "hh", "hxx", "inc")
.stream().map(s -> {
return "**/*." + s;
}).collect(Collectors.toList()));

@Override
public LicenseHeaderConfig licenseHeader(String licenseHeader) {
return licenseHeader(licenseHeader, CppDefaults.DELIMITER_EXPR);
Expand Down

0 comments on commit a8380dd

Please sign in to comment.