-
Notifications
You must be signed in to change notification settings - Fork 274
feat(amazonq): Implement aws/credentials/token messages #5410
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
Conversation
Qodana Community for JVMIt seems all right 👌 No new problems were found according to the checks applied 💡 Qodana analysis was run in the pull request mode: only the changed files were checked Contact Qodana teamContact us at [email protected]
|
| return CompletableFuture<ResponseMessage>().also { completableFuture -> | ||
| AmazonQLspService.executeIfRunning(project) { server -> | ||
| server.updateTokenCredentials(payload) | ||
| .whenComplete { response, throwable -> | ||
| if (throwable != null) { | ||
| completableFuture.completeExceptionally(throwable) | ||
| } else { | ||
| completableFuture.complete(response) | ||
| } | ||
| } | ||
| } ?: completableFuture.completeExceptionally(IllegalStateException("LSP Server not running")) | ||
| } | ||
| } |
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.
i think we can reduce the boilerplate to
| return CompletableFuture<ResponseMessage>().also { completableFuture -> | |
| AmazonQLspService.executeIfRunning(project) { server -> | |
| server.updateTokenCredentials(payload) | |
| .whenComplete { response, throwable -> | |
| if (throwable != null) { | |
| completableFuture.completeExceptionally(throwable) | |
| } else { | |
| completableFuture.complete(response) | |
| } | |
| } | |
| } ?: completableFuture.completeExceptionally(IllegalStateException("LSP Server not running")) | |
| } | |
| } | |
| return AmazonQLspService.executeIfRunning(project) { server -> | |
| server.updateTokenCredentials(payload) | |
| } ?: CompletableFuture.failedFuture(IllegalStateException("LSP Server not running")) |
then redefine the execute methods with type generics
suspend fun<T> execute(runnable: suspend (AmazonQLanguageServer) -> T): T {
val lsp = withTimeout(10.seconds) {
val holder = mutex.withLock { instance }.await()
holder.initializer.join()
holder.languageServer
}
return runnable(lsp)
}
fun<T> executeSync(runnable: suspend (AmazonQLanguageServer) -> T): T =
runBlocking(cs.coroutineContext) {
execute(runnable)
}| fun updateTokenCredentials(payload: UpdateCredentialsPayload): CompletableFuture<ResponseMessage> | ||
|
|
||
| @JsonNotification("aws/credentials/token/delete") | ||
| fun deleteTokenCredentials() |
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.
| fun deleteTokenCredentials() | |
| fun deleteTokenCredentials(): CompletableFuture<Void> |
should it also return a future?
| fun updateTokenCredentials(accessToken: String, encrypted: Boolean): CompletableFuture<ResponseMessage> | ||
| fun deleteTokenCredentials(): CompletableFuture<Unit> |
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.
im assuming hooking these up will be a followup?
* implement aws/credentials/token messages * detekt * feedback
Added service handlers for aws/credential messages.
Types of changes
Description
Implemented credential service class to invoke messaging the LSP server for token updates and token deletion.
Checklist
License
I confirm that my contribution is made under the terms of the Apache 2.0 license.