mirror of
				https://github.com/SquidDev-CC/CC-Tweaked
				synced 2025-11-03 23:22:59 +00:00 
			
		
		
		
	Fix a couple of warnings
This commit is contained in:
		@@ -116,6 +116,7 @@ public final class MethodResult {
 | 
			
		||||
     * @return The method result which represents this yield.
 | 
			
		||||
     * @see #pullEvent(String, ILuaCallback)
 | 
			
		||||
     */
 | 
			
		||||
    @SuppressWarnings("NamedLikeContextualKeyword")
 | 
			
		||||
    public static MethodResult yield(@Nullable Object[] arguments, ILuaCallback callback) {
 | 
			
		||||
        Objects.requireNonNull(callback, "callback cannot be null");
 | 
			
		||||
        return new MethodResult(arguments, callback);
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,7 @@
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.core.apis.http.options;
 | 
			
		||||
 | 
			
		||||
import com.google.errorprone.annotations.Immutable;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Options for a given HTTP request or websocket, which control its resource constraints.
 | 
			
		||||
@@ -14,5 +15,6 @@ package dan200.computercraft.core.apis.http.options;
 | 
			
		||||
 * @param websocketMessage The maximum size of a websocket message (outgoing and incoming).
 | 
			
		||||
 * @param useProxy         Whether to use the configured proxy.
 | 
			
		||||
 */
 | 
			
		||||
@Immutable
 | 
			
		||||
public record Options(Action action, long maxUpload, long maxDownload, int websocketMessage, boolean useProxy) {
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,7 @@
 | 
			
		||||
 | 
			
		||||
package dan200.computercraft.core.apis.http.options;
 | 
			
		||||
 | 
			
		||||
import com.google.errorprone.annotations.Immutable;
 | 
			
		||||
import com.google.errorprone.annotations.concurrent.LazyInit;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nullable;
 | 
			
		||||
@@ -11,6 +12,7 @@ import java.util.Optional;
 | 
			
		||||
import java.util.OptionalInt;
 | 
			
		||||
import java.util.OptionalLong;
 | 
			
		||||
 | 
			
		||||
@Immutable
 | 
			
		||||
public final class PartialOptions {
 | 
			
		||||
    public static final PartialOptions DEFAULT = new PartialOptions(
 | 
			
		||||
        null, OptionalLong.empty(), OptionalLong.empty(), OptionalInt.empty(), Optional.empty()
 | 
			
		||||
 
 | 
			
		||||
@@ -27,7 +27,7 @@ final class ResultHelpers {
 | 
			
		||||
        return throwUnchecked0(t);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @SuppressWarnings("unchecked")
 | 
			
		||||
    @SuppressWarnings({ "unchecked", "TypeParameterUnusedInFormals" })
 | 
			
		||||
    private static <T extends Throwable> T throwUnchecked0(Throwable t) throws T {
 | 
			
		||||
        throw (T) t;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -46,7 +46,17 @@ class LuaCoverage {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void write(Writer out) throws IOException {
 | 
			
		||||
        Files.find(ROOT, Integer.MAX_VALUE, (path, attr) -> attr.isRegularFile()).forEach(path -> {
 | 
			
		||||
        try (var files = Files.find(ROOT, Integer.MAX_VALUE, (path, attr) -> attr.isRegularFile())) {
 | 
			
		||||
            files.forEach(path -> writeSingleFile(out, path));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        for (var filename : coverage.keySet()) {
 | 
			
		||||
            if (filename.startsWith("/test-rom/")) continue;
 | 
			
		||||
            LOG.warn("Unknown file {}", filename);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void writeSingleFile(Writer out, Path path) {
 | 
			
		||||
        var relative = ROOT.relativize(path);
 | 
			
		||||
        var full = relative.toString().replace('\\', '/');
 | 
			
		||||
        if (!full.endsWith(".lua")) return;
 | 
			
		||||
@@ -63,12 +73,6 @@ class LuaCoverage {
 | 
			
		||||
        } catch (IOException e) {
 | 
			
		||||
            throw new UncheckedIOException(e);
 | 
			
		||||
        }
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        for (var filename : coverage.keySet()) {
 | 
			
		||||
            if (filename.startsWith("/test-rom/")) continue;
 | 
			
		||||
            LOG.warn("Unknown file {}", filename);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void writeCoverageFor(Writer out, Path fullName, Map<Integer, Integer> visitedLines) throws IOException {
 | 
			
		||||
 
 | 
			
		||||
@@ -101,7 +101,7 @@ public class ComputerBootstrap {
 | 
			
		||||
            try {
 | 
			
		||||
                context.ensureClosed(1, TimeUnit.SECONDS);
 | 
			
		||||
            } catch (InterruptedException e) {
 | 
			
		||||
                throw new IllegalStateException("Runtime thread was interrupted", e);
 | 
			
		||||
                Thread.currentThread().interrupt();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -65,7 +65,7 @@ public class ComputerThreadRunner implements AutoCloseable {
 | 
			
		||||
            } finally {
 | 
			
		||||
                errorLock.unlock();
 | 
			
		||||
            }
 | 
			
		||||
        } while (worker.executed == 0 || thread.hasPendingWork());
 | 
			
		||||
        } while (!worker.executed || thread.hasPendingWork());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @GuardedBy("errorLock")
 | 
			
		||||
@@ -87,7 +87,7 @@ public class ComputerThreadRunner implements AutoCloseable {
 | 
			
		||||
        private final Task run;
 | 
			
		||||
        private final ComputerScheduler.Executor executor;
 | 
			
		||||
        private long[] totals = new long[16];
 | 
			
		||||
        volatile int executed = 0;
 | 
			
		||||
        private volatile boolean executed = false;
 | 
			
		||||
 | 
			
		||||
        private Worker(ComputerScheduler scheduler, Task run) {
 | 
			
		||||
            this.run = run;
 | 
			
		||||
@@ -102,7 +102,7 @@ public class ComputerThreadRunner implements AutoCloseable {
 | 
			
		||||
        public void work() {
 | 
			
		||||
            try {
 | 
			
		||||
                run.run(executor);
 | 
			
		||||
                executed++;
 | 
			
		||||
                executed = true;
 | 
			
		||||
            } catch (Throwable e) {
 | 
			
		||||
                errorLock.lock();
 | 
			
		||||
                try {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user