-
Notifications
You must be signed in to change notification settings - Fork 4
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
improved handling of lsp failure state #309
Changes from all commits
13c55ac
548a9da
374e549
34db4dc
9f846b1
5198a20
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package software.aws.toolkits.eclipse.amazonq.lsp.manager; | ||
|
||
public enum LspState { | ||
ACTIVE, | ||
FAILED, | ||
PENDING | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package software.aws.toolkits.eclipse.amazonq.lsp.manager; | ||
|
||
import software.aws.toolkits.eclipse.amazonq.plugin.Activator; | ||
import software.aws.toolkits.eclipse.amazonq.views.ViewVisibilityManager; | ||
|
||
public final class LspStatusManager { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can avoid having the LspStatusManager. The EventBroker keeps track of the latest state, so if we emit to the event bus, then every subscriber will get the latest LSP state when the subscribe. |
||
|
||
private static final LspStatusManager INSTANCE; | ||
private LspState lspState; | ||
|
||
static { | ||
INSTANCE = new LspStatusManager(); | ||
} | ||
|
||
private LspStatusManager() { | ||
lspState = LspState.PENDING; | ||
Activator.getEventBroker().post(lspState); | ||
} | ||
|
||
public static LspStatusManager getInstance() { | ||
return INSTANCE; | ||
} | ||
|
||
|
||
public boolean lspFailed() { | ||
return (lspState == LspState.FAILED); | ||
} | ||
|
||
public void setToActive() { | ||
lspState = LspState.ACTIVE; | ||
Activator.getEventBroker().post(lspState); | ||
ViewVisibilityManager.showDefaultView("restart"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what does the string value represent? It is unclear what it does to me. If its somehow related to metrics it should be indicated so with a enum class that holds these string eg. if this represents a click event then Source.Restart and similar There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The string value is indeed metric related, and you're right that it should be an enum. I'll start work to refactor all these instances. These metric strings are widely used and I don't want to dilute this PR with the changes, thus I'll open a separate PR with the edits. |
||
} | ||
|
||
public void setToFailed() { | ||
if (lspState != LspState.FAILED) { | ||
ViewVisibilityManager.showLspStartUpFailedView("update"); | ||
lspState = LspState.FAILED; | ||
Activator.getEventBroker().post(lspState); | ||
} | ||
} | ||
|
||
public LspState getLspState() { | ||
return lspState; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package software.aws.toolkits.eclipse.amazonq.views; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
import software.aws.toolkits.eclipse.amazonq.lsp.manager.LspStatusManager; | ||
|
||
public final class LspStartUpFailedView extends BaseView { | ||
public static final String ID = "software.aws.toolkits.eclipse.amazonq.views.LspStartUpFailedView"; | ||
|
||
private static final String ICON_PATH = "icons/AmazonQ64.png"; | ||
private static final String HEADER_LABEL = "Language Server failed to start."; | ||
private static final String DETAIL_MESSAGE = "Restart Eclipse or review error logs for troubleshooting"; | ||
|
||
/* TODO: After refactor of LSP error handling is completed, | ||
* add logic to base detail_message on error code returned from exception | ||
* */ | ||
@Override | ||
protected String getIconPath() { | ||
return ICON_PATH; | ||
} | ||
|
||
@Override | ||
protected String getHeaderLabel() { | ||
return HEADER_LABEL; | ||
} | ||
|
||
@Override | ||
protected String getDetailMessage() { | ||
return DETAIL_MESSAGE; | ||
} | ||
|
||
@Override | ||
protected void showAlternateView() { | ||
ViewVisibilityManager.showDefaultView("restart"); | ||
} | ||
|
||
@Override | ||
protected CompletableFuture<Boolean> isViewDisplayable() { | ||
return CompletableFuture.completedFuture(LspStatusManager.getInstance().lspFailed()); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this caught by startProcess on L70?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, both these exceptions are caught at separate changes so no overlap. The exception on L47 is caught by eclipse during instantiation of the class, and the exception on L70 is caught once eclipse begins the LSP init process in the earlyStartup process.