-
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
Fetch customizations from LSP server #43
Changes from 2 commits
ec98e04
5e49228
37bc88f
4d793b7
3fe700e
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,16 @@ | ||
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package software.aws.toolkits.eclipse.amazonq.lsp.model; | ||
|
||
public class GetConfigurationFromServerParams { | ||
private String section; | ||
|
||
public final String getSection() { | ||
return this.section; | ||
} | ||
|
||
public final void setSection(final String section) { | ||
this.section = section; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ | |
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.concurrent.ExecutionException; | ||
|
||
import org.eclipse.jface.action.ContributionItem; | ||
import org.eclipse.swt.SWT; | ||
import org.eclipse.swt.events.SelectionAdapter; | ||
|
@@ -17,8 +19,11 @@ | |
import jakarta.inject.Inject; | ||
import software.amazon.awssdk.utils.StringUtils; | ||
import software.aws.toolkits.eclipse.amazonq.configuration.PluginStore; | ||
import software.aws.toolkits.eclipse.amazonq.customization.CustomizationUtil; | ||
import software.aws.toolkits.eclipse.amazonq.exception.AmazonQPluginException; | ||
import software.aws.toolkits.eclipse.amazonq.util.AuthStatusChangedListener; | ||
import software.aws.toolkits.eclipse.amazonq.util.Constants; | ||
import software.aws.toolkits.eclipse.amazonq.util.PluginLogger; | ||
import software.aws.toolkits.eclipse.amazonq.views.CustomizationDialog; | ||
import software.aws.toolkits.eclipse.amazonq.views.CustomizationDialog.ResponseSelection; | ||
import software.aws.toolkits.eclipse.amazonq.views.model.Customization; | ||
|
@@ -50,9 +55,12 @@ public void onAuthStatusChanged(final boolean isLoggedIn) { | |
|
||
private List<Customization> getCustomizations() { | ||
List<Customization> customizations = new ArrayList<>(); | ||
customizations.add(new Customization("customization-arn-1", "Customization 1", "Code Whisperer customization 1")); | ||
customizations.add(new Customization("customization-arn-2", "Customization 2", "Code Whisperer customization 2")); | ||
customizations.add(new Customization("customization-arn-3", "Customization 3", "Code Whisperer customization 3")); | ||
try { | ||
customizations = CustomizationUtil.listCustomizations().get(); | ||
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. Is there any way to make this populate asynchronously? This would block the UI thread, no? 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. nice catch! I updated the code to fetch the customizations async and not block the UI thread to open the dialog. |
||
} catch (InterruptedException | ExecutionException e) { | ||
PluginLogger.error("Error occurred in getCustomizations", e); | ||
throw new AmazonQPluginException(e); | ||
} | ||
return customizations; | ||
} | ||
|
||
|
@@ -64,7 +72,6 @@ public void fill(final Menu menu, final int index) { | |
@Override | ||
public void widgetSelected(final SelectionEvent e) { | ||
CustomizationDialog dialog = new CustomizationDialog(shell); | ||
// TODO: This mock will be replaced by an actual call to LSP | ||
dialog.setCustomisationResponse(getCustomizations()); | ||
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. nit: customisation -> customization. keep it consistent |
||
String storedCustomizationArn = PluginStore.get(Constants.CUSTOMIZATION_STORAGE_INTERNAL_KEY); | ||
if (StringUtils.isBlank(storedCustomizationArn)) { | ||
|
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.
Sorry not too familiar with the params yet. Where are these sections defined? I don't see them in the high level manifests / plugin.xml.
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.
These don't need to be defined in manifest/plugin.xml. This is what LSP server for customization expects as an input. References: https://github.com/aws/language-servers/blob/main/server/aws-lsp-codewhisperer/src/language-server/configuration/qConfigurationServer.ts#L32 , https://github.com/aws/language-server-runtimes/blob/3a3c3f629dcba752a977ab1f1bf9e99dc0dc9f02/runtimes/protocol/getConfigurationFromServer.ts#L10
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.
Ah I see.