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

feat(amazonq): Implement aws/syncModuleDependencies call #5414

Merged
merged 27 commits into from
Mar 7, 2025

Conversation

samgst-amazon
Copy link
Contributor

@samgst-amazon samgst-amazon commented Feb 26, 2025

Implement the bare structure of the syncModuleDependencies service to make the call from the client to the server

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Description

added interface for the service handler as well as the data class for the params.

aws/syncModuleDependencies added to AmazonQLanguageServer interface to handle sending the JSONRequests

Checklist

  • My code follows the code style of this project
  • I have added tests to cover my changes
  • A short description of the change has been added to the CHANGELOG if the change is customer-facing in the IDE.
  • I have added metrics for my changes (if required)

License

I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link

github-actions bot commented Feb 26, 2025

Qodana Community for JVM

7 new problems were found

Inspection name Severity Problems
Unused symbol 🔶 Warning 4
Unstable API Usage 🔶 Warning 3

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Contact Qodana team

Contact us at qodana-support@jetbrains.com

package software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.dependencies

public class SyncModuleDependenciesParams(
val moduleName: String,

Check warning

Code scanning / QDJVMC

Unused symbol Warning

Property "moduleName" is never used
val moduleName: String,
val programmingLanguage: String,
val files: List<String>,
val dirs: List<String>,

Check warning

Code scanning / QDJVMC

Unused symbol Warning

Property "dirs" is never used
val programmingLanguage: String,
val files: List<String>,
val dirs: List<String>,
val includePatterns: List<String>,

Check warning

Code scanning / QDJVMC

Unused symbol Warning

Property "includePatterns" is never used
val files: List<String>,
val dirs: List<String>,
val includePatterns: List<String>,
val excludePatterns: List<String>,

Check warning

Code scanning / QDJVMC

Unused symbol Warning

Property "excludePatterns" is never used
@samgst-amazon samgst-amazon marked this pull request as ready for review March 3, 2025 19:25
@samgst-amazon samgst-amazon requested a review from a team as a code owner March 3, 2025 19:25
@samgst-amazon samgst-amazon marked this pull request as draft March 3, 2025 23:16
Comment on lines 16 to 17
import com.jetbrains.python.packaging.management.PythonPackageManager
import com.jetbrains.python.sdk.PythonSdkUtil
Copy link
Contributor

Choose a reason for hiding this comment

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

with this service we should define a generic interface that is registered with the extension point system and register them dynamically through optional depends. otherwise this will all fail if user is missing the java/python plugin

val dependencies = mutableListOf<String>()

PythonSdkUtil.findPythonSdk(module)?.let { sdk ->
val packageManager = PythonPackageManager.forSdk(module.project, sdk)

Check warning

Code scanning / QDJVMC

Unstable API Usage Warning

'com.jetbrains.python.packaging.management.PythonPackageManager.Companion' is declared in unstable 'com.jetbrains.python.packaging.management.PythonPackageManager' marked with @ApiStatus.Experimental
val dependencies = mutableListOf<String>()

PythonSdkUtil.findPythonSdk(module)?.let { sdk ->
val packageManager = PythonPackageManager.forSdk(module.project, sdk)

Check warning

Code scanning / QDJVMC

Unstable API Usage Warning

'forSdk(com.intellij.openapi.project.Project, com.intellij.openapi.projectRoots.Sdk)' is declared in unstable 'com.jetbrains.python.packaging.management.PythonPackageManager' marked with @ApiStatus.Experimental

PythonSdkUtil.findPythonSdk(module)?.let { sdk ->
val packageManager = PythonPackageManager.forSdk(module.project, sdk)
packageManager.installedPackages.forEach { pkg ->

Check warning

Code scanning / QDJVMC

Unstable API Usage Warning

'getInstalledPackages()' is declared in unstable 'com.jetbrains.python.packaging.management.PythonPackageManager' marked with @ApiStatus.Experimental
Comment on lines 19 to 21
<depends optional="true" config-file="java-support.xml">com.intellij.modules.java</depends>
<depends optional="true" config-file="python-support.xml">com.intellij.modules.python</depends>

Copy link
Contributor

Choose a reason for hiding this comment

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

depends should be on top-level plugin.xml, so use existing amazon-ext-java.xml

@samgst-amazon samgst-amazon marked this pull request as ready for review March 7, 2025 17:15
Comment on lines 38 to 43
CompletableFuture<Unit>().also { completableFuture ->
AmazonQLspService.executeIfRunning(project) { languageServer ->
languageServer.syncModuleDependencies(params)
completableFuture.complete(null)
} ?: completableFuture.completeExceptionally(IllegalStateException("LSP Server not running"))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

simplifies to

Suggested change
CompletableFuture<Unit>().also { completableFuture ->
AmazonQLspService.executeIfRunning(project) { languageServer ->
languageServer.syncModuleDependencies(params)
completableFuture.complete(null)
} ?: completableFuture.completeExceptionally(IllegalStateException("LSP Server not running"))
}
AmazonQLspService.executeIfRunning(project) { languageServer ->
languageServer.syncModuleDependencies(params)
}?.toCompletableFuture() ?: CompletableFuture.failedFuture(IllegalStateException("LSP Server not running"))

import java.util.concurrent.CompletableFuture

/**
* Remote interface exposed by the Amazon Q language server
*/
@Suppress("unused")
interface AmazonQLanguageServer : LanguageServer {
@JsonRequest("aws/syncModuleDependencies")
Copy link
Contributor

Choose a reason for hiding this comment

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

could you see if @JsonNotification works

@samgst-amazon samgst-amazon merged commit ac81a2f into feature/q-lsp Mar 7, 2025
15 of 18 checks passed
@samgst-amazon samgst-amazon deleted the samgst/q-lsp-module-dependencies branch March 7, 2025 21:04
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