Skip to content

Commit a8733d5

Browse files
committed
Merge remote-tracking branch 'upstream/main' into move-1
2 parents db1f787 + 6af6a46 commit a8733d5

File tree

56 files changed

+3650
-124
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+3650
-124
lines changed

.changes/3.33.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"date" : "2024-10-17",
3+
"version" : "3.33",
4+
"entries" : [ {
5+
"type" : "feature",
6+
"description" : "Add support for 2024.3"
7+
}, {
8+
"type" : "bugfix",
9+
"description" : "`@workspace` cannot properly locate certain folders for certain project setup"
10+
}, {
11+
"type" : "bugfix",
12+
"description" : "Fix an IDE deadlock that may occur while attempting to initialize Amazon Q UI elements (#4966)"
13+
} ]
14+
}

.changes/next-release/bugfix-bcf4a2c9-230b-440b-93ed-8b2fb96929be.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

.changes/next-release/feature-dd281d60-2902-47d0-b7d6-bf0bd6225abd.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# _3.33_ (2024-10-17)
2+
- **(Feature)** Add support for 2024.3
3+
- **(Bug Fix)** `@workspace` cannot properly locate certain folders for certain project setup
4+
- **(Bug Fix)** Fix an IDE deadlock that may occur while attempting to initialize Amazon Q UI elements ([#4966](https://github.com/aws/aws-toolkit-jetbrains/issues/4966))
5+
16
# _3.32_ (2024-10-10)
27
- **(Feature)** Loosen inline completion support limitations for YAML/JSON
38
- **(Bug Fix)** Fix error occuring when Amazon Q attempts to show UI hints on manually triggerred inline suggestion ([#4929](https://github.com/aws/aws-toolkit-jetbrains/issues/4929))

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
# Toolkit Version
5-
toolkitVersion=3.33-SNAPSHOT
5+
toolkitVersion=3.34-SNAPSHOT
66

77
# Publish Settings
88
publishToken=

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/editor/context/project/ProjectContextProvider.kt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import com.fasterxml.jackson.annotation.JsonProperty
88
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
99
import com.fasterxml.jackson.module.kotlin.readValue
1010
import com.intellij.openapi.Disposable
11+
import com.intellij.openapi.project.BaseProjectDirectories.Companion.getBaseDirectories
1112
import com.intellij.openapi.project.Project
12-
import com.intellij.openapi.project.guessProjectDir
1313
import com.intellij.openapi.vfs.VfsUtilCore
1414
import com.intellij.openapi.vfs.VirtualFile
1515
import com.intellij.openapi.vfs.VirtualFileVisitor
@@ -130,7 +130,7 @@ class ProjectContextProvider(val project: Project, private val encoderServer: En
130130
}
131131

132132
private fun initEncryption(): Boolean {
133-
logger.info { "project context: init key for ${project.guessProjectDir()} on port ${encoderServer.port}" }
133+
logger.info { "project context: init key for ${project.name} on port ${encoderServer.port}" }
134134
val url = URL("http://localhost:${encoderServer.port}/initialize")
135135
val payload = encoderServer.getEncryptionRequest()
136136
val connection = url.openConnection() as HttpURLConnection
@@ -148,7 +148,7 @@ class ProjectContextProvider(val project: Project, private val encoderServer: En
148148
var duration = (System.currentTimeMillis() - indexStartTime).toDouble()
149149
logger.debug { "project context file collection time: ${duration}ms" }
150150
logger.debug { "list of files collected: ${filesResult.files.joinToString("\n")}" }
151-
val projectRoot = project.guessProjectDir()?.path ?: return false
151+
val projectRoot = project.basePath ?: return false
152152
val payload = IndexRequestPayload(filesResult.files, projectRoot, false)
153153
val payloadJson = mapper.writeValueAsString(payload)
154154
val encrypted = encoderServer.encrypt(payloadJson)
@@ -162,7 +162,15 @@ class ProjectContextProvider(val project: Project, private val encoderServer: En
162162
logger.debug { "project context index time: ${duration}ms" }
163163
if (connection.responseCode == 200) {
164164
val usage = getUsage()
165-
TelemetryHelper.recordIndexWorkspace(duration, filesResult.files.size, filesResult.fileSize, true, usage?.memoryUsage, usage?.cpuUsage, startUrl)
165+
TelemetryHelper.recordIndexWorkspace(
166+
duration,
167+
filesResult.files.size,
168+
filesResult.fileSize,
169+
true,
170+
usage?.memoryUsage?.div(1024 * 1024),
171+
usage?.cpuUsage,
172+
startUrl
173+
)
166174
logger.debug { "project context index finished for ${project.name}" }
167175
return true
168176
} else {
@@ -275,7 +283,7 @@ class ProjectContextProvider(val project: Project, private val encoderServer: En
275283
var currentTotalFileSize = 0L
276284
val featureDevSessionContext = FeatureDevSessionContext(project)
277285
val allFiles = mutableListOf<VirtualFile>()
278-
project.guessProjectDir()?.let {
286+
project.getBaseDirectories().forEach {
279287
VfsUtilCore.visitChildrenRecursively(
280288
it,
281289
object : VirtualFileVisitor<Unit>(NO_FOLLOW_SYMLINKS) {

plugins/amazonq/codewhisperer/jetbrains-community/resources/META-INF/plugin-codewhisperer.xml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55
<applicationListeners>
66
<listener class="software.aws.toolkits.jetbrains.services.codewhisperer.popup.CodeWhispererUIChangeListener"
77
topic="software.aws.toolkits.jetbrains.services.codewhisperer.popup.CodeWhispererPopupStateChangeListener"/>
8+
<listener class="software.aws.toolkits.jetbrains.services.codewhisperer.popup.CodeWhispererUIChangeListenerNew"
9+
topic="software.aws.toolkits.jetbrains.services.codewhisperer.popup.CodeWhispererPopupStateChangeListener"/>
810
<listener class="software.aws.toolkits.jetbrains.services.codewhisperer.toolwindow.CodeWhispererCodeReferenceActionListener"
911
topic="software.aws.toolkits.jetbrains.services.codewhisperer.popup.CodeWhispererUserActionListener"/>
12+
<listener class="software.aws.toolkits.jetbrains.services.codewhisperer.toolwindow.CodeWhispererCodeReferenceActionListenerNew"
13+
topic="software.aws.toolkits.jetbrains.services.codewhisperer.popup.CodeWhispererUserActionListener"/>
1014
</applicationListeners>
1115

1216
<projectListeners>
@@ -81,9 +85,32 @@
8185
</group>
8286

8387
<action class="software.aws.toolkits.jetbrains.services.codewhisperer.actions.CodeWhispererRecommendationAction"
84-
text="Show Code Suggestions">
88+
text="Invoke Amazon Q Inline Suggestions">
8589
<keyboard-shortcut keymap="$default" first-keystroke="alt C"/>
8690
</action>
91+
<action id="codewhisperer.inline.navigate.previous"
92+
class="software.aws.toolkits.jetbrains.services.codewhisperer.actions.CodeWhispererNavigatePrevAction"
93+
text="Navigate to Previous Inline Suggestion" description="Navigate to previous inline suggestion">
94+
<keyboard-shortcut keymap="$default" first-keystroke="alt OPEN_BRACKET"/>
95+
</action>
96+
<action id="codewhisperer.inline.navigate.next"
97+
class="software.aws.toolkits.jetbrains.services.codewhisperer.actions.CodeWhispererNavigateNextAction"
98+
text="Navigate to Next Inline Suggestion" description="Navigate to next inline suggestion">
99+
<keyboard-shortcut keymap="$default" first-keystroke="alt CLOSE_BRACKET"/>
100+
</action>
101+
<action id="codewhisperer.inline.accept"
102+
class="software.aws.toolkits.jetbrains.services.codewhisperer.actions.CodeWhispererAcceptAction"
103+
text="Accept the Current Inline Suggestion" description="Accept the current inline suggestions">
104+
<keyboard-shortcut keymap="$default" first-keystroke="TAB"/>
105+
</action>
106+
<action id="codewhisperer.inline.force.accept"
107+
class="software.aws.toolkits.jetbrains.services.codewhisperer.actions.CodeWhispererForceAcceptAction"
108+
text="Force Accept the Current Inline Suggestion" description="Force accept the current inline suggestion">
109+
<keyboard-shortcut keymap="Mac OS X" first-keystroke="alt TAB"/>
110+
<keyboard-shortcut keymap="Mac OS X 10.5+" first-keystroke="alt TAB"/>
111+
<keyboard-shortcut keymap="$default" first-keystroke="alt ENTER"/>
112+
</action>
113+
87114
<group id="aws.toolkit.codewhisperer.toolbar.security">
88115
<action
89116
id="codewhisperer.toolbar.security.scan"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package software.aws.toolkits.jetbrains.services.codewhisperer.actions
5+
6+
import com.intellij.openapi.actionSystem.ActionUpdateThread
7+
import com.intellij.openapi.actionSystem.AnAction
8+
import com.intellij.openapi.actionSystem.AnActionEvent
9+
import com.intellij.openapi.actionSystem.CommonDataKeys
10+
import com.intellij.openapi.application.ApplicationManager
11+
import com.intellij.openapi.project.DumbAware
12+
import software.aws.toolkits.jetbrains.services.codewhisperer.popup.CodeWhispererPopupManager
13+
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererInvocationStatusNew
14+
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererServiceNew
15+
import software.aws.toolkits.resources.message
16+
17+
open class CodeWhispererAcceptAction(title: String = message("codewhisperer.inline.accept")) : AnAction(title), DumbAware {
18+
override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.EDT
19+
20+
override fun update(e: AnActionEvent) {
21+
e.presentation.isEnabled = e.project != null && e.getData(CommonDataKeys.EDITOR) != null &&
22+
CodeWhispererInvocationStatusNew.getInstance().isDisplaySessionActive()
23+
}
24+
25+
override fun actionPerformed(e: AnActionEvent) {
26+
val sessionContext = e.project?.getUserData(CodeWhispererServiceNew.KEY_SESSION_CONTEXT) ?: return
27+
if (!CodeWhispererInvocationStatusNew.getInstance().isDisplaySessionActive()) return
28+
ApplicationManager.getApplication().messageBus.syncPublisher(
29+
CodeWhispererPopupManager.CODEWHISPERER_USER_ACTION_PERFORMED
30+
).beforeAccept(sessionContext)
31+
}
32+
}
33+
34+
// A same accept action but different key shortcut and different promoter logic
35+
class CodeWhispererForceAcceptAction(title: String = message("codewhisperer.inline.force.accept")) : CodeWhispererAcceptAction(title)

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/actions/CodeWhispererActionPromoter.kt

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,46 @@
33

44
package software.aws.toolkits.jetbrains.services.codewhisperer.actions
55

6+
import com.intellij.codeInsight.lookup.impl.actions.ChooseItemAction
67
import com.intellij.openapi.actionSystem.ActionPromoter
78
import com.intellij.openapi.actionSystem.AnAction
89
import com.intellij.openapi.actionSystem.DataContext
910
import com.intellij.openapi.editor.actionSystem.EditorAction
1011
import software.aws.toolkits.jetbrains.services.codewhisperer.popup.handlers.CodeWhispererPopupLeftArrowHandler
1112
import software.aws.toolkits.jetbrains.services.codewhisperer.popup.handlers.CodeWhispererPopupRightArrowHandler
1213
import software.aws.toolkits.jetbrains.services.codewhisperer.popup.handlers.CodeWhispererPopupTabHandler
14+
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererFeatureConfigService
15+
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererInvocationStatusNew
1316

1417
class CodeWhispererActionPromoter : ActionPromoter {
1518
override fun promote(actions: MutableList<out AnAction>, context: DataContext): MutableList<AnAction> {
19+
if (CodeWhispererFeatureConfigService.getInstance().getNewAutoTriggerUX()) {
20+
val results = actions.toMutableList()
21+
if (!CodeWhispererInvocationStatusNew.getInstance().isDisplaySessionActive()) return results
22+
23+
results.sortWith { a, b ->
24+
if (isCodeWhispererForceAction(a)) {
25+
return@sortWith -1
26+
} else if (isCodeWhispererForceAction(b)) {
27+
return@sortWith 1
28+
}
29+
30+
if (a is ChooseItemAction) {
31+
return@sortWith -1
32+
} else if (b is ChooseItemAction) {
33+
return@sortWith 1
34+
}
35+
36+
if (isCodeWhispererAcceptAction(a)) {
37+
return@sortWith -1
38+
} else if (isCodeWhispererAcceptAction(b)) {
39+
return@sortWith 1
40+
}
41+
42+
0
43+
}
44+
return results
45+
}
1646
val results = actions.toMutableList()
1747
results.sortWith { a, b ->
1848
if (isCodeWhispererPopupAction(a)) {
@@ -27,14 +57,28 @@ class CodeWhispererActionPromoter : ActionPromoter {
2757
}
2858

2959
private fun isCodeWhispererAcceptAction(action: AnAction): Boolean =
30-
action is EditorAction && action.handler is CodeWhispererPopupTabHandler
60+
if (CodeWhispererFeatureConfigService.getInstance().getNewAutoTriggerUX()) {
61+
action is CodeWhispererAcceptAction
62+
} else {
63+
action is EditorAction && action.handler is CodeWhispererPopupTabHandler
64+
}
65+
66+
private fun isCodeWhispererForceAcceptAction(action: AnAction): Boolean =
67+
action is CodeWhispererForceAcceptAction
3168

3269
private fun isCodeWhispererNavigateAction(action: AnAction): Boolean =
33-
action is EditorAction && (
34-
action.handler is CodeWhispererPopupRightArrowHandler ||
35-
action.handler is CodeWhispererPopupLeftArrowHandler
36-
)
70+
if (CodeWhispererFeatureConfigService.getInstance().getNewAutoTriggerUX()) {
71+
action is CodeWhispererNavigateNextAction || action is CodeWhispererNavigatePrevAction
72+
} else {
73+
action is EditorAction && (
74+
action.handler is CodeWhispererPopupRightArrowHandler ||
75+
action.handler is CodeWhispererPopupLeftArrowHandler
76+
)
77+
}
3778

3879
private fun isCodeWhispererPopupAction(action: AnAction): Boolean =
3980
isCodeWhispererAcceptAction(action) || isCodeWhispererNavigateAction(action)
81+
82+
private fun isCodeWhispererForceAction(action: AnAction): Boolean =
83+
isCodeWhispererForceAcceptAction(action) || isCodeWhispererNavigateAction(action)
4084
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package software.aws.toolkits.jetbrains.services.codewhisperer.actions
5+
6+
import com.intellij.openapi.actionSystem.ActionUpdateThread
7+
import com.intellij.openapi.actionSystem.AnAction
8+
import com.intellij.openapi.actionSystem.AnActionEvent
9+
import com.intellij.openapi.actionSystem.CommonDataKeys
10+
import com.intellij.openapi.application.ApplicationManager
11+
import com.intellij.openapi.project.DumbAware
12+
import software.aws.toolkits.jetbrains.services.codewhisperer.popup.CodeWhispererPopupManager
13+
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererInvocationStatusNew
14+
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererServiceNew
15+
import software.aws.toolkits.resources.message
16+
17+
class CodeWhispererNavigateNextAction : AnAction(message("codewhisperer.inline.navigate.next")), DumbAware {
18+
override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.EDT
19+
20+
override fun update(e: AnActionEvent) {
21+
e.presentation.isEnabled = e.project != null &&
22+
e.getData(CommonDataKeys.EDITOR) != null &&
23+
CodeWhispererInvocationStatusNew.getInstance().isDisplaySessionActive()
24+
}
25+
26+
override fun actionPerformed(e: AnActionEvent) {
27+
val sessionContext = e.project?.getUserData(CodeWhispererServiceNew.KEY_SESSION_CONTEXT) ?: return
28+
if (!CodeWhispererInvocationStatusNew.getInstance().isDisplaySessionActive()) return
29+
ApplicationManager.getApplication().messageBus.syncPublisher(
30+
CodeWhispererPopupManager.CODEWHISPERER_USER_ACTION_PERFORMED
31+
).navigateNext(sessionContext)
32+
}
33+
}

0 commit comments

Comments
 (0)