Skip to content
This repository was archived by the owner on Apr 21, 2023. It is now read-only.

Return a WorkspaceEdit even if an exception is thrown #1952

Merged
merged 1 commit into from
Aug 18, 2022

Conversation

rubenporras
Copy link
Contributor

The error is logged but the method still returns a (null) value. This allows the server to return a CodeAction to the client, that this can inspect and discard (because no editAction is set). Otherwise the client will wait for the server and show it like that on the UI, which does not create a good user experience.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
The error is logged but the method still returns a (null) value. This allows the server to return a CodeAction to the client, that this can inspect and discard (because no editAction is set). Otherwise the client will wait for the server and show it like that on the UI, which does not create a good user experience.
@cdietrich cdietrich added this to the Release_2.28 milestone Aug 17, 2022
@@ -131,7 +134,8 @@ public WorkspaceEdit apply() {
}
return edit;
} catch (Exception exc) {
throw new WrappedException(exc);
log.error("Creation of WorkspaceEdit failed.", exc);
Copy link
Member

Choose a reason for hiding this comment

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

@heinrichWeichert are you ok with this change?

Copy link

@heinrichWeichert heinrichWeichert Aug 17, 2022

Choose a reason for hiding this comment

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

Could you we return an empty Edit instead that does nothing?

Copy link
Contributor Author

@rubenporras rubenporras Aug 18, 2022

Choose a reason for hiding this comment

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

@heinrichWeichert : Yes, we could return new WorkspaceEdit(), LSP defines the workspaceEdit as a nullable field. I checked LSP4E and it always checks for the field to be != null before accessing it, I also checked what it would do with an empty edit, and it will have the same result, as it will contain no changes. I think returning null is simpler, but if you think returning a new WorkspaceEdit() is better, I would do that, I do not have a strong opinion. May I ask why you think that returning an empty Edit is preferable?

Copy link
Member

Choose a reason for hiding this comment

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

@szarnekow what do you think?

Copy link

@heinrichWeichert heinrichWeichert Aug 18, 2022

Choose a reason for hiding this comment

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

@rubenporras OK, i didn't check that. If it is indeed nullsafe and expected it's fine with me.
One thing about the logger @cdietrich is there are more suitable logger that logs xtext framework errors? In log4j, i would have to configure this one differently, and it seems more like a debug/trace level for me? I would be OK if this is not that relevant....

Copy link
Contributor

Choose a reason for hiding this comment

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

I've a preference towards returning null, too. An empty edit suggests that there is something the client could apply which might mess with its undo queue or whatsoever.

Copy link
Member

Choose a reason for hiding this comment

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

i am not sure if and how tracing works in standalone mode.

Choose a reason for hiding this comment

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

all fine for me

@cdietrich cdietrich merged commit 0c06762 into eclipse:master Aug 18, 2022
@cdietrich
Copy link
Member

thx @rubenporras

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants