diff --git a/src/main/java/org/openrewrite/NoopProgressBar.java b/src/main/java/org/openrewrite/NoopProgressBar.java deleted file mode 100644 index ba861b2..0000000 --- a/src/main/java/org/openrewrite/NoopProgressBar.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2021 the original author or authors. - *
- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *
- * https://www.apache.org/licenses/LICENSE-2.0 - *
- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openrewrite; - -import org.openrewrite.internal.lang.Nullable; - -/** - * @deprecated This class has been moved to rewrite-polyglot. - */ -@Deprecated -public class NoopProgressBar implements ProgressBar { - @Override - public void intermediateResult(@Nullable String message) { - } - - @Override - public void finish(String message) { - } - - @Override - public void close() { - } - - @Override - public void step() { - } - - @Override - public ProgressBar setExtraMessage(String extraMessage) { - return this; - } - - @Override - public ProgressBar setMax(int max) { - return this; - } -} diff --git a/src/main/java/org/openrewrite/OmniParser.java b/src/main/java/org/openrewrite/OmniParser.java deleted file mode 100644 index 5505314..0000000 --- a/src/main/java/org/openrewrite/OmniParser.java +++ /dev/null @@ -1,319 +0,0 @@ -/* - * Copyright 2021 the original author or authors. - *
- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *
- * https://www.apache.org/licenses/LICENSE-2.0 - *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.openrewrite;
-
-import lombok.AccessLevel;
-import lombok.RequiredArgsConstructor;
-import org.openrewrite.hcl.HclParser;
-import org.openrewrite.internal.lang.Nullable;
-import org.openrewrite.json.JsonParser;
-import org.openrewrite.properties.PropertiesParser;
-import org.openrewrite.protobuf.ProtoParser;
-import org.openrewrite.quark.QuarkParser;
-import org.openrewrite.shaded.jgit.ignore.IgnoreNode;
-import org.openrewrite.text.PlainTextParser;
-import org.openrewrite.xml.XmlParser;
-import org.openrewrite.yaml.YamlParser;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UncheckedIOException;
-import java.nio.file.*;
-import java.nio.file.attribute.BasicFileAttributes;
-import java.util.*;
-import java.util.function.Consumer;
-import java.util.stream.Stream;
-import java.util.stream.StreamSupport;
-
-import static java.util.Collections.emptyList;
-
-/**
- * @deprecated This class has been moved to rewrite-polyglot.
- */
-@Deprecated
-@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
-public class OmniParser implements Parser {
- private static final Collection
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.openrewrite;
-
-import org.openrewrite.internal.lang.Nullable;
-
-/**
- * @deprecated This class has been moved to rewrite-polyglot.
- */
-@Deprecated
-public interface ProgressBar extends AutoCloseable {
-
- void intermediateResult(@Nullable String message);
-
- void finish(String message);
-
- @Override
- void close();
-
- void step();
-
- @SuppressWarnings("UnusedReturnValue")
- ProgressBar setExtraMessage(String extraMessage);
-
- ProgressBar setMax(int max);
-}
diff --git a/src/main/java/org/openrewrite/RemoteProgressBarReceiver.java b/src/main/java/org/openrewrite/RemoteProgressBarReceiver.java
deleted file mode 100644
index 3fd14d0..0000000
--- a/src/main/java/org/openrewrite/RemoteProgressBarReceiver.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright 2021 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.openrewrite;
-
-import org.openrewrite.RemoteProgressBarSender.Request.Type;
-import org.openrewrite.internal.lang.Nullable;
-
-import java.io.IOException;
-import java.io.UncheckedIOException;
-import java.net.DatagramPacket;
-import java.net.DatagramSocket;
-import java.net.SocketException;
-import java.net.SocketTimeoutException;
-import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import static java.util.Objects.requireNonNull;
-import static org.openrewrite.RemoteProgressBarSender.MAX_MESSAGE_SIZE;
-
-/**
- * @deprecated This class has been moved to rewrite-polyglot.
- */
-@Deprecated
-public class RemoteProgressBarReceiver implements ProgressBar {
- private static final ExecutorService PROGRESS_RECEIVER_POOL = Executors.newCachedThreadPool();
-
- private final ProgressBar delegate;
- private final DatagramSocket socket;
-
- public RemoteProgressBarReceiver(ProgressBar delegate) {
- this.delegate = delegate;
- try {
- this.socket = new DatagramSocket();
- PROGRESS_RECEIVER_POOL.submit(this::receive);
- } catch (SocketException e) {
- throw new UncheckedIOException(e);
- }
- }
-
- public int getPort() {
- return socket.getLocalPort();
- }
-
- public void receive() {
- try {
- for (; ; ) {
- byte[] buf = new byte[MAX_MESSAGE_SIZE]; // no message should be longer than a terminal line length
- DatagramPacket packet = new DatagramPacket(buf, buf.length);
- try {
- socket.receive(packet);
- } catch (SocketTimeoutException ignored) {
- break;
- }
-
- Type type = null;
- for (Type t : Type.values()) {
- if (t.ordinal() == buf[0] - '0') {
- type = t;
- break;
- }
- }
-
- if (type == null) {
- return;
- }
-
- String message = null;
- if (packet.getLength() > 1) {
- message = new String(Arrays.copyOfRange(buf, 1, packet.getLength()),
- StandardCharsets.UTF_8);
- }
-
- switch (type) {
- case IntermediateResult:
- delegate.intermediateResult(message);
- break;
- case Step:
- delegate.step();
- break;
- case SetExtraMessage:
- delegate.setExtraMessage(requireNonNull(message));
- break;
- case SetMax:
- delegate.setMax(Integer.parseInt(requireNonNull(message)));
- break;
- }
- }
- } catch (IOException e) {
- throw new UncheckedIOException(e);
- }
- }
-
- @Override
- public void intermediateResult(@Nullable String message) {
- delegate.intermediateResult(message);
- }
-
- @Override
- public void finish(String message) {
- delegate.finish(message);
- }
-
- @Override
- public void step() {
- delegate.step();
- }
-
- @Override
- public ProgressBar setExtraMessage(String extraMessage) {
- return delegate.setExtraMessage(extraMessage);
- }
-
- @Override
- public ProgressBar setMax(int max) {
- return delegate.setMax(max);
- }
-
- @Override
- public void close() {
- socket.close();
- }
-}
diff --git a/src/main/java/org/openrewrite/RemoteProgressBarSender.java b/src/main/java/org/openrewrite/RemoteProgressBarSender.java
deleted file mode 100644
index ff12e56..0000000
--- a/src/main/java/org/openrewrite/RemoteProgressBarSender.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright 2021 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.openrewrite;
-
-import lombok.Value;
-import org.openrewrite.internal.StringUtils;
-import org.openrewrite.internal.lang.Nullable;
-
-import java.io.IOException;
-import java.io.UncheckedIOException;
-import java.net.*;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-
-/**
- * @deprecated This class has been moved to rewrite-polyglot.
- */
-@Deprecated
-public class RemoteProgressBarSender implements ProgressBar {
- final static int MAX_MESSAGE_SIZE = 256;
-
- private final DatagramSocket socket;
- private final InetAddress address;
- private final int port;
-
- public RemoteProgressBarSender(int port) {
- this(null, port);
- }
-
- public RemoteProgressBarSender(@Nullable InetAddress address, int port) {
- try {
- String localhost = Files.exists(Paths.get("/.dockerenv")) ? "host.docker.internal" : "localhost";
- this.address = address == null ? InetAddress.getByName(localhost) : address;
- this.port = port;
- this.socket = new DatagramSocket();
- } catch (UnknownHostException | SocketException e) {
- throw new UncheckedIOException(e);
- }
- }
-
- @Override
- public void intermediateResult(@Nullable String message) {
- send(Request.Type.IntermediateResult, message);
- }
-
- @Override
- public void finish(String message) {
- throw new UnsupportedOperationException("The finish message must be determined by the receiver");
- }
-
- @Override
- public void close() {
- socket.close();
- }
-
- @Override
- public void step() {
- send(Request.Type.Step, null);
- }
-
- @Override
- public ProgressBar setExtraMessage(String extraMessage) {
- send(Request.Type.SetExtraMessage, extraMessage);
- return this;
- }
-
- @Override
- public ProgressBar setMax(int max) {
- send(Request.Type.SetMax, Integer.toString(max));
- return this;
- }
-
- private void send(Request.Type type, @Nullable String message) {
- try {
- if (message != null && message.length() + 1 > MAX_MESSAGE_SIZE) {
- throw new IllegalArgumentException("Message size exceeded maximum length: " + message);
- }
- byte[] buf = (type.ordinal() + (message == null ? "" : message)).getBytes();
- DatagramPacket packet = new DatagramPacket(buf, buf.length, address, port);
- socket.send(packet);
- } catch (SocketException ignored) {
- // the remote receiver may not be listening any longer, so ignore
- } catch (IOException e) {
- throw new UncheckedIOException(e);
- }
- }
-
- @Value
- static class Request {
- enum Type {
- IntermediateResult,
- Step,
- SetExtraMessage,
- SetMax
- }
-
- Type type;
-
- @Nullable
- String body;
- }
-}
diff --git a/src/test/java/org/openrewrite/RemoteProgressBarTest.java b/src/test/java/org/openrewrite/RemoteProgressBarTest.java
deleted file mode 100644
index 24dee7a..0000000
--- a/src/test/java/org/openrewrite/RemoteProgressBarTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2021 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.openrewrite;
-
-import org.junit.jupiter.api.Test;
-import org.openrewrite.internal.lang.Nullable;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-/**
- * @deprecated This class has been moved to rewrite-polyglot.
- */
-@Deprecated
-public class RemoteProgressBarTest {
-
- @Test
- void remote() throws InterruptedException {
- CountDownLatch latch = new CountDownLatch(4);
- try (
- ProgressBar progressBar = new ProgressBar() {
- @Override
- public void intermediateResult(@Nullable String message) {
- assertThat(message).isEqualTo("intermediate");
- latch.countDown();
- }
-
- @Override
- public void finish(String message) {
- }
-
- @Override
- public void close() {
- }
-
- @Override
- public void step() {
- latch.countDown();
- }
-
- @Override
- public ProgressBar setExtraMessage(String extraMessage) {
- assertThat(extraMessage).isEqualTo("extra");
- latch.countDown();
- return this;
- }
-
- @Override
- public ProgressBar setMax(int max) {
- assertThat(max).isEqualTo(100);
- latch.countDown();
- return this;
- }
- };
-
- RemoteProgressBarReceiver receiver = new RemoteProgressBarReceiver(progressBar)) {
- try (ProgressBar sender = new RemoteProgressBarSender(receiver.getPort())) {
- sender.setMax(100);
- sender.step();
- sender.setExtraMessage("extra");
- sender.intermediateResult("intermediate");
- }
-
- assertThat(latch.await(5, TimeUnit.SECONDS)).isTrue();
- }
- }
-}