Skip to content

Commit 280d533

Browse files
committed
further cleanup
1 parent 5c2f07a commit 280d533

File tree

4 files changed

+20
-9
lines changed

4 files changed

+20
-9
lines changed

plugins/amazonq/codewhisperer/jetbrains-community/src/migration/software/aws/toolkits/jetbrains/services/codewhisperer/explorer/CodeWhispererExplorerActionManager.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ import software.aws.toolkits.jetbrains.core.credentials.sso.bearer.BearerTokenPr
2020
import software.aws.toolkits.jetbrains.services.codewhisperer.credentials.CodeWhispererLoginType
2121
import software.aws.toolkits.jetbrains.services.codewhisperer.explorer.CodeWhispererExploreActionState
2222
import software.aws.toolkits.jetbrains.services.codewhisperer.explorer.CodeWhispererExploreStateType
23-
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererConstants
2423
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererUtil.getConnectionStartUrl
25-
import software.aws.toolkits.telemetry.AwsTelemetry
2624

2725
// TODO: refactor this class, now it's managing action and state
2826
@State(name = "codewhispererStates", storages = [Storage("aws.xml")])
@@ -39,7 +37,10 @@ class CodeWhispererExplorerActionManager : PersistentStateComponent<CodeWhispere
3937

4038
private fun getCodeWhispererConnectionStartUrl(project: Project): String {
4139
val connection = ToolkitConnectionManager.getInstance(project).activeConnectionForFeature(CodeWhispererConnection.getInstance())
42-
return getConnectionStartUrl(connection) ?: CodeWhispererConstants.ACCOUNTLESS_START_URL
40+
return getConnectionStartUrl(connection) ?: run {
41+
LOG.warn { "fail to retrieve connection start url, not a bearer token connection" }
42+
""
43+
}
4344
}
4445

4546
fun isAutoEnabled(): Boolean = actionState.value.getOrDefault(CodeWhispererExploreStateType.IsAutoEnabled, true)
@@ -81,10 +82,8 @@ class CodeWhispererExplorerActionManager : PersistentStateComponent<CodeWhispere
8182
}
8283

8384
// Adding Auto CodeScan Function
84-
fun setAutoCodeScan(project: Project, isAutoEnabledForCodeScan: Boolean) {
85+
fun setAutoCodeScan(isAutoEnabledForCodeScan: Boolean) {
8586
setAutoEnabledForCodeScan(isAutoEnabledForCodeScan)
86-
val autoCodeScanState = if (isAutoEnabledForCodeScan) CodeWhispererConstants.AutoCodeScan.ACTIVATED else CodeWhispererConstants.AutoCodeScan.DEACTIVATED
87-
AwsTelemetry.modifySetting(project, settingId = CodeWhispererConstants.AutoCodeScan.SETTING_ID, settingState = autoCodeScanState)
8887
}
8988

9089
fun getIsFirstRestartAfterQInstall(): Boolean = actionState.value.getOrDefault(CodeWhispererExploreStateType.IsFirstRestartAfterQInstall, true)

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import com.intellij.icons.AllIcons
77
import com.intellij.openapi.actionSystem.AnActionEvent
88
import com.intellij.openapi.project.DumbAwareAction
99
import software.aws.toolkits.jetbrains.services.codewhisperer.explorer.CodeWhispererExplorerActionManager
10+
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererConstants
1011
import software.aws.toolkits.resources.message
12+
import software.aws.toolkits.telemetry.AwsTelemetry
1113

1214
class PauseCodeScans : DumbAwareAction(
1315
{ message("codewhisperer.explorer.pause_auto_scans") },
@@ -16,6 +18,11 @@ class PauseCodeScans : DumbAwareAction(
1618
override fun actionPerformed(e: AnActionEvent) {
1719
val project = e.project ?: return
1820

19-
CodeWhispererExplorerActionManager.getInstance().setAutoCodeScan(project, false)
21+
CodeWhispererExplorerActionManager.getInstance().setAutoCodeScan(false)
22+
AwsTelemetry.modifySetting(
23+
project,
24+
settingId = CodeWhispererConstants.AutoCodeScan.SETTING_ID,
25+
settingState = CodeWhispererConstants.AutoCodeScan.DEACTIVATED
26+
)
2027
}
2128
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import software.aws.toolkits.jetbrains.services.codewhisperer.explorer.CodeWhisp
1111
import software.aws.toolkits.jetbrains.services.codewhisperer.explorer.isUserBuilderId
1212
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererConstants
1313
import software.aws.toolkits.resources.message
14+
import software.aws.toolkits.telemetry.AwsTelemetry
1415

1516
class ResumeCodeScans : DumbAwareAction(
1617
{ message("codewhisperer.explorer.resume_auto_scans") },
@@ -20,7 +21,12 @@ class ResumeCodeScans : DumbAwareAction(
2021
val project = e.project ?: return
2122

2223
val actionManager = CodeWhispererExplorerActionManager.getInstance()
23-
actionManager.setAutoCodeScan(project, true)
24+
actionManager.setAutoCodeScan(true)
25+
AwsTelemetry.modifySetting(
26+
project,
27+
settingId = CodeWhispererConstants.AutoCodeScan.SETTING_ID,
28+
settingState = CodeWhispererConstants.AutoCodeScan.ACTIVATED
29+
)
2430
// Run Proactive Code File Scan once toggle is enabled
2531
if (actionManager.isAutoEnabledForCodeScan() && !actionManager.isMonthlyQuotaForCodeScansExceeded() && !isUserBuilderId(project)) {
2632
CodeWhispererCodeScanManager.getInstance(project).createDebouncedRunCodeScan(CodeWhispererConstants.CodeAnalysisScope.FILE)

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/CodeWhispererConstants.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ object CodeWhispererConstants {
8686
const val TOTAL_BYTES_IN_MB = 1024 * 1024
8787
const val TOTAL_MILLIS_IN_SECOND = 1000
8888
const val TOTAL_SECONDS_IN_MINUTE: Long = 60L
89-
const val ACCOUNTLESS_START_URL = "accountless"
9089
const val FEATURE_CONFIG_POLL_INTERVAL_IN_MS: Long = 30 * 60 * 1000L // 30 mins
9190
const val USING: String = "using"
9291
const val GLOBAL_USING: String = "global using"

0 commit comments

Comments
 (0)