Skip to content

Commit 4b088d2

Browse files
cpovirkgoogle-java-format Team
authored andcommitted
Replace calls to Runnables.doNothing() with a do-nothing lambda, () -> {}.
`Runnables.doNothing()` exists only because Java lambdas didn't exist in 2013. `() -> {}` is shorter and more standard. PiperOrigin-RevId: 972576296
1 parent b291d95 commit 4b088d2

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

idea_plugin/src/main/java/com/google/googlejavaformat/intellij/GoogleJavaFormatImportOptimizer.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package com.google.googlejavaformat.intellij;
1818

19-
import com.google.common.util.concurrent.Runnables;
2019
import com.google.googlejavaformat.java.FormatterException;
2120
import com.google.googlejavaformat.java.ImportOrderer;
2221
import com.google.googlejavaformat.java.JavaFormatterOptions;
@@ -43,14 +42,14 @@ public boolean supports(@NotNull PsiFile file) {
4342
Project project = file.getProject();
4443

4544
if (!JreConfigurationChecker.checkJreConfiguration(file.getProject())) {
46-
return Runnables.doNothing();
45+
return () -> {};
4746
}
4847

4948
PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project);
5049
Document document = documentManager.getDocument(file);
5150

5251
if (document == null) {
53-
return Runnables.doNothing();
52+
return () -> {};
5453
}
5554

5655
JavaFormatterOptions.Style style = GoogleJavaFormatSettings.getInstance(project).getStyle();
@@ -61,14 +60,14 @@ public boolean supports(@NotNull PsiFile file) {
6160
text = ImportOrderer.reorderImports(RemoveUnusedImports.removeUnusedImports(origText), style);
6261
} catch (FormatterException e) {
6362
Notifications.displayParsingErrorNotification(project, file.getName());
64-
return Runnables.doNothing();
63+
return () -> {};
6564
}
6665

6766
// pointless to change document text if it hasn't changed, plus this can interfere with
6867
// e.g. GoogleJavaFormattingService's output, i.e. it can overwrite the results from the main
6968
// formatter.
7069
if (text.equals(origText)) {
71-
return Runnables.doNothing();
70+
return () -> {};
7271
}
7372

7473
return () -> {

0 commit comments

Comments
 (0)