Skip to content

Commit d5a962f

Browse files
authored
Merge branch 'main' into vchikoti/samWizardTest
2 parents 65e6888 + 9e3760e commit d5a962f

File tree

8 files changed

+40
-41
lines changed

8 files changed

+40
-41
lines changed

.changes/3.53.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"date" : "2025-02-07",
3+
"version" : "3.53",
4+
"entries" : [ {
5+
"type" : "bugfix",
6+
"description" : "Amazon Q: Fixed an issue where in a specific scenario when receiving multiple suggestions with JetBrains suggestions visible, users are not able to accept the suggestion."
7+
} ]
8+
}

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# _3.53_ (2025-02-07)
2+
- **(Bug Fix)** Amazon Q: Fixed an issue where in a specific scenario when receiving multiple suggestions with JetBrains suggestions visible, users are not able to accept the suggestion.
3+
14
# _3.52_ (2025-02-06)
25
- **(Feature)** Adds event listener for notifying UI that AB feature configurations have been resolved
36
- **(Feature)** Amazon Q /review: Code issues can now be grouped by severity or file location.

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.53-SNAPSHOT
5+
toolkitVersion=3.54-SNAPSHOT
66

77
# Publish Settings
88
publishToken=

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/constants/CodeTransformChatItems.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,12 +284,11 @@ fun buildLanguageUpgradeProjectValidChatContent() = CodeTransformChatMessageCont
284284

