-
Notifications
You must be signed in to change notification settings - Fork 223
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
Replace old actions with new actions that have configurable key bindings #4914
Changes from all commits
357fa36
42dce38
64304f7
6043c8e
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,36 @@ | ||
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package software.aws.toolkits.jetbrains.services.codewhisperer.actions | ||
|
||
import com.intellij.openapi.actionSystem.ActionUpdateThread | ||
import com.intellij.openapi.actionSystem.AnAction | ||
import com.intellij.openapi.actionSystem.AnActionEvent | ||
import com.intellij.openapi.actionSystem.CommonDataKeys | ||
import com.intellij.openapi.application.ApplicationManager | ||
import com.intellij.openapi.project.DumbAware | ||
import software.aws.toolkits.jetbrains.services.codewhisperer.model.SessionContext | ||
import software.aws.toolkits.jetbrains.services.codewhisperer.popup.CodeWhispererPopupManager | ||
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererInvocationStatus | ||
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererService | ||
import software.aws.toolkits.resources.message | ||
|
||
open class CodeWhispererAcceptAction(title: String = message("codewhisperer.inline.accept")) : AnAction(title), DumbAware { | ||
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. make sealed and move the force action here since there is no difference except the key binding? 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. ok 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. It seems like I can't make CodeWhispererAcceptAction as sealed class because I will be getting this error:
|
||
override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.EDT | ||
|
||
override fun update(e: AnActionEvent) { | ||
e.presentation.isEnabled = e.project != null && e.getData(CommonDataKeys.EDITOR) != null && | ||
CodeWhispererInvocationStatus.getInstance().isDisplaySessionActive() | ||
} | ||
|
||
override fun actionPerformed(e: AnActionEvent) { | ||
val sessionContext = e.project?.getUserData(CodeWhispererService.KEY_SESSION_CONTEXT) ?: return | ||
if (!CodeWhispererInvocationStatus.getInstance().isDisplaySessionActive()) return | ||
ApplicationManager.getApplication().messageBus.syncPublisher( | ||
CodeWhispererPopupManager.CODEWHISPERER_USER_ACTION_PERFORMED | ||
).beforeAccept(sessionContext) | ||
} | ||
} | ||
|
||
// A same accept action but different key shortcut and different promoter logic | ||
class CodeWhispererForceAcceptAction(title: String = message("codewhisperer.inline.force.accept")) : CodeWhispererAcceptAction(title) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package software.aws.toolkits.jetbrains.services.codewhisperer.actions | ||
|
||
import com.intellij.openapi.actionSystem.ActionUpdateThread | ||
import com.intellij.openapi.actionSystem.AnAction | ||
import com.intellij.openapi.actionSystem.AnActionEvent | ||
import com.intellij.openapi.actionSystem.CommonDataKeys | ||
import com.intellij.openapi.application.ApplicationManager | ||
import com.intellij.openapi.project.DumbAware | ||
import software.aws.toolkits.jetbrains.services.codewhisperer.popup.CodeWhispererPopupManager | ||
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererInvocationStatus | ||
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererService | ||
import software.aws.toolkits.resources.message | ||
|
||
class CodeWhispererNavigateNextAction : AnAction(message("codewhisperer.inline.navigate.next")), DumbAware { | ||
override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.EDT | ||
|
||
override fun update(e: AnActionEvent) { | ||
e.presentation.isEnabled = e.project != null && | ||
e.getData(CommonDataKeys.EDITOR) != null && | ||
CodeWhispererInvocationStatus.getInstance().isDisplaySessionActive() | ||
} | ||
|
||
override fun actionPerformed(e: AnActionEvent) { | ||
val sessionContext = e.project?.getUserData(CodeWhispererService.KEY_SESSION_CONTEXT) ?: return | ||
if (!CodeWhispererInvocationStatus.getInstance().isDisplaySessionActive()) return | ||
ApplicationManager.getApplication().messageBus.syncPublisher( | ||
CodeWhispererPopupManager.CODEWHISPERER_USER_ACTION_PERFORMED | ||
).navigateNext(sessionContext) | ||
Comment on lines
+29
to
+31
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. not related to this PR tho, i feel we could make this messagebus a project level 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. prob doesn't matter since we aren't going to have multple display sessions across different projects |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package software.aws.toolkits.jetbrains.services.codewhisperer.actions | ||
|
||
import com.intellij.openapi.actionSystem.ActionUpdateThread | ||
import com.intellij.openapi.actionSystem.AnAction | ||
import com.intellij.openapi.actionSystem.AnActionEvent | ||
import com.intellij.openapi.actionSystem.CommonDataKeys | ||
import com.intellij.openapi.application.ApplicationManager | ||
import com.intellij.openapi.project.DumbAware | ||
import software.aws.toolkits.jetbrains.services.codewhisperer.popup.CodeWhispererPopupManager | ||
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererInvocationStatus | ||
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererService | ||
import software.aws.toolkits.resources.message | ||
|
||
class CodeWhispererNavigatePrevAction : AnAction(message("codewhisperer.inline.navigate.previous")), DumbAware { | ||
override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.EDT | ||
|
||
override fun update(e: AnActionEvent) { | ||
e.presentation.isEnabled = e.project != null && | ||
e.getData(CommonDataKeys.EDITOR) != null && | ||
CodeWhispererInvocationStatus.getInstance().isDisplaySessionActive() | ||
} | ||
|
||
override fun actionPerformed(e: AnActionEvent) { | ||
val sessionContext = e.project?.getUserData(CodeWhispererService.KEY_SESSION_CONTEXT) ?: return | ||
if (!CodeWhispererInvocationStatus.getInstance().isDisplaySessionActive()) return | ||
ApplicationManager.getApplication().messageBus.syncPublisher( | ||
CodeWhispererPopupManager.CODEWHISPERER_USER_ACTION_PERFORMED | ||
).navigatePrevious(sessionContext) | ||
} | ||
} |
This file was deleted.
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'm a bit worried about the interaction between this and the IDE
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.
The logic will be what the promoter does -- when the CW is showing:
CodeWhispererInvocationStatus.getInstance().isDisplaySessionActive()
it will be promoted to CW accept.
Otherwise it will be IDE tab action.