Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
dependencies {
classpath 'com.palantir.jakartapackagealignment:jakarta-package-alignment:0.6.0'
classpath 'com.gradle.publish:plugin-publish-plugin:1.3.1'
classpath 'com.palantir.baseline:gradle-baseline-java:6.43.0'
classpath 'com.palantir.baseline:gradle-baseline-java:6.44.0'
classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.36.0'
classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.19.0'
classpath 'com.palantir.gradle.failure-reports:gradle-failure-reports:1.14.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.io.File;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
Expand Down Expand Up @@ -46,7 +47,6 @@ public abstract class ExecutableTransform implements TransformAction<TransformPa
@InputArtifact
public abstract Provider<FileSystemLocation> getInputArtifact();

@SuppressWarnings("for-rollout:PreferUncheckedIoException")
@Override
public void transform(TransformOutputs outputs) {
File inputFile = getInputArtifact().get().getAsFile();
Expand All @@ -55,11 +55,11 @@ public void transform(TransformOutputs outputs) {
Files.copy(inputFile.toPath(), outputFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
makeFileExecutable(outputFile.toPath());
} catch (IOException e) {
throw new RuntimeException(String.format("Failed to create executable file %s", outputFile.toPath()), e);
throw new UncheckedIOException(
String.format("Failed to create executable file %s", outputFile.toPath()), e);
}
}

@SuppressWarnings("for-rollout:PreferUncheckedIoException")
private static void makeFileExecutable(Path pathToExe) {
try {
Set<PosixFilePermission> existingPermissions = Files.getPosixFilePermissions(pathToExe);
Expand All @@ -73,7 +73,7 @@ private static void makeFileExecutable(Path pathToExe) {
PosixFilePermission.OTHERS_EXECUTE))
.collect(Collectors.toSet()));
} catch (IOException e) {
throw new RuntimeException("Failed to set execute permissions on native-image", e);
throw new UncheckedIOException("Failed to set execute permissions on native-image", e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.google.common.base.Suppliers;
import com.google.common.collect.Iterables;
import com.palantir.javaformat.java.FormatterService;
import java.io.UncheckedIOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
Expand All @@ -41,13 +42,12 @@ public FormatterService serviceLoad() {

@SuppressWarnings("for-rollout:NullAway")
private FormatterService serviceLoadInternal() {
@SuppressWarnings("for-rollout:PreferUncheckedIoException")
URL[] jarUris = configuration.getFiles().stream()
.map(file -> {
try {
return file.toURI().toURL();
} catch (MalformedURLException e) {
throw new RuntimeException("Unable to convert URI to URL: " + file, e);
throw new UncheckedIOException("Unable to convert URI to URL: " + file, e);
}
})
.toArray(URL[]::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.io.UncheckedIOException;
import java.util.function.Supplier;
import org.gradle.api.artifacts.Configuration;

Expand Down Expand Up @@ -79,7 +80,7 @@ static final class State implements Serializable {
this.memoizedFormatter = memoizedFormatter;
}

@SuppressWarnings({"NullableProblems", "for-rollout:PreferUncheckedIoException"})
@SuppressWarnings("NullableProblems")
FormatterFunc createFormat() {
return input -> {
try {
Expand All @@ -92,7 +93,7 @@ FormatterFunc createFormat() {

return memoizedFormatter.get().formatSourceReflowStringsAndFixImports(input);
} catch (IOException e) {
throw new RuntimeException(e);
throw new UncheckedIOException(e);
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.palantir.javaformat.bootstrap.NativeImageFormatterService;
import com.palantir.javaformat.java.FormatterService;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
Expand Down Expand Up @@ -207,12 +208,11 @@ private static URL[] toUrlsUnchecked(List<Path> paths) {
.toArray(URL[]::new);
}

@SuppressWarnings("for-rollout:PreferUncheckedIoException")
private static List<Path> listDirAsUrlsUnchecked(Path dir) {
try (Stream<Path> list = Files.list(dir)) {
return list.collect(Collectors.toList());
} catch (IOException e) {
throw new RuntimeException("Couldn't list dir: " + dir, e);
throw new UncheckedIOException("Couldn't list dir: " + dir, e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.palantir.javaformat.java.JavaFormatterOptions;
import com.palantir.sls.versions.OrderableSlsVersion;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.URI;
import java.util.List;
import java.util.Optional;
Expand Down Expand Up @@ -113,7 +114,6 @@ Optional<String> getImplementationVersion() {
return Optional.ofNullable(FormatterProvider.getPluginDescriptor().getVersion());
}

@SuppressWarnings("for-rollout:PreferUncheckedIoException")
Optional<String> computeFormatterVersion() {
return getImplementationClassPath().map(classpath -> classpath.stream()
.flatMap(uri -> {
Expand All @@ -127,7 +127,7 @@ Optional<String> computeFormatterVersion() {
}
return Stream.empty();
} catch (IOException e) {
throw new RuntimeException(e);
throw new UncheckedIOException(e);
}
})
.findFirst()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import com.palantir.javaformat.intellij.PalantirJavaFormatSettings.State;
import java.io.File;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -103,15 +104,14 @@ protected Project getProject() {
@NotNull
protected LightProjectDescriptor getProjectDescriptor() {
return new DefaultLightProjectDescriptor() {
@SuppressWarnings("for-rollout:PreferUncheckedIoException")
@Override
public Sdk getSdk() {
try {
return JavaSdk.getInstance()
.createJdk(
"java 1.11", new File(System.getProperty("java.home")).getCanonicalPath(), false);
} catch (IOException e) {
throw new RuntimeException(e);
throw new UncheckedIOException(e);
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static org.assertj.core.api.Assertions.assertThat;

import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -47,7 +48,6 @@ public static class BenchmarkState {

final List<String> filesToFormat = getFilesToFormat();

@SuppressWarnings("for-rollout:PreferUncheckedIoException")
private static List<String> getFilesToFormat() {
Path srcJavaFormatFiles = Paths.get(".")
.toAbsolutePath()
Expand All @@ -57,7 +57,7 @@ private static List<String> getFilesToFormat() {
.map(path -> path.toAbsolutePath().toString())) {
return paths.collect(Collectors.toList());
} catch (IOException e) {
throw new RuntimeException("Couldn't list src files: " + srcJavaFormatFiles, e);
throw new UncheckedIOException("Couldn't list src files: " + srcJavaFormatFiles, e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.palantir.javaformat.java.FormatterService;
import com.palantir.javaformat.java.Replacement;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Path;
import java.util.Collection;
import java.util.List;
Expand All @@ -50,33 +51,30 @@ public BootstrappingFormatterService(Path jdkPath, Integer jdkMajorVersion, List
this.implementationClassPath = implementationClassPath;
}

@SuppressWarnings("for-rollout:PreferUncheckedIoException")
@Override
public ImmutableList<Replacement> getFormatReplacements(String input, Collection<Range<Integer>> ranges) {
try {
return getFormatReplacementsInternal(input, ranges);
} catch (IOException e) {
throw new RuntimeException("Error running formatter command", e);
throw new UncheckedIOException("Error running formatter command", e);
}
}

@SuppressWarnings("for-rollout:PreferUncheckedIoException")
@Override
public String formatSourceReflowStringsAndFixImports(String input) {
try {
return runFormatterCommand(input);
} catch (IOException e) {
throw new RuntimeException("Error running formatter command", e);
throw new UncheckedIOException("Error running formatter command", e);
}
}

@SuppressWarnings("for-rollout:PreferUncheckedIoException")
@Override
public String fixImports(String input) throws FormatterException {
try {
return runFormatterCommand(input);
} catch (IOException e) {
throw new RuntimeException("Error running formatter command", e);
throw new UncheckedIOException("Error running formatter command", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.palantir.javaformat.java.FormatterService;
import com.palantir.javaformat.java.Replacement;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Path;
import java.util.Collection;
import java.util.List;
Expand All @@ -42,7 +43,6 @@ public NativeImageFormatterService(Path nativeImagePath) {
this.nativeImagePath = nativeImagePath;
}

@SuppressWarnings("for-rollout:PreferUncheckedIoException")
@Override
public ImmutableList<Replacement> getFormatReplacements(String input, Collection<Range<Integer>> ranges) {
try {
Expand All @@ -60,27 +60,25 @@ public ImmutableList<Replacement> getFormatReplacements(String input, Collection
}
return MAPPER.readValue(output.get(), new TypeReference<>() {});
} catch (IOException e) {
throw new RuntimeException("Error running the native image command", e);
throw new UncheckedIOException("Error running the native image command", e);
}
}

@SuppressWarnings("for-rollout:PreferUncheckedIoException")
@Override
public String formatSourceReflowStringsAndFixImports(String input) {
try {
return runFormatterCommand(input);
} catch (IOException e) {
throw new RuntimeException("Error running the native image command", e);
throw new UncheckedIOException("Error running the native image command", e);
}
}

@SuppressWarnings("for-rollout:PreferUncheckedIoException")
@Override
public String fixImports(String input) {
try {
return runFormatterCommand(input);
} catch (IOException e) {
throw new RuntimeException("Error running the native image command", e);
throw new UncheckedIOException("Error running the native image command", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.palantir.javaformat.doc.Doc;
import com.palantir.javaformat.doc.Level;
import java.io.IOException;
import java.io.UncheckedIOException;
import org.derive4j.ArgOption;
import org.derive4j.Data;

Expand Down Expand Up @@ -73,7 +74,6 @@ public interface Cases<R> {
*/
static class Json extends JsonSerializer<BreakBehaviour> {

@SuppressWarnings("for-rollout:PreferUncheckedIoException")
@Override
public void serialize(BreakBehaviour value, JsonGenerator gen, SerializerProvider serializers)
throws IOException {
Expand All @@ -83,7 +83,7 @@ public void serialize(BreakBehaviour value, JsonGenerator gen, SerializerProvide
try {
gen.writeObjectField("type", "breakThisLevel");
} catch (IOException e) {
throw new RuntimeException(e);
throw new UncheckedIOException(e);
}
return null;
})
Expand All @@ -92,15 +92,15 @@ public void serialize(BreakBehaviour value, JsonGenerator gen, SerializerProvide
gen.writeObjectField("type", "preferBreakingLastInnerLevel");
gen.writeObjectField("keepIndentWhenInlined", keepIndentWhenInlined);
} catch (IOException e) {
throw new RuntimeException(e);
throw new UncheckedIOException(e);
}
return null;
})
.inlineSuffix(() -> {
try {
gen.writeObjectField("type", "inlineSuffix");
} catch (IOException e) {
throw new RuntimeException(e);
throw new UncheckedIOException(e);
}
return null;
})
Expand All @@ -109,7 +109,7 @@ public void serialize(BreakBehaviour value, JsonGenerator gen, SerializerProvide
gen.writeObjectField("type", "breakOnlyIfInnerLevelsThenFitOnOneLine");
gen.writeObjectField("keepIndentWhenInlined", keepIndentWhenInlined);
} catch (IOException e) {
throw new RuntimeException(e);
throw new UncheckedIOException(e);
}
return null;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.palantir.javaformat.doc.State;
import com.palantir.javaformat.doc.Token;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
Expand All @@ -51,7 +52,6 @@ static Path getOutputFile() {
return publicDir.resolve("output.js");
}

@SuppressWarnings("for-rollout:PreferUncheckedIoException")
static void render(
JavaInput javaInput,
OpsOutput opsOutput,
Expand All @@ -72,7 +72,7 @@ static void render(
try {
Files.write(getOutputFile(), javascript.getBytes(StandardCharsets.UTF_8));
} catch (IOException e) {
throw new RuntimeException(e);
throw new UncheckedIOException(e);
}
}

Expand All @@ -85,7 +85,6 @@ private static String outputAsString(JavaOutput javaOutput) {
return output.toString();
}

@SuppressWarnings("for-rollout:PreferUncheckedIoException")
private static String opsJson(OpsOutput opsOutput) {
ArrayNode arrayNode = OBJECT_MAPPER.createArrayNode();

Expand Down Expand Up @@ -143,16 +142,15 @@ private static String opsJson(OpsOutput opsOutput) {
try {
return OBJECT_MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(arrayNode);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
throw new UncheckedIOException(e);
}
}

@SuppressWarnings("for-rollout:PreferUncheckedIoException")
private static String jsonEscapedString(String javaInput) {
try {
return OBJECT_MAPPER.writeValueAsString(javaInput);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
throw new UncheckedIOException(e);
}
}

Expand Down
Loading