285285
fun buildProjectInvalidChatContent(validationResult: ValidationResult): CodeTransformChatMessageContent {
286286
val errorMessage = when (validationResult.invalidTelemetryReason.category) {
287-
CodeTransformPreValidationError.NoPom -> message("codemodernizer.chat.message.validation.error.no_pom", CODE_TRANSFORM_PREREQUISITES)
288-
CodeTransformPreValidationError.UnsupportedJavaVersion -> message("codemodernizer.chat.message.validation.error.unsupported_java_version")
287+
CodeTransformPreValidationError.UnsupportedJavaVersion, CodeTransformPreValidationError.UnsupportedBuildSystem ->
288+
message("codemodernizer.chat.message.validation.error.unsupported_module")
289289
CodeTransformPreValidationError.RemoteRunProject -> message("codemodernizer.notification.warn.invalid_project.description.reason.remote_backend")
290290
CodeTransformPreValidationError.NonSsoLogin -> message("codemodernizer.notification.warn.invalid_project.description.reason.not_logged_in")
291291
CodeTransformPreValidationError.EmptyProject -> message("codemodernizer.notification.warn.invalid_project.description.reason.missing_content_roots")
292-
CodeTransformPreValidationError.UnsupportedBuildSystem -> message("codemodernizer.chat.message.validation.error.no_pom")
293292
CodeTransformPreValidationError.NoJavaProject -> message("codemodernizer.chat.message.validation.error.no_java_project")
294293
CodeTransformPreValidationError.JavaDowngradeAttempt -> message("codemodernizer.chat.message.validation.error.downgrade_attempt")
295294
else -> message("codemodernizer.chat.message.validation.error.other")

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/popup/CodeWhispererPopupManager.kt

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,9 @@ import com.intellij.ui.popup.AbstractPopup
4141
import com.intellij.ui.popup.PopupFactoryImpl
4242
import com.intellij.util.messages.Topic
4343
import com.intellij.util.ui.UIUtil
44-
import kotlinx.coroutines.sync.Semaphore
4544
import software.amazon.awssdk.services.codewhispererruntime.model.Import
4645
import software.amazon.awssdk.services.codewhispererruntime.model.Reference
4746
import software.aws.toolkits.core.utils.debug
48-
import software.aws.toolkits.core.utils.error
4947
import software.aws.toolkits.core.utils.getLogger
5048
import software.aws.toolkits.jetbrains.services.codewhisperer.editor.CodeWhispererEditorManager
5149
import software.aws.toolkits.jetbrains.services.codewhisperer.layout.CodeWhispererLayoutConfig.addHorizontalGlue
@@ -88,8 +86,8 @@ import javax.swing.JLabel
8886
class CodeWhispererPopupManager {
8987
val popupComponents = CodeWhispererPopupComponents()
9088

91-
// Act like a semaphore: one increment only corresponds to one decrement
92-
var allowEditsDuringSuggestionPreview = Semaphore(MAX_EDIT_SOURCE_DURING_SUGGESTION_PREVIEW)
89+
var allowTypingDuringSuggestionPreview = false
90+
var allowIntelliSenseDuringSuggestionPreview = false
9391
var sessionContext = SessionContext()
9492
private set
9593

@@ -251,18 +249,11 @@ class CodeWhispererPopupManager {
251249

252250
// Don't want to block or throw any kinds of exceptions here if it can continue to provide suggestions
253251
fun dontClosePopupAndRun(runnable: () -> Unit) {
254-
if (allowEditsDuringSuggestionPreview.tryAcquire()) {
255-
try {
256-
runnable()
257-
} finally {
258-
try {
259-
allowEditsDuringSuggestionPreview.release()
260-
} catch (e: Exception) {
261-
LOG.error(e) { "Failed to release allowEditsDuringSuggestionPreview semaphore" }
262-
}
263-
}
264-
} else {
265-
LOG.error { "Failed to acquire allowEditsDuringSuggestionPreview semaphore" }
252+
try {
253+
allowTypingDuringSuggestionPreview = true
254+
runnable()
255+
} finally {
256+
allowTypingDuringSuggestionPreview = false
266257
}
267258
}
268259

@@ -511,7 +502,7 @@ class CodeWhispererPopupManager {
511502
val editor = states.requestContext.editor
512503
val codewhispererSelectionListener: SelectionListener = object : SelectionListener {
513504
override fun selectionChanged(event: SelectionEvent) {
514-
if (allowEditsDuringSuggestionPreview.availablePermits == MAX_EDIT_SOURCE_DURING_SUGGESTION_PREVIEW) {
505+
if (!allowTypingDuringSuggestionPreview && !allowIntelliSenseDuringSuggestionPreview) {
515506
cancelPopup(states.popup)
516507
}
517508
super.selectionChanged(event)
@@ -527,7 +518,7 @@ class CodeWhispererPopupManager {
527518
if (!delete) return
528519
if (editor.caretModel.offset == event.offset) {
529520
changeStates(states, 0)
530-
} else if (allowEditsDuringSuggestionPreview.availablePermits == MAX_EDIT_SOURCE_DURING_SUGGESTION_PREVIEW) {
521+
} else if (!allowTypingDuringSuggestionPreview && !allowIntelliSenseDuringSuggestionPreview) {
531522
cancelPopup(states.popup)
532523
}
533524
}
@@ -536,7 +527,7 @@ class CodeWhispererPopupManager {
536527

537528
val codewhispererCaretListener: CaretListener = object : CaretListener {
538529
override fun caretPositionChanged(event: CaretEvent) {
539-
if (allowEditsDuringSuggestionPreview.availablePermits == MAX_EDIT_SOURCE_DURING_SUGGESTION_PREVIEW) {
530+
if (!allowTypingDuringSuggestionPreview && !allowIntelliSenseDuringSuggestionPreview) {
540531
cancelPopup(states.popup)
541532
}
542533
super.caretPositionChanged(event)

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/popup/listeners/CodeWhispererPopupIntelliSenseAcceptListener.kt

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ import com.intellij.codeInsight.lookup.LookupEvent
88
import com.intellij.codeInsight.lookup.LookupListener
99
import com.intellij.codeInsight.lookup.LookupManagerListener
1010
import com.intellij.codeInsight.lookup.impl.LookupImpl
11-
import software.aws.toolkits.core.utils.error
11+
import com.intellij.openapi.util.Disposer
1212
import software.aws.toolkits.core.utils.getLogger
1313
import software.aws.toolkits.jetbrains.services.codewhisperer.model.InvocationContext
1414
import software.aws.toolkits.jetbrains.services.codewhisperer.popup.CodeWhispererPopupManager
15-
import software.aws.toolkits.jetbrains.services.codewhisperer.popup.listeners.CodeWhispererPopupIntelliSenseAcceptListener.Companion.LOG
1615
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererInvocationStatus
1716

1817
class CodeWhispererPopupIntelliSenseAcceptListener(private val states: InvocationContext) : LookupManagerListener {
@@ -28,10 +27,8 @@ class CodeWhispererPopupIntelliSenseAcceptListener(private val states: Invocatio
2827
}
2928

3029
fun addIntelliSenseAcceptListener(lookup: Lookup, states: InvocationContext) {
31-
if (!CodeWhispererPopupManager.getInstance().allowEditsDuringSuggestionPreview.tryAcquire()) {
32-
LOG.error { "Failed to acquire allowEditsDuringSuggestionPreview semaphore" }
33-
}
34-
lookup.addLookupListener(object : LookupListener {
30+
CodeWhispererPopupManager.getInstance().allowIntelliSenseDuringSuggestionPreview = true
31+
val listener = object : LookupListener {
3532
override fun itemSelected(event: LookupEvent) {
3633
if (!CodeWhispererInvocationStatus.getInstance().isDisplaySessionActive() ||
3734
!(event.lookup as LookupImpl).isShown
@@ -52,11 +49,12 @@ fun addIntelliSenseAcceptListener(lookup: Lookup, states: InvocationContext) {
5249

5350
private fun cleanup() {
5451
lookup.removeLookupListener(this)
55-
try {
56-
CodeWhispererPopupManager.getInstance().allowEditsDuringSuggestionPreview.release()
57-
} catch (e: Exception) {
58-
LOG.error(e) { "Failed to release allowEditsDuringSuggestionPreview semaphore" }
59-
}
52+
CodeWhispererPopupManager.getInstance().allowIntelliSenseDuringSuggestionPreview = false
6053
}
61-
})
54+
}
55+
lookup.addLookupListener(listener)
56+
Disposer.register(states) {
57+
lookup.removeLookupListener(listener)
58+
CodeWhispererPopupManager.getInstance().allowIntelliSenseDuringSuggestionPreview = false
59+
}
6260
}

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererUserModificationTracker.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class CodeWhispererUserModificationTracker(private val project: Project) : Dispo
135135
}
136136

137137
private fun emitTelemetryOnChatCodeInsert(insertedCode: InsertedCodeModificationEntry) {
138-
try {
138+
val modificationPercentage = try {
139139
val file = insertedCode.vFile
140140
if (file == null || (!file.isValid)) throw Exception("Record OnChatCodeInsert - invalid file")
141141

@@ -145,11 +145,12 @@ class CodeWhispererUserModificationTracker(private val project: Project) : Dispo
145145
val currentString = document?.getText(
146146
TextRange(insertedCode.range.startOffset, insertedCode.range.endOffset)
147147
)
148-
val modificationPercentage = checkDiff(currentString?.trim(), insertedCode.originalString.trim())
149-
sendModificationWithChatTelemetry(insertedCode, modificationPercentage)
148+
checkDiff(currentString?.trim(), insertedCode.originalString.trim())
150149
} catch (e: Exception) {
151-
sendModificationWithChatTelemetry(insertedCode, null)
150+
null
152151
}
152+
153+
sendModificationWithChatTelemetry(insertedCode, modificationPercentage)
153154
}
154155

155156
private fun emitTelemetryOnSuggestion(acceptedSuggestion: AcceptedSuggestionEntry) {

plugins/core/resources/resources/software/aws/toolkits/resources/MessagesBundle.properties

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -703,9 +703,8 @@ codemodernizer.chat.message.validation.error.invalid_target_db=I can only conver
703703
codemodernizer.chat.message.validation.error.missing_sct_file=An .sct file is required for transformation. Make sure that you've uploaded the .zip file you retrieved from your schema conversion in AWS DMS.
704704
codemodernizer.chat.message.validation.error.more_info=For more information, see the [Amazon Q documentation]({0}).
705705
codemodernizer.chat.message.validation.error.no_java_project=Sorry, I could not find an open Java module with embedded Oracle SQL statements. Make sure you have a Java module open that has at least 1 content root.
706-
codemodernizer.chat.message.validation.error.no_pom=I couldn't find a module that I can upgrade. Your Java project must be built on Maven and contain a pom.xml file. For more information, see the [Amazon Q documentation]({0}).
707706
codemodernizer.chat.message.validation.error.other=I couldn't find a module that I can upgrade. Currently, I support Java 8, Java 11, Java 17, and Java 21 projects built on Maven. Make sure your project is open in the IDE. If you have a Java 8, Java 11, Java 17, or Java 21 module in your workspace, you might need to configure your project so that I can find it. Go to File and choose Project Structure. In the Projects tab, set the correct project JDK and the correct language level. In the Modules tab, set the correct module JDK and language level.
708-
codemodernizer.chat.message.validation.error.unsupported_java_version=I couldn't find a module that I can upgrade. Currently, I support Java 8, Java 11, Java 17, and Java 21 projects built on Maven. Make sure your project is open in the IDE. If you have a Java 8, Java 11, Java 17, or Java 21 in your workspace, you might need to configure your project so that I can find it. Go to File and choose Project Structure. In the Projects tab, set the correct project JDK and the correct language level. In the Modules tab, set the correct module JDK and language level.
707+
codemodernizer.chat.message.validation.error.unsupported_module=I couldn't find a module that I can upgrade. Currently, I support Java 8, Java 11, Java 17, and Java 21 projects built on Maven. Make sure your project is open in the IDE. If you have a Java 8, Java 11, Java 17, or Java 21 in your workspace, you might need to configure your project so that I can find it. Go to File and choose Project Structure. In the Projects tab, set the correct project JDK and the correct language level. In the Modules tab, set the correct module JDK and language level.
709708
codemodernizer.chat.message.validation.no_jdk=I couldn't build your project with your current JDK configuration. To update your JDK, go to File and choose Project Structure. In the Projects tab, set the correct project JDK in the SDK field. In the Modules tab, set the correct module JDK in the SDK field. In Maven Runner settings, set the correct JDK in the JRE field.
710709
codemodernizer.chat.prompt.label.dependency_current_version=Current version
711710
codemodernizer.chat.prompt.label.dependency_name=Dependency name

0 commit comments

Comments
 (0)