From 54be4a7f8c201f1ec666a9d2b4f75544e11cda63 Mon Sep 17 00:00:00 2001 From: Nipuna Ranasinghe Date: Wed, 11 Dec 2024 23:26:47 +0530 Subject: [PATCH] Add minor fixes --- .../commons/workspace/RunContext.java | 2 +- .../command/executors/RunExecutor.java | 8 ++++---- .../workspace/BallerinaWorkspaceManager.java | 1 + .../BallerinaExtendedDebugServer.java | 10 +++++----- .../debugadapter/DebugExecutionManager.java | 7 +++---- .../debugadapter/utils/ServerUtils.java | 18 +++++++++++++----- 6 files changed, 27 insertions(+), 19 deletions(-) diff --git a/language-server/modules/langserver-commons/src/main/java/org/ballerinalang/langserver/commons/workspace/RunContext.java b/language-server/modules/langserver-commons/src/main/java/org/ballerinalang/langserver/commons/workspace/RunContext.java index af831a5cb2c3..8e929d58b5f7 100644 --- a/language-server/modules/langserver-commons/src/main/java/org/ballerinalang/langserver/commons/workspace/RunContext.java +++ b/language-server/modules/langserver-commons/src/main/java/org/ballerinalang/langserver/commons/workspace/RunContext.java @@ -63,4 +63,4 @@ public RunContext build() { return new RunContext(sourcePath, programArgs, env, debugPort); } } -} \ No newline at end of file +} diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/command/executors/RunExecutor.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/command/executors/RunExecutor.java index be04d327edf9..fcc24d3a2d4d 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/command/executors/RunExecutor.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/command/executors/RunExecutor.java @@ -49,13 +49,13 @@ public Boolean execute(ExecuteCommandContext context) throws LSCommandExecutorEx RunContext.Builder builder = new RunContext.Builder(extractPath(context)); builder.withProgramArgs(extractProgramArgs(context)); int debugPort = extractDebugArgs(context); - if (debugPort > 0) { + if (debugPort >= 0) { builder.withDebugPort(debugPort); } - // TODO handle env vars + // TODO: handle env vars - RunContext RunContext = builder.build(); - Optional processOpt = context.workspace().run(RunContext); + RunContext runContext = builder.build(); + Optional processOpt = context.workspace().run(runContext); if (processOpt.isEmpty()) { return false; } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/workspace/BallerinaWorkspaceManager.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/workspace/BallerinaWorkspaceManager.java index 9ca9223d71e0..cd0073c040a5 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/workspace/BallerinaWorkspaceManager.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/workspace/BallerinaWorkspaceManager.java @@ -102,6 +102,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; + import javax.annotation.Nonnull; import javax.annotation.Nullable; diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/BallerinaExtendedDebugServer.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/BallerinaExtendedDebugServer.java index 9e2565372e40..e44f512d42cd 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/BallerinaExtendedDebugServer.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/BallerinaExtendedDebugServer.java @@ -30,12 +30,12 @@ public interface BallerinaExtendedDebugServer extends IDebugProtocolServer { /** - * Custom request to send the program output from the remote VM (initiated by the debug client) to the debug server. - * This extension is specifically used in the fast-run mode to forward the program output to the debug adapter, - * to be sent to the client. + * Custom request to forward the program output from the remote VM (initiated by the debug client) to the debug + * server. This extension is specifically designed for fast-run mode, enabling the debug adapter to forward the + * program output to the client. * - * @param arguments output event arguments - * @return completable future + * @param arguments the output event arguments + * @return a CompletableFuture representing the completion of the request */ @JsonRequest CompletableFuture output(OutputEventArguments arguments); diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/DebugExecutionManager.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/DebugExecutionManager.java index 911a77b1b39a..f741ca9b754a 100755 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/DebugExecutionManager.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/DebugExecutionManager.java @@ -110,12 +110,11 @@ private VirtualMachine attachWithRetries(AttachingConnector connector, Map extendedCapabilities = @@ -150,8 +156,8 @@ public static boolean supportsBreakpointVerification(ExecutionContext context) { */ public static void sendFastRunNotification(ExecutionContext context, int port) { Endpoint endPoint = new GenericEndpoint(context.getClient()); - FastRunArguments arguments = new FastRunArguments(port); - endPoint.notify(START_FAST_RUN, arguments); + FastRunArgs arguments = new FastRunArgs(port); + endPoint.notify(FAST_RUN_NOTIFICATION_NAME, arguments); } /** @@ -169,9 +175,11 @@ public static int findFreePort() { } /** - * Represents the arguments of the 'restarted' notification. + * Represents the arguments of the 'startFastRun' notification. + * + * @param port port number to start the fast-run */ - public record FastRunArguments(int port) { + public record FastRunArgs(int port) { } }