Skip to content

Commit 05b2ced

Browse files
authored
Merge branch 'main' into ai_gen
2 parents c8b29fe + fdfc07c commit 05b2ced

File tree

9 files changed

+79
-8
lines changed

9 files changed

+79
-8
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "bugfix",
3+
"description" : "/transform: use correct doc link in SQL conversion help message"
4+
}

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/controller/CodeTransformChatController.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import software.aws.toolkits.jetbrains.services.amazonq.auth.AuthController
2626
import software.aws.toolkits.jetbrains.services.amazonq.auth.AuthFollowUpType
2727
import software.aws.toolkits.jetbrains.services.codemodernizer.ArtifactHandler
2828
import software.aws.toolkits.jetbrains.services.codemodernizer.CodeModernizerManager
29+
import software.aws.toolkits.jetbrains.services.codemodernizer.CodeModernizerManager.Companion.LOG
2930
import software.aws.toolkits.jetbrains.services.codemodernizer.CodeTransformTelemetryManager
3031
import software.aws.toolkits.jetbrains.services.codemodernizer.EXPLAINABILITY_V1
3132
import software.aws.toolkits.jetbrains.services.codemodernizer.HilTelemetryMetaData
@@ -684,6 +685,7 @@ class CodeTransformChatController(
684685
)
685686

