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

Fix: language server generatePipepath error #1557

Merged
merged 2 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions extension/src/languageServer/languageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export async function startLanguageClientAndWaitForConnection(
rootProjectsStore: RootProjectsStore,
languageServerPipePath: string
): Promise<void> {
if (languageServerPipePath === "") {
isLanguageServerStarted = false;
return;
}
void vscode.window.withProgress({ location: vscode.ProgressLocation.Window }, (progress) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
return new Promise<void>(async (resolve) => {
Expand Down
4 changes: 2 additions & 2 deletions extension/src/server/GradleServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
private setLanguageServerPipePath(): void {
this.languageServerPipePath = getRandomPipeName();
if (this.languageServerPipePath === "") {
this.logger.error("Failed to generate language server pipe path, language server will not start");
this.logger.error("Gradle language server will not start due to pipe path generation failure");
}
}

Expand All @@ -55,7 +55,7 @@
if (isPrepared) {
startBuildServer = true;
} else {
this.logger.error("Failed to generate build server pipe path, build server will not start");
this.logger.error("Gradle build server will not start due to pipe path generation failure");
}
}
this.bspProxy.setBuildServerStarted(startBuildServer);
Expand Down Expand Up @@ -152,7 +152,7 @@

private async killProcess(): Promise<void> {
if (this.process) {
return new Promise((resolve, _reject) => {

Check warning on line 155 in extension/src/server/GradleServer.ts

View workflow job for this annotation

GitHub Actions / Build & Analyse

'_reject' is defined but never used
if (this.process?.pid) {
kill(this.process.pid, () => resolve);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.lsp4j.CompletionOptions;
import org.eclipse.lsp4j.DocumentFilter;
import org.eclipse.lsp4j.ExecuteCommandOptions;
Expand All @@ -43,9 +42,6 @@ public class GradleLanguageServer implements LanguageServer, LanguageClientAware

public static void main(String[] args) {
GradleLanguageServer server = new GradleLanguageServer();
if (StringUtils.isBlank(args[0])) {
server.exit();
}
try {
NamedPipeStream pipeStream = new NamedPipeStream(args[0]);

Expand All @@ -55,7 +51,7 @@ public static void main(String[] args) {
server.connect(launcher.getRemoteProxy());
launcher.startListening();
} catch (IOException e) {
server.exit();
throw new RuntimeException("Gradle language server start failed", e);
Jiaaming marked this conversation as resolved.
Show resolved Hide resolved
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.badsyntax.gradle;

import com.github.badsyntax.gradle.utils.Utils;
import com.google.common.base.Strings;
import com.microsoft.gradle.GradleLanguageServer;
import io.grpc.Server;
import io.grpc.ServerBuilder;
Expand Down Expand Up @@ -62,8 +63,10 @@ public static void main(String[] args) throws Exception {
int taskServerPort = Integer.parseInt(Utils.validateRequiredParam(params, "port"));
startTaskServerThread(taskServerPort);

String languageServerPipePath = Utils.validateRequiredParam(params, "languageServerPipePath");
startLanguageServerThread(languageServerPipePath);
String languageServerPipePath = params.get("languageServerPipePath");
if (!Strings.isNullOrEmpty(languageServerPipePath)) {
startLanguageServerThread(languageServerPipePath);
}

boolean startBuildServer = Boolean.parseBoolean(Utils.validateRequiredParam(params, "startBuildServer"));
if (startBuildServer) {
Expand Down
Loading