-
Notifications
You must be signed in to change notification settings - Fork 274
feat(amazonq): grouping options for code issues #5314
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
.changes/next-release/feature-6565a79c-90f3-4d49-abb6-ca4d5c0ff679.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "type" : "feature", | ||
| "description" : "Amazon Q /review: Code issues can now be grouped by severity or file location." | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ import com.intellij.util.ui.JBUI | |
| import icons.AwsIcons | ||
| import kotlinx.coroutines.CoroutineScope | ||
| import software.aws.toolkits.jetbrains.services.codewhisperer.codescan.listeners.CodeWhispererCodeScanTreeMouseListener | ||
| import software.aws.toolkits.jetbrains.services.codewhisperer.codescan.utils.IssueGroupingStrategy | ||
| import software.aws.toolkits.jetbrains.services.codewhisperer.codescan.utils.IssueSeverity | ||
| import software.aws.toolkits.jetbrains.services.codewhisperer.layout.CodeWhispererLayoutConfig | ||
| import software.aws.toolkits.jetbrains.services.codewhisperer.layout.CodeWhispererLayoutConfig.addHorizontalGlue | ||
|
|
@@ -47,6 +48,8 @@ import javax.swing.tree.TreePath | |
| */ | ||
| internal class CodeWhispererCodeScanResultsView(private val project: Project, private val defaultScope: CoroutineScope) : JPanel(BorderLayout()) { | ||
|
|
||
| private fun isGroupedBySeverity() = CodeWhispererCodeScanManager.getInstance(project).getGroupingStrategySelected() == IssueGroupingStrategy.SEVERITY | ||
|
|
||
| private val codeScanTree: Tree = Tree().apply { | ||
| isRootVisible = false | ||
| CodeWhispererCodeScanTreeMouseListener(project).installOn(this) | ||
|
|
@@ -62,6 +65,9 @@ internal class CodeWhispererCodeScanResultsView(private val project: Project, pr | |
| } | ||
|
|
||
| private fun expandItems() { | ||
| if (!isGroupedBySeverity()) { | ||
| return | ||
| } | ||
| val criticalTreePath = TreePath(arrayOf(codeScanTree.model.root, codeScanTree.model.getChild(codeScanTree.model.root, 0))) | ||
| val highTreePath = TreePath(arrayOf(codeScanTree.model.root, codeScanTree.model.getChild(codeScanTree.model.root, 1))) | ||
| codeScanTree.expandPath(criticalTreePath) | ||
|
|
@@ -326,7 +332,7 @@ internal class CodeWhispererCodeScanResultsView(private val project: Project, pr | |
| return actionManager.createActionToolbar(ACTION_PLACE, group, false) | ||
| } | ||
|
|
||
| private class ColoredTreeCellRenderer : TreeCellRenderer { | ||
| private inner class ColoredTreeCellRenderer : TreeCellRenderer { | ||
| private fun getSeverityIcon(severity: String): Icon? = when (severity) { | ||
| IssueSeverity.LOW.displayName -> AwsIcons.Resources.CodeWhisperer.SEVERITY_INITIAL_LOW | ||
| IssueSeverity.MEDIUM.displayName -> AwsIcons.Resources.CodeWhisperer.SEVERITY_INITIAL_MEDIUM | ||
|
|
@@ -359,15 +365,23 @@ internal class CodeWhispererCodeScanResultsView(private val project: Project, pr | |
| } | ||
| is CodeWhispererCodeScanIssue -> { | ||
| val cellText = obj.title.trimEnd('.') | ||
| val cellDescription = "${obj.file.name} ${obj.displayTextRange()}" | ||
| val cellDescription = if ([email protected]()) { | ||
| "${obj.file.name} ${obj.displayTextRange()}" | ||
| } else { | ||
| obj.displayTextRange() | ||
| } | ||
| if (obj.isInvalid) { | ||
| cell.text = message("codewhisperer.codescan.scan_recommendation_invalid", obj.title, cellDescription, INACTIVE_TEXT_COLOR) | ||
| cell.toolTipText = message("codewhisperer.codescan.scan_recommendation_invalid.tooltip_text") | ||
| cell.icon = AllIcons.General.Information | ||
| } else { | ||
| cell.text = message("codewhisperer.codescan.scan_recommendation", cellText, cellDescription, INACTIVE_TEXT_COLOR) | ||
| cell.toolTipText = cellText | ||
| cell.icon = obj.issueSeverity.icon | ||
| cell.icon = if ([email protected]()) { | ||
| obj.issueSeverity.icon | ||
| } else { | ||
| getSeverityIcon(obj.severity) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
37 changes: 37 additions & 0 deletions
37
...rvices/codewhisperer/codescan/actions/CodeWhispererCodeScanGroupingStrategyActionGroup.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package software.aws.toolkits.jetbrains.services.codewhisperer.codescan.actions | ||
|
|
||
| import com.intellij.openapi.actionSystem.ActionGroup | ||
| import com.intellij.openapi.actionSystem.ActionUpdateThread | ||
| import com.intellij.openapi.actionSystem.AnAction | ||
| import com.intellij.openapi.actionSystem.AnActionEvent | ||
| import com.intellij.openapi.actionSystem.ex.CheckboxAction | ||
| import software.aws.toolkits.jetbrains.services.codewhisperer.codescan.CodeWhispererCodeScanManager | ||
| import software.aws.toolkits.jetbrains.services.codewhisperer.codescan.utils.IssueGroupingStrategy | ||
|
|
||
| class CodeWhispererCodeScanGroupingStrategyActionGroup : ActionGroup() { | ||
|
Check warning on line 14 in plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/codescan/actions/CodeWhispererCodeScanGroupingStrategyActionGroup.kt
|
||
| override fun getChildren(e: AnActionEvent?): Array<out AnAction> = IssueGroupingStrategy.entries.map { GroupByAction(it) }.toTypedArray() | ||
|
|
||
| private class GroupByAction(private val groupingStrategy: IssueGroupingStrategy) : CheckboxAction() { | ||
| override fun getActionUpdateThread() = ActionUpdateThread.BGT | ||
|
|
||
| override fun isSelected(event: AnActionEvent): Boolean { | ||
| val project = event.project ?: return false | ||
| return CodeWhispererCodeScanManager.getInstance(project).getGroupingStrategySelected() == groupingStrategy | ||
| } | ||
|
|
||
| override fun setSelected(event: AnActionEvent, state: Boolean) { | ||
| val project = event.project ?: return | ||
| if (state) { | ||
| CodeWhispererCodeScanManager.getInstance(project).setGroupingStrategySelected(groupingStrategy) | ||
| } | ||
| } | ||
|
|
||
| override fun update(e: AnActionEvent) { | ||
| super.update(e) | ||
| e.presentation.text = groupingStrategy.displayName | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / QDJVMC
Component/Action not registered Warning