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

Use language server label as background job name if available #367

Merged
merged 1 commit into from
Jan 14, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class LanguageClientImpl implements LanguageClient {
public final void connect(LanguageServer server, LanguageServerWrapper wrapper) {
this.server = server;
this.wrapper = wrapper;
progressManager.connect(server);
progressManager.connect(server, wrapper.serverDefinition);
}

protected void setDiagnosticsConsumer(@NonNull Consumer<PublishDiagnosticsParams> diagnosticConsumer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.lsp4e.LanguageServerPlugin;
import org.eclipse.lsp4e.LanguageServersRegistry.LanguageServerDefinition;
import org.eclipse.lsp4e.ui.Messages;
import org.eclipse.lsp4j.ProgressParams;
import org.eclipse.lsp4j.WorkDoneProgressBegin;
import org.eclipse.lsp4j.WorkDoneProgressCancelParams;
Expand All @@ -41,6 +43,7 @@ public class LSPProgressManager {
private final Map<String, BlockingQueue<ProgressParams>> progressMap;
private final Map<IProgressMonitor, Integer> currentPercentageMap;
private LanguageServer languageServer;
private LanguageServerDefinition languageServerDefinition;
private final Set<String> done;

public LSPProgressManager() {
Expand All @@ -49,8 +52,9 @@ public LSPProgressManager() {
this.done = new ConcurrentSkipListSet<>();
}

public void connect(final LanguageServer languageServer) {
public void connect(final LanguageServer languageServer, LanguageServerDefinition languageServerDefinition) {
this.languageServer = languageServer;
this.languageServerDefinition = languageServerDefinition;
}
/**
* Creates the progress.
Expand All @@ -68,12 +72,19 @@ public void connect(final LanguageServer languageServer) {
LanguageServerPlugin.logInfo(
"Old progress with identifier " + jobIdentifier + " discarded due to new create progress request"); //$NON-NLS-1$//$NON-NLS-2$
}
createJob(languageServer, queue, jobIdentifier);
createJob(queue, jobIdentifier);
return CompletableFuture.completedFuture(null);
}

private void createJob(final LanguageServer languageServer, final LinkedBlockingDeque<ProgressParams> queue, final String jobIdentifier) {
Job job = Job.create("Language Server Background Job", (ICoreRunnable) monitor -> { //$NON-NLS-1$
private void createJob(final LinkedBlockingDeque<ProgressParams> queue, final String jobIdentifier) {
final var languageServer = this.languageServer;
final var languageServerDefinition = this.languageServerDefinition;

final var jobName = languageServerDefinition == null //
|| languageServerDefinition.label == null || languageServerDefinition.label.isBlank() //
? Messages.LSPProgressManager_BackgroundJobName
: languageServerDefinition.label;
Job job = Job.create(jobName, (ICoreRunnable) monitor -> {
try {
while (true) {
if (monitor.isCanceled()) {
Expand Down
1 change: 1 addition & 0 deletions org.eclipse.lsp4e/src/org/eclipse/lsp4e/ui/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public class Messages extends NLS {
public static String DocumentContentSynchronizer_TimeoutThresholdMessage;
public static String CreateFile_confirm_title;
public static String CreateFile_confirm_message;
public static String LSPProgressManager_BackgroundJobName;

static {
NLS.initializeMessages("org.eclipse.lsp4e.ui.messages", Messages.class); //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,6 @@ DocumentContentSynchronizer_TimeoutMessage="On-Save action timeout out after {0}
DocumentContentSynchronizer_TimeoutThresholdMessage="On-Save action timeout out after {0} seconds for {1}. On-Save actions will no longer be called for this document"

CreateFile_confirm_title=Create file
CreateFile_confirm_message=Unable to open file ''{0}''. Do you want to create file?
CreateFile_confirm_message=Unable to open file ''{0}''. Do you want to create file?

LSPProgressManager_BackgroundJobName=Language Server Background Job