Skip to content

Commit

Permalink
Support also COMMAND_RUN and COMMAND_DEBUG actions (#9041)
Browse files Browse the repository at this point in the history
Turns out that #8923 isn't enough to support debugging of `Vector_Spec.enso` when root of Enso repository is opened as a folder/workspace. To allow debugging of `Vector_Spec.enso` two changes are needed. One is provided in this PR, the other one will be integrated as apache/netbeans#7105
  • Loading branch information
JaroslavTulach authored Apr 18, 2024
1 parent 86ecd3e commit c8dcd48
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
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

0 comments on commit c8dcd48

Please sign in to comment.