Skip to content

Commit

Permalink
Add minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
NipunaRanasinghe committed Dec 11, 2024
1 parent b055589 commit 54be4a7
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ public RunContext build() {
return new RunContext(sourcePath, programArgs, env, debugPort);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<Process> processOpt = context.workspace().run(RunContext);
RunContext runContext = builder.build();
Optional<Process> processOpt = context.workspace().run(runContext);
if (processOpt.isEmpty()) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Void> output(OutputEventArguments arguments);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,11 @@ private VirtualMachine attachWithRetries(AttachingConnector connector, Map<Strin

return attachedVm;
} catch (IOException e) {
LOGGER.debug(String.format("Attachment attempt %d/%d failed: %s", attempt, maxAttempts, e.getMessage()));
LOGGER.debug(String.format("Attach attempt %d/%d failed: %s", attempt, maxAttempts, e.getMessage()));
try {
Thread.sleep(retryIntervalMs);
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
throw new IOException("Attachment interrupted", e);
} catch (InterruptedException ignored) {
// ignored
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*/
public class ServerUtils {

private static final String START_FAST_RUN = "startFastRun";
private static final String FAST_RUN_NOTIFICATION_NAME = "startFastRun";

/**
* Checks whether the debug server should run in no-debug mode.
Expand All @@ -56,6 +56,12 @@ public static boolean isNoDebugMode(ExecutionContext context) {
}
}

/**
* Checks whether the fast-run mode is enabled in the connected debug client.
*
* @param context debug context
* @return true if the debug mode is fast-run mode
*/
public static boolean isFastRunEnabled(ExecutionContext context) {
try {
Optional<ClientConfigHolder.ExtendedClientCapabilities> extendedCapabilities =
Expand Down Expand Up @@ -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);
}

/**
Expand All @@ -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) {

}
}

0 comments on commit 54be4a7

Please sign in to comment.