686687
private suspend fun handleCodeTransformResult(result: CodeModernizerJobCompletedResult) {
688+
LOG.info { "CodeModernizerJobCompletedResult: $result" }
687689
when (result) {
688690
is CodeModernizerJobCompletedResult.Stopped, CodeModernizerJobCompletedResult.JobAbortedBeforeStarting -> handleCodeTransformStoppedByUser()
689691
is CodeModernizerJobCompletedResult.JobFailed -> handleCodeTransformJobFailed(result.failureReason)
@@ -696,6 +698,7 @@ class CodeTransformChatController(
696698
CodeModernizerSessionState.getInstance(context.project).currentJobId as JobId,
697699
TransformationDownloadArtifactType.CLIENT_INSTRUCTIONS
698700
)
701+
LOG.info { "Download result: $downloadResult" }
699702
when (downloadResult) {
700703
is DownloadArtifactResult.Success -> {
701704
if (downloadResult.artifact !is CodeModernizerArtifact) return artifactHandler.notifyUnableToApplyPatch("")

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/codescan/CodeWhispererCodeScanManager.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,8 @@ class CodeWhispererCodeScanManager(val project: Project) {
475475
codeScanStatus,
476476
codeScanResponseContext.payloadContext.srcPayloadSize.toDouble() ?: 0.0,
477477
connection,
478-
scope
478+
scope,
479+
initiatedByChat
479480
)
480481
)
481482
sendCodeScanTelemetryToServiceAPI(project, language, codeScanResponseContext, scope)

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/model/CodeWhispererModel.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ data class CodeScanTelemetryEvent(
254254
val totalProjectSizeInBytes: Double?,
255255
val connection: ToolkitConnection?,
256256
val codeAnalysisScope: CodeWhispererConstants.CodeAnalysisScope,
257+
val initiatedByChat: Boolean = false,
257258
)
258259

259260
data class CreateUploadUrlServiceInvocationContext(

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

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,18 @@ class CodeWhispererTelemetryService {
283283
)
284284
}
285285

286+
private fun mapToTelemetryScope(codeAnalysisScope: CodeWhispererConstants.CodeAnalysisScope, initiatedByChat: Boolean): CodewhispererCodeScanScope =
287+
when (codeAnalysisScope) {
288+
CodeWhispererConstants.CodeAnalysisScope.FILE -> {
289+
if (initiatedByChat) {
290+
CodewhispererCodeScanScope.FILEONDEMAND
291+
} else {
292+
CodewhispererCodeScanScope.FILEAUTO
293+
}
294+
}
295+
CodeWhispererConstants.CodeAnalysisScope.PROJECT -> CodewhispererCodeScanScope.PROJECT
296+
}
297+
286298
fun sendSecurityScanEvent(codeScanEvent: CodeScanTelemetryEvent, project: Project? = null) {
287299
val payloadContext = codeScanEvent.codeScanResponseContext.payloadContext
288300
val serviceInvocationContext = codeScanEvent.codeScanResponseContext.serviceInvocationContext
@@ -291,8 +303,9 @@ class CodeWhispererTelemetryService {
291303
val issuesWithFixes = codeScanEvent.codeScanResponseContext.codeScanIssuesWithFixes
292304
val reason = codeScanEvent.codeScanResponseContext.reason
293305
val startUrl = getConnectionStartUrl(codeScanEvent.connection)
294-
val codeAnalysisScope = codeScanEvent.codeAnalysisScope
295-
val passive = codeAnalysisScope == CodeWhispererConstants.CodeAnalysisScope.FILE
306+
val codeAnalysisScope = mapToTelemetryScope(codeScanEvent.codeAnalysisScope, codeScanEvent.initiatedByChat)
307+
val passive = codeAnalysisScope == CodewhispererCodeScanScope.FILEAUTO
308+
val source = if (codeScanEvent.initiatedByChat) "chat" else "menu"
296309

297310
LOG.debug {
298311
"Recording code security scan event. \n" +
@@ -309,8 +322,9 @@ class CodeWhispererTelemetryService {
309322
"Service invocation duration in milliseconds: ${serviceInvocationContext.serviceInvocationDuration}, \n" +
310323
"Total number of lines scanned: ${payloadContext.totalLines}, \n" +
311324
"Reason: $reason \n" +
312-
"Scope: ${codeAnalysisScope.value} \n" +
313-
"Passive: $passive \n"
325+
"Scope: $codeAnalysisScope \n" +
326+
"Passive: $passive \n" +
327+
"Source: $source \n"
314328
}
315329
CodewhispererTelemetry.securityScan(
316330
project = project,
@@ -330,8 +344,9 @@ class CodeWhispererTelemetryService {
330344
reason = reason,
331345
result = codeScanEvent.result,
332346
credentialStartUrl = startUrl,
333-
codewhispererCodeScanScope = CodewhispererCodeScanScope.from(codeAnalysisScope.value),
334-
passive = passive
347+
codewhispererCodeScanScope = codeAnalysisScope,
348+
passive = passive,
349+
source = source
335350
)
336351
}
337352

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/RulesEngine.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ object RulesEngine {
5656
if (notificationExtension.isNullOrEmpty()) return true
5757
val extensionsToBeChecked = notificationExtension.map { it.id }
5858
val pluginVersions = actualPluginVersions.filterKeys { extensionsToBeChecked.contains(it) }
59+
if (pluginVersions.isEmpty()) return false
5960
return notificationExtension.all { extension ->
6061
val actualVersion = pluginVersions[extension.id]
6162
if (actualVersion == null) {

plugins/core/jetbrains-community/tst/software/aws/toolkits/jetbrains/core/notifications/NotificationFormatUtilsTest.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class NotificationFormatUtilsTest {
3636
val projectRule = ProjectRule()
3737

3838
private lateinit var mockSystemDetails: SystemDetails
39+
private lateinit var mockSystemDetailsWithNoPlugin: SystemDetails
3940
private lateinit var exampleNotification: InputStream
4041

4142
@BeforeEach
@@ -53,6 +54,18 @@ class NotificationFormatUtilsTest {
5354
)
5455
)
5556

57+
mockSystemDetailsWithNoPlugin = SystemDetails(
58+
computeType = "Local",
59+
computeArchitecture = "x86_64",
60+
osType = "Linux",
61+
osVersion = "5.4.0",
62+
ideType = "IC",
63+
ideVersion = "2023.1",
64+
pluginVersions = mapOf(
65+
"aws.toolkit" to "1.0",
66+
)
67+
)
68+
5669
exampleNotification = javaClass.getResource("/exampleNotification2.json")?.let {
5770
Paths.get(it.toURI()).takeIf { f -> f.exists() }
5871
}?.inputStream() ?: throw RuntimeException("Test not found")
@@ -98,6 +111,13 @@ class NotificationFormatUtilsTest {
98111
}
99112
}
100113

114+
@Test
115+
fun `If plugin is not present, notification is not shown`() {
116+
every { getCurrentSystemAndConnectionDetails() } returns mockSystemDetailsWithNoPlugin
117+
val shouldShow = RulesEngine.displayNotification(projectRule.project, pluginNotPresentData)
118+
assertThat(shouldShow).isFalse
119+
}
120+
101121
@ParameterizedTest
102122
@MethodSource("validNotifications")
103123
fun `The notification is shown`(notification: String, expectedData: NotificationData) {

plugins/core/jetbrains-community/tst/software/aws/toolkits/jetbrains/core/notifications/NotificationFormatUtilsTestCases.kt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,3 +360,29 @@ val invalidIdeTypeAndVersionData = NotificationData(
360360
)
361361
)
362362
)
363+
364+
val pluginNotPresentData = NotificationData(
365+
id = "example_id_12344",
366+
schedule = NotificationSchedule(type = "StartUp"),
367+
severity = "Critical",
368+
condition = NotificationDisplayCondition(
369+
compute = null,
370+
os = null,
371+
ide = null,
372+
extension = mutableListOf(
373+
ExtensionType(
374+
"amazon.q",
375+
version = NotificationExpression.NotEqualsCondition("1.3334")
376+
)
377+
),
378+
authx = null
379+
380+
),
381+
actions = emptyList(),
382+
content = NotificationContentDescriptionLocale(
383+
NotificationContentDescription(
384+
title = "Look at this!",
385+
description = "Some bug is there"
386+
)
387+
)
388+
)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ codemodernizer.builderrordialog.description.title=Error occurred when building y
602602
codemodernizer.chat.form.user_selection.item.choose_module=Choose a module to transform
603603
codemodernizer.chat.form.user_selection.item.choose_one_or_multiple_diffs_option=Choose how to receive proposed changes
604604
codemodernizer.chat.form.user_selection.item.choose_skip_tests_option=Choose to skip unit tests
605-
codemodernizer.chat.form.user_selection.item.choose_sql_metadata_file=Okay, I can convert the embedded SQL code for your Oracle to PostgreSQL transformation. To get started, upload the zipped metadata file from your schema conversion in AWS Data Migration Service (DMS). To retrieve the metadata file:\n1. Open your database migration project in the AWS DMS console.\n2. Open the schema conversion and choose **Convert the embedded SQL in your application**.\n3. Once you complete the conversion, close the project and go to the S3 bucket where your project is stored.\n4. Open the folder and find the project folder ("sct-project").\n5. Download the object inside the project folder. This will be a zip file.\n\nFor more info, refer to the [documentation](https://docs.aws.amazon.com/dms/latest/userguide/schema-conversion-save-apply.html#schema-conversion-save).
605+
codemodernizer.chat.form.user_selection.item.choose_sql_metadata_file=Okay, I can convert the embedded SQL code for your Oracle to PostgreSQL transformation. To get started, upload the zipped metadata file from your schema conversion in AWS Data Migration Service (DMS). To retrieve the metadata file:\n1. Open your database migration project in the AWS DMS console.\n2. Open the schema conversion and choose **Convert the embedded SQL in your application**.\n3. Once you complete the conversion, close the project and go to the S3 bucket where your project is stored.\n4. Open the folder and find the project folder ("sct-project").\n5. Download the object inside the project folder. This will be a zip file.\n\nFor more info, refer to the [documentation](https://docs.aws.amazon.com/dms/latest/userguide/schema-conversion-embedded-sql.html).
606606
codemodernizer.chat.form.user_selection.item.choose_target_version=Choose the target code version
607607
codemodernizer.chat.form.user_selection.title=Q - Code transformation
608608
codemodernizer.chat.message.absolute_path_detected=I detected {0} potential absolute file path(s) in your {1} file: **{2}**. Absolute file paths might cause issues when I build your code. Any errors will show up in the build log.

0 commit comments

Comments
 (0)