Skip to content

Commit 920c320

Browse files
committed
spotlessApply
1 parent 53f3fcf commit 920c320

File tree

216 files changed

+984
-1014
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

216 files changed

+984
-1014
lines changed

_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/BundleController.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public Bundle getBundle(String location) {
168168
@Override
169169
public ServiceReference<?>[] getAllServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
170170
//Filters are based on class names
171-
String interfaceClassName = (null == clazz) ? filter : clazz;
171+
var interfaceClassName = (null == clazz) ? filter : clazz;
172172
return services.getReferences(interfaceClassName);
173173
}
174174

_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/ResourceAccessor.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class ResourceAccessor {
6363
/** Resources are located in the JAR of the given class
6464
* @throws BundleException */
6565
ResourceAccessor(Class<?> clazz) throws BundleException {
66-
String bundleObjPath = clazz.getName();
66+
var bundleObjPath = clazz.getName();
6767
fatJarResourcePath = bundleObjPath.substring(0, bundleObjPath.lastIndexOf('.'));
6868
try {
6969
bundleFile = getBundlFile(clazz);
@@ -74,7 +74,7 @@ class ResourceAccessor {
7474

7575
private static BundleFile getBundlFile(Class<?> clazz) throws BundleException {
7676
URI objUri = getBundleUri(clazz);
77-
File jarOrDirectory = new File(objUri.getPath());
77+
var jarOrDirectory = new File(objUri.getPath());
7878
if (!(jarOrDirectory.exists() && jarOrDirectory.canRead())) {
7979
throw new BundleException(String.format("Path '%s' for '%s' is not accessible exist on local file system.", objUri, clazz.getName()), BundleException.READ_ERROR);
8080
}
@@ -87,7 +87,7 @@ private static BundleFile getBundlFile(Class<?> clazz) throws BundleException {
8787

8888
private static URI getBundleUri(Class<?> clazz) throws BundleException {
8989
try {
90-
URL objUrl = clazz.getProtectionDomain().getCodeSource().getLocation();
90+
var objUrl = clazz.getProtectionDomain().getCodeSource().getLocation();
9191
return objUrl.toURI();
9292
} catch (NullPointerException e) {
9393
//No bunlde should be used for RT classes lookup. See also org.eclipse.core.runtime.PerformanceStats.
@@ -101,10 +101,10 @@ private static URI getBundleUri(Class<?> clazz) throws BundleException {
101101

102102
/** Get the manifest name from the resources. */
103103
String getManifestName() throws BundleException {
104-
URL manifestUrl = getEntry(JarFile.MANIFEST_NAME);
104+
var manifestUrl = getEntry(JarFile.MANIFEST_NAME);
105105
if (null != manifestUrl) {
106106
try {
107-
Manifest manifest = new Manifest(manifestUrl.openStream());
107+
var manifest = new Manifest(manifestUrl.openStream());
108108
String headerValue = manifest.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME);
109109
if (null == headerValue) {
110110
throw new BundleException(String.format("Symbolic values not found in '%s'.", manifestUrl), BundleException.MANIFEST_ERROR);

_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/ServiceCollection.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public void set(String key, String value) {
7676

7777
@Override
7878
public <S> void add(Class<S> interfaceClass, S service) throws ServiceException {
79-
String className = interfaceClass.getName();
79+
var className = interfaceClass.getName();
8080
if (null != className2Service.put(interfaceClass.getName(), new FrameworkServiceReference<S>(className, service))) {
8181
throw new ServiceException(
8282
String.format("Service '%s' is already registered.", interfaceClass.getName()), ServiceException.FACTORY_ERROR);

_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/runtime/PluginRegistrar.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class PluginRegistrar {
3939
private static final String PLUGIN_PROPERTIES = "plugin.properties";
4040

4141
public static BundleException register(Bundle bundle) {
42-
PluginRegistrar registrar = new PluginRegistrar(bundle);
42+
var registrar = new PluginRegistrar(bundle);
4343
try {
4444
registrar.register();
4545
} catch (BundleException e) {

_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/service/SingleSlf4JService.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ public long getTime() {
459459

460460
@Override
461461
public String toString() {
462-
StringWriter result = new StringWriter();
462+
var result = new StringWriter();
463463
result.write(message);
464464
if (execption.isPresent()) {
465465
result.write('\n');

_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/service/TemporaryLocation.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ private TemporaryLocation(Location parent, URL defaultValue) {
4444

4545
private static URL createTemporaryDirectory() {
4646
try {
47-
Path location = Files.createTempDirectory(TEMP_PREFIX);
47+
var location = Files.createTempDirectory(TEMP_PREFIX);
4848
return location.toUri().toURL();
4949
} catch (IOException e) {
5050
throw new IOError(e);
@@ -120,7 +120,7 @@ public Location createLocation(Location parent, URL defaultValue, boolean readon
120120
@Override
121121
public URL getDataArea(String path) throws IOException {
122122
try {
123-
Path locationPath = Paths.get(location.toURI());
123+
var locationPath = Paths.get(location.toURI());
124124
return locationPath.resolve(path).toUri().toURL();
125125
} catch (URISyntaxException e) {
126126
throw new IOException("Location not correctly formatted.", e);
@@ -130,7 +130,7 @@ public URL getDataArea(String path) throws IOException {
130130
@Override
131131
public void close() throws Exception {
132132
try {
133-
Path path = Path.of(location.toURI());
133+
var path = Path.of(location.toURI());
134134
Files.walk(path)
135135
.sorted(Comparator.reverseOrder())
136136
.map(Path::toFile)

_ext/eclipse-base/src/test/java/com/diffplug/spotless/extra/eclipse/base/SpotlessEclipseFrameworkTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ public void println(String x) {
251251
@Override
252252
public void println(Object x) {
253253
if (x instanceof Exception) {
254-
Exception e = (Exception) x;
254+
var e = (Exception) x;
255255
if (TEST_EXCEPTION_MESSAGE == e.getMessage()) {
256256
messages.add(TEST_EXCEPTION_MESSAGE);
257257
}

_ext/eclipse-base/src/test/java/com/diffplug/spotless/extra/eclipse/base/osgi/BundleSetTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void testAddGet() throws BundleException {
4949

5050
@Test
5151
void testSameSymbolicName() throws BundleException {
52-
final String symbolicName = "sym.a";
52+
final var symbolicName = "sym.a";
5353
final long id1 = 12345;
5454
final long id2 = 23456;
5555
Bundle testBundle1 = new TestBundle(id1, symbolicName);
@@ -63,8 +63,8 @@ void testSameSymbolicName() throws BundleException {
6363

6464
@Test
6565
void testSameID() throws BundleException {
66-
final String symbolicName1 = "sym.a";
67-
final String symbolicName2 = "sym.b";
66+
final var symbolicName1 = "sym.a";
67+
final var symbolicName2 = "sym.b";
6868
final long id = 12345;
6969
Bundle testBundle1 = new TestBundle(id, symbolicName1);
7070
Bundle testBundle2 = new TestBundle(id, symbolicName2);

_ext/eclipse-base/src/test/java/com/diffplug/spotless/extra/eclipse/base/osgi/ServiceCollectionTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ void initialize() {
3939

4040
@Test
4141
void testAddGet() {
42-
Service1 service1 = new Service1();
43-
Service2 service2 = new Service2();
42+
var service1 = new Service1();
43+
var service2 = new Service2();
4444
instance.add(Interf1.class, service1);
4545
instance.add(Interf2a.class, service2);
4646
instance.add(Interf2b.class, service2);
@@ -51,8 +51,8 @@ void testAddGet() {
5151

5252
@Test
5353
void testMultipleServicesPerInterface() {
54-
Service1 serviceX = new Service1();
55-
Service1 serviceY = new Service1();
54+
var serviceX = new Service1();
55+
var serviceY = new Service1();
5656
instance.add(Interf1.class, serviceX);
5757
ServiceException e = assertThrows(ServiceException.class, () -> instance.add(Interf1.class, serviceY));
5858
assertThat(e.getMessage()).as("ServiceException does not contain interface class name.").contains(Interf1.class.getName());

_ext/eclipse-cdt/src/test/java/com/diffplug/spotless/extra/eclipse/cdt/EclipseCdtFormatterStepImplTest.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -50,26 +50,26 @@ class EclipseCdtFormatterStepImplTest {
5050

5151
@Test
5252
void defaultFormat() throws Throwable {
53-
String output = format(CPP_UNFORMATTED, config -> {});
53+
var output = format(CPP_UNFORMATTED, config -> {});
5454
assertEquals(CPP_FORMATTED,
5555
output, "Unexpected formatting with default preferences.");
5656
}
5757

5858
@Test
5959
void invalidFormat() throws Throwable {
60-
String output = format(CPP_FORMATTED.replace("int main() {", "int main() "), config -> {});
60+
var output = format(CPP_FORMATTED.replace("int main() {", "int main() "), config -> {});
6161
assertTrue(output.contains("int main()" + LINE_DELIMITER), "Incomplete CPP not formatted on best effort basis.");
6262
}
6363

6464
@Test
6565
void invalidCharater() throws Throwable {
66-
String output = format(CPP_FORMATTED.replace("int main() {", "int main()" + ILLEGAL_CHAR + " {"), config -> {});
66+
var output = format(CPP_FORMATTED.replace("int main() {", "int main()" + ILLEGAL_CHAR + " {"), config -> {});
6767
assertTrue(output.contains("int main()" + LINE_DELIMITER), "Invalid charater not formatted on best effort basis.");
6868
}
6969

7070
@Test
7171
void invalidConfiguration() throws Throwable {
72-
String output = format(CPP_FORMATTED, config -> {
72+
var output = format(CPP_FORMATTED, config -> {
7373
config.setProperty(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, CCorePlugin.SPACE);
7474
config.setProperty(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "noInteger");
7575
});
@@ -79,19 +79,19 @@ void invalidConfiguration() throws Throwable {
7979

8080
@Test
8181
void htmlCommentFormat() throws Throwable {
82-
String output = format(DOXYGEN_HTML + CPP_FORMATTED, config -> {});
82+
var output = format(DOXYGEN_HTML + CPP_FORMATTED, config -> {});
8383
assertEquals(DOXYGEN_HTML + CPP_FORMATTED,
8484
output, "HTML comments not ignored by formatter.");
8585
}
8686

8787
@Test
8888
void regionWarning() throws Throwable {
89-
String output = format(FUNCT_PTR_UNFORMATTED, config -> {});
89+
var output = format(FUNCT_PTR_UNFORMATTED, config -> {});
9090
assertEquals(FUNCT_PTR_FORMATTED, output, "Code not formatted at all due to regional error.");
9191
}
9292

9393
private static String format(final String input, final Consumer<Properties> config) throws Exception {
94-
Properties properties = new Properties();
94+
var properties = new Properties();
9595
config.accept(properties);
9696
EclipseCdtFormatterStepImpl formatter = new EclipseCdtFormatterStepImpl(properties);
9797
return formatter.format(input);

_ext/eclipse-groovy/src/main/java/com/diffplug/spotless/extra/eclipse/groovy/GrEclipseFormatterStepImpl.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public void activatePlugins(SpotlessEclipsePluginConfig config) {
8080
/** Formatting Groovy string */
8181
public String format(String raw) throws Exception {
8282
IDocument doc = new Document(raw);
83-
GroovyErrorListener errorListener = new GroovyErrorListener();
83+
var errorListener = new GroovyErrorListener();
8484
TextSelection selectAll = new TextSelection(doc, 0, doc.getLength());
8585
GroovyFormatter codeFormatter = new DefaultGroovyFormatter(selectAll, doc, preferencesStore, false);
8686
TextEdit edit = codeFormatter.format();
@@ -127,7 +127,7 @@ public boolean errorsDetected() {
127127

128128
@Override
129129
public String toString() {
130-
StringBuilder string = new StringBuilder();
130+
var string = new StringBuilder();
131131
if (1 < errors.size()) {
132132
string.append("Multiple problems detected during step execution:");
133133
} else if (0 == errors.size()) {
@@ -161,9 +161,9 @@ public void log(TraceCategory arg0, String arg1) {
161161

162162
private static PreferenceStore createPreferences(final Properties properties) throws IOException {
163163
final PreferenceStore preferences = new PreferenceStore();
164-
ByteArrayOutputStream output = new ByteArrayOutputStream();
164+
var output = new ByteArrayOutputStream();
165165
properties.store(output, null);
166-
ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
166+
var input = new ByteArrayInputStream(output.toByteArray());
167167
preferences.load(input);
168168
return preferences;
169169
}

_ext/eclipse-groovy/src/test/java/com/diffplug/spotless/extra/eclipse/groovy/GrEclipseFormatterStepImplTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void scannerException() throws Throwable {
8080
*/
8181
@Test
8282
void boundedWildCards() throws Throwable {
83-
String output = format(BOUNDED_WILDCARDS_UNFORMATTED, config -> {});
83+
var output = format(BOUNDED_WILDCARDS_UNFORMATTED, config -> {});
8484
assertEquals(BOUNDED_WILDCARDS_FORMATTED,
8585
output, "Unexpected formatting after bounded wildcards.");
8686
}
@@ -96,7 +96,7 @@ void ignoreCompilerProblems() throws Throwable {
9696
}
9797

9898
private static String format(final String input, final Consumer<Properties> config) throws Exception {
99-
Properties properties = new Properties();
99+
var properties = new Properties();
100100
config.accept(properties);
101101
GrEclipseFormatterStepImpl formatter = new GrEclipseFormatterStepImpl(properties);
102102
return formatter.format(input);

_ext/eclipse-groovy/src/test/java/com/diffplug/spotless/extra/eclipse/groovy/TestData.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222

2323
public class TestData {
2424
public static TestData getTestDataOnFileSystem() {
25-
final String userDir = System.getProperty("user.dir", ".");
26-
Path dataPath = Paths.get(userDir, "src", "test", "resources");
25+
final var userDir = System.getProperty("user.dir", ".");
26+
var dataPath = Paths.get(userDir, "src", "test", "resources");
2727
if (Files.isDirectory(dataPath)) {
2828
return new TestData(dataPath);
2929
}
@@ -48,7 +48,7 @@ public String input(final String fileName) throws Exception {
4848
}
4949

5050
public String expected(final String fileName) {
51-
Path path = expectedPath.resolve(fileName);
51+
var path = expectedPath.resolve(fileName);
5252
return read(path);
5353
}
5454

@@ -57,7 +57,7 @@ private String read(final Path xmlPath) {
5757
throw new IllegalArgumentException(String.format("'%1$s' is not a regular file.", xmlPath));
5858
}
5959
try {
60-
String checkedOutFileContent = new String(java.nio.file.Files.readAllBytes(xmlPath), "UTF8");
60+
var checkedOutFileContent = new String(java.nio.file.Files.readAllBytes(xmlPath), "UTF8");
6161
return checkedOutFileContent.replace("\r", ""); //Align GIT end-of-line normalization
6262
} catch (IOException e) {
6363
throw new IllegalArgumentException(String.format("Failed to read '%1$s'.", xmlPath), e);

_ext/eclipse-jdt/src/test/java/com/diffplug/spotless/extra/eclipse/java/EclipseJdtFormatterStepImplTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void nominal() throws Throwable {
6060
@Test
6161
public void invalidSyntax() throws Throwable {
6262
try {
63-
String invalidSyntax = FORMATTED.replace("{", "");
63+
var invalidSyntax = FORMATTED.replace("{", "");
6464
assertEquals(invalidSyntax, format(invalidSyntax));
6565
} catch (IndexOutOfBoundsException e) {
6666
/*
@@ -72,15 +72,15 @@ public void invalidSyntax() throws Throwable {
7272

7373
@Test
7474
void invalidCharater() throws Throwable {
75-
String invalidInput = UNFORMATTED + ILLEGAL_CHAR;
75+
var invalidInput = UNFORMATTED + ILLEGAL_CHAR;
7676
assertEquals(invalidInput, format(invalidInput));
7777
}
7878

7979
@Test
8080
void invalidConfiguration() throws Throwable {
8181
config.setProperty(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
8282
config.setProperty(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "noInteger");
83-
String defaultTabReplacement = " ";
83+
var defaultTabReplacement = " ";
8484
assertEquals(FORMATTED.replace("\t", defaultTabReplacement), format(FORMATTED));
8585
}
8686

_ext/eclipse-wtp/src/main/java/com/diffplug/spotless/extra/eclipse/wtp/EclipseHtmlFormatterStepImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public void activatePlugins(SpotlessEclipsePluginConfig config) {
141141
* The HTML formatter only uses the DOCTYPE/SCHEMA for content model selection.
142142
* Hence no external URIs are required.
143143
*/
144-
boolean allowExternalURI = false;
144+
var allowExternalURI = false;
145145
EclipseXmlFormatterStepImpl.FrameworkConfig.activateXmlPlugins(config, allowExternalURI);
146146
config.add(new HTMLCorePlugin());
147147
}

_ext/eclipse-wtp/src/main/java/com/diffplug/spotless/extra/eclipse/wtp/html/StructuredDocumentProcessor.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public StructuredDocumentProcessor(IStructuredDocument document, String type,
6363

6464
/** Applies processor on document, using a given formatter */
6565
public void apply(T formatter) {
66-
for (int currentRegionId = 0; currentRegionId < numberOfRegions; currentRegionId++) {
66+
for (var currentRegionId = 0; currentRegionId < numberOfRegions; currentRegionId++) {
6767
applyOnRegion(currentRegionId, formatter);
6868
}
6969
}
@@ -132,7 +132,7 @@ public int getLastLine() {
132132
}
133133

134134
private static int computeIndent(IStructuredDocument document, ITypedRegion region, String htmlIndent) {
135-
int indent = 0;
135+
var indent = 0;
136136
try {
137137
int lineNumber = document.getLineOfOffset(region.getOffset());
138138
document.getNumberOfLines();
@@ -180,7 +180,7 @@ protected void fixTagIndent(MultiTextEdit modifications, int offset, String inde
180180
int lineStart = document.getLineOffset(lineNumber);
181181
int lineEnd = document.getLineOffset(lineNumber + 1);
182182
String lineContent = document.get(lineStart, lineEnd - lineStart);
183-
StringBuilder currentIndent = new StringBuilder();
183+
var currentIndent = new StringBuilder();
184184
lineContent.chars().filter(c -> {
185185
if (c == ' ' || c == '\t') {
186186
currentIndent.append(c);

_ext/eclipse-wtp/src/main/java/com/diffplug/spotless/extra/eclipse/wtp/sse/PluginPreferences.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ public static void configureCatalog(final Properties properties, final ICatalog
9696
throw new IllegalArgumentException("Internal error: Catalog implementation '" + defaultCatalogInterface.getClass().getCanonicalName() + "' unsupported.");
9797
}
9898
Catalog defaultCatalog = (Catalog) defaultCatalogInterface;
99-
String catalogProperty = properties.getProperty(USER_CATALOG, "");
99+
var catalogProperty = properties.getProperty(USER_CATALOG, "");
100100
if (!catalogProperty.isEmpty()) {
101-
final File catalogFile = new File(catalogProperty);
101+
final var catalogFile = new File(catalogProperty);
102102
try {
103103
InputStream inputStream = new FileInputStream(catalogFile);
104104
String orgBase = defaultCatalog.getBase();
@@ -118,7 +118,7 @@ public static void configureCatalog(final Properties properties, final ICatalog
118118
public static void assertNoChanges(Plugin plugin, Properties properties) {
119119
Objects.requireNonNull(properties, "Property values are missing.");
120120
final String preferenceId = plugin.getBundle().getSymbolicName();
121-
Properties originalValues = CONFIG.get(preferenceId);
121+
var originalValues = CONFIG.get(preferenceId);
122122
if (null == originalValues) {
123123
throw new IllegalArgumentException("No configuration found for " + preferenceId);
124124
}

_ext/eclipse-wtp/src/test/java/com/diffplug/spotless/extra/eclipse/wtp/EclipseCssFormatterStepImplTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void initialize() throws Exception {
4141
* All formatter configuration is stored in
4242
* org.eclipse.core.runtime/.settings/org.eclipse.wst.css.core.prefs.
4343
*/
44-
Properties properties = new Properties();
44+
var properties = new Properties();
4545
properties.put(INDENTATION_SIZE, "3");
4646
properties.put(INDENTATION_CHAR, SPACE); //Default is TAB
4747
properties.put(CLEANUP_CASE_SELECTOR, Integer.toString(UPPER)); //Done by cleanup

_ext/eclipse-wtp/src/test/java/com/diffplug/spotless/extra/eclipse/wtp/EclipseHtmlFormatterStepImplTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void initialize() throws Exception {
4040
* org.eclipse.core.runtime/.settings/org.eclipse.wst.xml.core.prefs.
4141
* So a simple test of one configuration item change is considered sufficient.
4242
*/
43-
Properties properties = new Properties();
43+
var properties = new Properties();
4444
properties.put(CLEANUP_TAG_NAME_CASE, Integer.toString(HTMLCorePreferenceNames.UPPER)); //HTML config
4545
properties.put(FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON, JavaScriptCore.INSERT); //JS config
4646
properties.put(QUOTE_ATTR_VALUES, "TRUE"); //CSS config
@@ -89,7 +89,7 @@ void formatCSS() throws Exception {
8989

9090
@Test
9191
void checkCleanupForNonUtf8() throws Exception {
92-
String osEncoding = System.getProperty("file.encoding");
92+
var osEncoding = System.getProperty("file.encoding");
9393
System.setProperty("file.encoding", "ISO-8859-1"); //Simulate a non UTF-8 OS
9494
String[] input = testData.input("utf-8.html");
9595
String output = formatter.format(input[0]);

0 commit comments

Comments
 (0)