-
Notifications
You must be signed in to change notification settings - Fork 274
feat(amazonq): Implement aws/syncModuleDependencies call #5414
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
Changes from 13 commits
9d71b4c
1f1c2ac
f92ab4d
58e3ea2
060f64a
63eb25c
f5f4c87
10ddb2d
44c794e
90d5365
9edbfac
b9ba38f
a461559
5ff55ca
b2d5cc3
a1c08a5
f254b7a
c9d7ab3
7b77a6f
3263ac9
7e74c9e
e35e956
d14bfe4
2edaba4
6d9eb85
db03df1
2fd9ee6
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,129 @@ | ||||||||||||||||||||
| // Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||||||||||||||||||||
| // SPDX-License-Identifier: Apache-2.0 | ||||||||||||||||||||
|
|
||||||||||||||||||||
| package software.aws.toolkits.jetbrains.services.amazonq.lsp.dependencies | ||||||||||||||||||||
|
|
||||||||||||||||||||
| import com.intellij.openapi.Disposable | ||||||||||||||||||||
| import com.intellij.openapi.module.Module | ||||||||||||||||||||
|
||||||||||||||||||||
| import com.intellij.openapi.module.ModuleManager | ||||||||||||||||||||
| import com.intellij.openapi.project.Project | ||||||||||||||||||||
| import com.intellij.openapi.projectRoots.JavaSdkType | ||||||||||||||||||||
| import com.intellij.openapi.roots.ModuleRootEvent | ||||||||||||||||||||
| import com.intellij.openapi.roots.ModuleRootListener | ||||||||||||||||||||
| import com.intellij.openapi.roots.ModuleRootManager | ||||||||||||||||||||
|
||||||||||||||||||||
| import com.intellij.openapi.roots.OrderRootType | ||||||||||||||||||||
|
||||||||||||||||||||
| import com.intellij.openapi.vfs.VfsUtil | ||||||||||||||||||||
|
||||||||||||||||||||
| import com.jetbrains.python.packaging.management.PythonPackageManager | ||||||||||||||||||||
|
||||||||||||||||||||
| import com.jetbrains.python.sdk.PythonSdkUtil | ||||||||||||||||||||
|
||||||||||||||||||||
| import software.aws.toolkits.jetbrains.services.amazonq.lsp.AmazonQLspService | ||||||||||||||||||||
| import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.dependencies.SyncModuleDependenciesParams | ||||||||||||||||||||
| import java.util.concurrent.CompletableFuture | ||||||||||||||||||||
|
|
||||||||||||||||||||
| class DefaultModuleDependenciesService( | ||||||||||||||||||||
| private val project: Project, | ||||||||||||||||||||
| serverInstance: Disposable, | ||||||||||||||||||||
| ) : ModuleDependenciesService, | ||||||||||||||||||||
| ModuleRootListener { | ||||||||||||||||||||
|
|
||||||||||||||||||||
| init { | ||||||||||||||||||||
| project.messageBus.connect(serverInstance).subscribe( | ||||||||||||||||||||
| ModuleRootListener.TOPIC, | ||||||||||||||||||||
| this | ||||||||||||||||||||
| ) | ||||||||||||||||||||
| // project initiation with initial list of dependencies | ||||||||||||||||||||
| syncAllModules() | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| override fun rootsChanged(event: ModuleRootEvent) { | ||||||||||||||||||||
| if (event.isCausedByFileTypesChange) return | ||||||||||||||||||||
| // call on change with updated dependencies | ||||||||||||||||||||
| syncAllModules() | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| override fun syncModuleDependencies(params: SyncModuleDependenciesParams): CompletableFuture<Unit> = | ||||||||||||||||||||
| CompletableFuture<Unit>().also { completableFuture -> | ||||||||||||||||||||
| AmazonQLspService.executeIfRunning(project) { languageServer -> | ||||||||||||||||||||
| languageServer.syncModuleDependencies(params) | ||||||||||||||||||||
| completableFuture.complete(null) | ||||||||||||||||||||
| } ?: completableFuture.completeExceptionally(IllegalStateException("LSP Server not running")) | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
||||||||||||||||||||
| 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")) |
Fixed
Show fixed
Hide fixed
Fixed
Show fixed
Hide fixed
Check warning on line 114 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/dependencies/DefaultModuleDependenciesService.kt
GitHub Actions / Qodana Community for JVM
Unstable API Usage
'com.jetbrains.python.packaging.management.PythonPackageManager.Companion' is declared in unstable 'com.jetbrains.python.packaging.management.PythonPackageManager' marked with @ApiStatus.Experimental
Check warning on line 114 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/dependencies/DefaultModuleDependenciesService.kt
GitHub Actions / Qodana Community for JVM
Unstable API Usage
'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
Fixed
Show fixed
Hide fixed
Fixed
Show fixed
Hide fixed
Check warning on line 115 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/dependencies/DefaultModuleDependenciesService.kt
GitHub Actions / Qodana Community for JVM
Unstable API Usage
'getInstalledPackages()' is declared in unstable 'com.jetbrains.python.packaging.management.PythonPackageManager' marked with @ApiStatus.Experimental
Fixed
Show fixed
Hide fixed
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| // Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package software.aws.toolkits.jetbrains.services.amazonq.lsp.dependencies | ||
|
|
||
| import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.dependencies.SyncModuleDependenciesParams | ||
| import java.util.concurrent.CompletableFuture | ||
|
|
||
| interface ModuleDependenciesService { | ||
| fun syncModuleDependencies(params: SyncModuleDependenciesParams): CompletableFuture<Unit> | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| // Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.dependencies | ||
|
|
||
| public class SyncModuleDependenciesParams( | ||
|
Check warning on line 6 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/model/aws/dependencies/SyncModuleDependenciesParams.kt
|
||
|
||
| val moduleName: String, | ||
|
Check warning on line 7 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/model/aws/dependencies/SyncModuleDependenciesParams.kt
|
||
Check warningCode scanning / QDJVMC Unused symbol Warning
Property "moduleName" is never used
|
||
| val programmingLanguage: String, | ||
| val files: List<String>, | ||
| val dirs: List<String>, | ||
|
Check warning on line 10 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/model/aws/dependencies/SyncModuleDependenciesParams.kt
|
||
Check warningCode scanning / QDJVMC Unused symbol Warning
Property "dirs" is never used
|
||
| val includePatterns: List<String>, | ||
|
Check warning on line 11 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/model/aws/dependencies/SyncModuleDependenciesParams.kt
|
||
Check warningCode scanning / QDJVMC Unused symbol Warning
Property "includePatterns" is never used
|
||
| val excludePatterns: List<String>, | ||
|
Check warning on line 12 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/model/aws/dependencies/SyncModuleDependenciesParams.kt
|
||
Check warningCode scanning / QDJVMC Unused symbol Warning
Property "excludePatterns" is never used
|
||
| ) | ||
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.
could you see if
@JsonNotificationworks