entlicher commented on a change in pull request #3006:
URL: https://github.com/apache/netbeans/pull/3006#discussion_r654992834
##########
File path:
java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/debugging/launch/NbLaunchDelegate.java
##########
@@ -336,6 +403,12 @@ private static void startNativeDebug(File nativeImageFile,
List<String> args, St
throw new IllegalArgumentException("Expected String or String
list");
}
}
+
+ private static CompletableFuture<Pair<ActionProvider, String>>
findEnabledTarget(FileObject toRun, SingleMethod singleMethod, boolean debug,
boolean testRun, NbProcessConsole ioContext) throws IllegalArgumentException {
Review comment:
I did not find usage of this method.
##########
File path:
java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/debugging/launch/NbLaunchDelegate.java
##########
@@ -226,6 +217,82 @@ public void progressHandleCreated(ProgressOperationEvent
e) {
}
lookup = Lookups.fixed(runContext.toArray(new
Object[runContext.size()]));
+ // the execution Lookup is fully populated now. If the Project
supports Configurations,
+ // check if the action is actually enabled in the prescribed
configuration. If it is not,
+ if (pcp != null) {
+ final ActionProvider ap = providerAndCommand.first();
+ final String cmd = providerAndCommand.second();
+ if (!ap.isActionEnabled(cmd, lookup)) {
+
+ // attempt to locate a different configuration that
enables the action:
+ ProjectConfiguration supportive = null;
+ int confIndex =
runContext.indexOf(selectConfiguration);
+ if (confIndex == -1) {
+ runContext.add(null);
+ confIndex = runContext.size() - 1;
+ }
+ boolean defConfig = true;
+ for (ProjectConfiguration c : pcp.getConfigurations())
{
+ runContext.set(confIndex, c);
+ Lookup tryConf =
Lookups.fixed(runContext.toArray(new Object[runContext.size()]));
+ if (ap.isActionEnabled(cmd, tryConf)) {
+ supportive = c;
+ break;
+ }
+ defConfig = false;
+ }
+ String msg;
+ String recommended = defConfig ?
Bundle.ERR_LaunchDefaultConfiguration():
Bundle.ERR_LaunchSupportiveConfigName(supportive.getDisplayName());
+ if (debug) {
+ msg = supportive == null ?
+ Bundle.ERR_UnsupportedLaunchDebug() :
Bundle.ERR_UnsupportedLaunchDebugConfig(selectConfiguration.getDisplayName(),
recommended);
+ } else {
+ msg = supportive == null ?
+ Bundle.ERR_UnsupportedLaunch() :
Bundle.ERR_UnsupportedLaunchConfig(selectConfiguration.getDisplayName(),
recommended);
+ }
+ LanguageClient client =
context.getLspSession().getLookup().lookup(LanguageClient.class);
+ if (client != null) {
+ client.showMessage(new
MessageParams(MessageType.Warning, msg));
+ // first complete the future
+ launchFuture.complete(null);
+ // and then fake debuggee termination.
+ context.getClient().terminated(new
TerminatedEventArguments());
+ } else {
+ launchFuture.completeExceptionally(new
CancellationException());
+ }
Review comment:
Shouldn't we return here so that the launch does not proceed?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists