Skip to content

Commit

Permalink
Add now required import
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek committed Dec 7, 2024
1 parent 51579f4 commit 0ad2c51
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public J.Try visitTry(J.Try tryStatement, ExecutionContext ctx) {
}
return try_.withCatches(ListUtils.map(try_.getCatches(), catch_ -> {
if (TypeUtils.isOfClassType(catch_.getParameter().getType(), ILLEGAL_ARGUMENT_EXCEPTION)) {
maybeAddImport(ALREADY_CONNECTED_EXCEPTION);
return (J.Try.Catch) new ChangeType(ILLEGAL_ARGUMENT_EXCEPTION, ALREADY_CONNECTED_EXCEPTION, true)
.getVisitor().visit(catch_, ctx);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ void catchException() {
import java.net.SocketAddress;
import java.nio.channels.DatagramChannel;
public class Test {
public void sendDataCatch() {
class Test {
void sendDataCatch() {
try {
DatagramChannel channel = DatagramChannel.open();
channel.send(ByteBuffer.allocate(1024), new java.net.InetSocketAddress("localhost", 8080));
Expand All @@ -53,11 +53,12 @@ public void sendDataCatch() {
""",
"""
import java.nio.ByteBuffer;
import java.nio.channels.AlreadyConnectedException;
import java.net.SocketAddress;
import java.nio.channels.DatagramChannel;
public class Test {
public void sendDataCatch() {
class Test {
void sendDataCatch() {
try {
DatagramChannel channel = DatagramChannel.open();
channel.send(ByteBuffer.allocate(1024), new java.net.InetSocketAddress("localhost", 8080));
Expand All @@ -81,8 +82,8 @@ void rethrowException() {
import java.net.SocketAddress;
import java.nio.channels.DatagramChannel;
public class Test {
public void sendDataRethrow() {
class Test {
void sendDataRethrow() {
try {
DatagramChannel channel = DatagramChannel.open();
channel.send(ByteBuffer.allocate(1024), new java.net.InetSocketAddress("localhost", 8080));
Expand All @@ -94,11 +95,12 @@ public void sendDataRethrow() {
""",
"""
import java.nio.ByteBuffer;
import java.nio.channels.AlreadyConnectedException;
import java.net.SocketAddress;
import java.nio.channels.DatagramChannel;
public class Test {
public void sendDataRethrow() {
class Test {
void sendDataRethrow() {
try {
DatagramChannel channel = DatagramChannel.open();
channel.send(ByteBuffer.allocate(1024), new java.net.InetSocketAddress("localhost", 8080));
Expand All @@ -118,12 +120,13 @@ void retainOtherCaughtExceptions() {
//language=java
java(
"""
import java.io.IOException;import java.nio.ByteBuffer;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.net.SocketAddress;
import java.nio.channels.DatagramChannel;
public class Test {
public void sendData() {
class Test {
void sendData() {
try {
DatagramChannel channel = DatagramChannel.open();
channel.send(ByteBuffer.allocate(1024), new java.net.InetSocketAddress("localhost", 8080));
Expand Down

0 comments on commit 0ad2c51

Please sign in to comment.