Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support also COMMAND_RUN and COMMAND_DEBUG actions #9041

Merged
merged 7 commits into from
Apr 18, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ public final class EnsoActionProvider implements ActionProvider {

@Override
public String[] getSupportedActions() {
return new String[]{ActionProvider.COMMAND_RUN_SINGLE, ActionProvider.COMMAND_DEBUG_SINGLE};
return new String[]{
COMMAND_RUN, COMMAND_DEBUG,
COMMAND_RUN_SINGLE, COMMAND_DEBUG_SINGLE
};
}

@Override
Expand Down Expand Up @@ -106,7 +109,7 @@ public void invokeAction(String action, Lookup lkp) throws IllegalArgumentExcept
.postExecution((exitCode) -> {
cf.complete(exitCode);
});
var launch = ActionProvider.COMMAND_DEBUG_SINGLE.equals(action) ?
var launch = COMMAND_DEBUG_SINGLE.equals(action) || COMMAND_DEBUG.equals(action) ?
new DebugAndLaunch(fo, builder, params) : builder;
var service = ExecutionService.newService(launch, descriptor, script.getName());
service.run();
Expand Down Expand Up @@ -142,13 +145,12 @@ private static List<String> prepareArguments(File script, boolean isGraalVM) {
}

@Override
public boolean isActionEnabled(String string, Lookup lkp) throws IllegalArgumentException {
if (lkp.lookup(EnsoDataObject.class) != null) {
return true;
} else {
var fo = lkp.lookup(FileObject.class);
return fo != null && fo.getLookup().lookup(EnsoDataObject.class) != null;
}
public boolean isActionEnabled(String action, Lookup lkp) throws IllegalArgumentException {
return switch (action) {
case COMMAND_RUN_SINGLE, COMMAND_DEBUG_SINGLE, COMMAND_RUN, COMMAND_DEBUG ->
lkp.lookup(EnsoDataObject.class) != null;
default -> false;
};
}

static final class DebugAndLaunch implements Callable<Process> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,11 @@ public EnsoSources findBinaryRoots2(URL url) {

@Override
public URL[] computeRoots(EnsoSources result) {
return new URL[] { result.output().toURL() };
if (result.output() != null) {
return new URL[] { result.output().toURL() };
} else {
return new URL[0];
}
}

@Override
Expand Down
Loading