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

Implement configurations related to customization updates #39

Merged
merged 19 commits into from
Sep 30, 2024

Conversation

pras0131
Copy link
Contributor

Reference ticket: https://issues.amazon.com/issues/ECLIPSE-295

The PR aims to handle two scenarios:

  1. Trigger workspace/didChangeConfiguration notification to LSP server upon a customization update by a user.
  2. Implement workspace/configuration to return customization related configuration (for now) when LSP server requests for the saved configurations at the Plugin side. LSP server requests this at two places: during initialization of LSP server and upon receiving workspace/didChangeConfiguration notification from the Plugin/client.

Tested the above two functionalities by taking a pull of aws/language-servers#462 branch in my local and running the same locally.

@pras0131 pras0131 requested a review from breedloj September 26, 2024 14:45

public CustomizationUtil() {
try {
amazonQLspServer = LspProvider.getAmazonQServer().get();
Copy link
Contributor

Choose a reason for hiding this comment

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

This blocking call should not be placed into the constructor. This will not resolve until the LSP is downloaded and started up, and if we are waiting on the main thread it can cause deadlock. See #35

Comment on lines 43 to 45
} else {
output.add(null);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes because we are not handling other configurations as of now. Didn't want to handle it by fetching first index hardcoding. Also according to the LSP spec, The request can fetch several configuration settings in one roundtrip. The order of the returned configuration settings correspond to the order of the passed ConfigurationItems (e.g. the first item in the response is the result for the first configuration item in the params).

Reference: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_configuration

Map<String, Object> updatedSettings = new HashMap<>();
Map<String, String> internalMap = new HashMap<>();
internalMap.put("customization", this.selectedCustomisationArn);
updatedSettings.put("aws.q", internalMap);
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's put this value aws.q in a const somewhere since we need to use it in multiple places.

Map<String, String> internalMap = new HashMap<>();
internalMap.put(Constants.LSP_CUSTOMIZATION_CONFIGURATION_KEY, this.selectedCustomisationArn);
updatedSettings.put(Constants.LSP_CONFIGURATION_KEY, internalMap);
CustomizationUtil.triggerChangeConfigurationNotification(updatedSettings);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we will still want this to be processed in a separate thread, due to the downstream blocking call.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean we should not even wait for LspProvider.getAmazonQServer() to complete?

Copy link
Contributor Author

@pras0131 pras0131 Sep 30, 2024

Choose a reason for hiding this comment

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

made the change to let it be executed in a separate thread.

@breedloj
Copy link
Contributor

Can you please merge main into your branch to make sure Checkstyle is running?

@pras0131
Copy link
Contributor Author

pras0131 commented Sep 30, 2024

Can you please merge main into your branch to make sure Checkstyle is running?

This PR is dependent on this one #33, that's why can't merge it to main. I forked this one from paras/showCustomizationsDialog branch. I formatted on my local for checkstyle as well and pushed to this branch.

@pras0131 pras0131 force-pushed the paras/lspConfigurations branch from 88194fc to f5a8163 Compare September 30, 2024 15:10
Base automatically changed from paras/showCustomizationsDialog to main September 30, 2024 16:56
@breedloj breedloj merged commit 5023db0 into main Sep 30, 2024
1 check passed
@breedloj breedloj deleted the paras/lspConfigurations branch September 30, 2024 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants