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

Ignoring failures when checking for hyperlinks #1186

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

will-lauer
Copy link

Adding LanguageServers.addAllSuccessful as an alternative to LanguageServers.addAll so that exceptions from one of the requests being combined can be ignored. Then using this new method in OpenDeclarationHyperlinkDetector when combining the results from definitions, declarations, typeDefinitions, and implementions because some LSPs return errors instead of empty lists for some of these calls. Instead, we combine only the successful results when building the list of hyperlinks, ignoring the errors.

This should resolve #1169

Adding LanguageServers.addAllSuccessful as an alternative to
LanguageServers.addAll so that exceptions from one of the requests being
combined can be ignored. Then using this new method in
OpenDeclarationHyperlinkDetector when combining the results from
definitions, declarations, typeDefinitions, and implementions because
some LSPs return errors instead of empty lists for some of these calls.
Instead, we combine only the successful results when building the list
of hyperlinks, ignoring the errors.

This should resolve eclipse-lsp4e#1169
Copy link
Contributor

@rubenporras rubenporras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. I like the idea but I think we should improve a little bit the changes.

@@ -30,10 +30,16 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks unrelated to the ticket you are resolving. Could you move the change to a new PR so that it can be looked at independently?

@@ -12,6 +12,16 @@
*******************************************************************************/
package org.eclipse.lsp4e;

import org.eclipse.core.resources.IProject;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like organize imports is configured different than by default. Could you change it so that the PR does not change the order of the import in all the modified files?

@@ -410,6 +410,30 @@ public static <T> CompletableFuture<List<T>> addAll(CompletableFuture<List<T>> a
return res;
}

/**
* Combines two async lists of results into a single list by adding all the elements of the second list to the first one,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Combines two async lists of results into a single list by adding all the elements of the second list to the first one,
* Combines async lists of results into a single list by adding all the elements of each lists to a new list

@@ -410,6 +410,30 @@ public static <T> CompletableFuture<List<T>> addAll(CompletableFuture<List<T>> a
return res;
}

/**
* Combines two async lists of results into a single list by adding all the elements of the second list to the first one,
* ignoring abnormal results and only including succeses.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* ignoring abnormal results and only including succeses.
* ignoring any CompletableFuture that completed exceptionally.

.thenApply( v -> {
List<T> results = new ArrayList<>(futures.length);
for(CompletableFuture<List<T>> f : futures) {
if (!f.isCompletedExceptionally()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of just ignoring exceptions, I think we should log them using LanguageServerPlugin.logError

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants