Repository navigation
fix: The DAP run configuration's working directory is now used when creating the server process if available (fixes #1684) - #1685
Conversation
… is used for the executed DAP server process.
|
Hey @SCWells72 ! Your PR looks good, when it will be finished please switch to ready PR. |
|
|
||
| protected @NotNull GeneralCommandLine createStartServerCommandLine(@Nullable String command) throws ExecutionException { | ||
| return createStartServerCommandLine(command, Collections.emptyMap(), false); | ||
| return createStartServerCommandLine(null, command, Collections.emptyMap(), false); |
There was a problem hiding this comment.
Adjusted this delegated signature, but note that this method is unused. I didn't want to delete it in case it was considered part of the historical interface, but if it's truly unused, I can delete it as part of this work.
| } | ||
|
|
||
| protected @NotNull GeneralCommandLine createStartServerCommandLine(@Nullable String command, | ||
| protected @NotNull GeneralCommandLine createStartServerCommandLine(@Nullable String workingDirectory, |
There was a problem hiding this comment.
Added the optional working directory as the first argument here.
| command = command.replace($_PORT, String.valueOf(port)); | ||
| } | ||
| GeneralCommandLine commandLine = createCommandLine(command, userEnvironmentVariables, includeSystemEnvironmentVariables); | ||
| if (StringUtils.isNotBlank(workingDirectory)) { |
There was a problem hiding this comment.
And if the working directory is set and corresponds to a physical directory in the file system, I set it as the server process' working directory.
| @Nullable | ||
| protected GeneralCommandLine createStartServerCommandLine(@NotNull RunConfigurationOptions options) throws ExecutionException { | ||
| if (options instanceof DAPRunConfigurationOptions dapOptions) { | ||
| String workingDirectory = dapOptions.getWorkingDirectory(); |
There was a problem hiding this comment.
These two changes are just getting the working directory from the DAP options (which take it from the run configuration) and passing it to createStartServerCommandLine().
| package com.redhat.devtools.lsp4ij.internal; | ||
|
|
||
|
|
||
| import org.jetbrains.annotations.Contract; |
There was a problem hiding this comment.
When I used StringUtils.isNotBlank() above for consistency with what was being used in the same class/method, I noticed that the IDE's nullability analysis still showed the value that was successfully evaluated as not being blank as potentially being null. Obviously that's not possible, and it's doing so because these methods don't use the @Contract annotation to inform the IDE's nullability analysis about these methods' contracts around null inputs. I've updated them to do so properly which should provide much better nullability analysis when/where they're used. It wouldn't be a bad idea to update other common methods that can return null (or non-null) based specifically on the nullability of their inputs so that the IDE's nullability analysis can be much more informed about when a value is or is not potentially null based on prior calls in the code path.
|
Thanks @SCWells72 ! |
The title pretty much says it all, but this addresses an issue where DAP server processes are executed without any explicit working directory, therefore requiring any path-based server command-line arguments to be fully-qualified and not allowing the server process to find working directory-relative context like local configuration files.
Here's evidence of it working:
Run configuration

Server process
