Skip to content

Commit 312cb0c

Browse files
authored
cleanup: remove unused CodeWhispererExplorerActionManager methods & funcs (aws#4423)
1 parent df7ce2d commit 312cb0c

File tree

3 files changed

+1
-56
lines changed

3 files changed

+1
-56
lines changed

plugins/toolkit/jetbrains-core/src/migration/software/aws/toolkits/jetbrains/services/codewhisperer/explorer/CodeWhispererExplorerActionManager.kt

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,13 @@ import software.aws.toolkits.jetbrains.services.codewhisperer.explorer.CodeWhisp
2323
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererConstants
2424
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererUtil.getConnectionStartUrl
2525
import software.aws.toolkits.telemetry.AwsTelemetry
26-
import java.time.LocalDateTime
2726

2827
// TODO: refactor this class, now it's managing action and state
2928
@State(name = "codewhispererStates", storages = [Storage("aws.xml")])
3029
class CodeWhispererExplorerActionManager : PersistentStateComponent<CodeWhispererExploreActionState> {
3130
private val actionState = CodeWhispererExploreActionState()
3231
private val suspendedConnections = mutableSetOf<String>()
3332

34-
fun isSuspended(project: Project): Boolean {
35-
val startUrl = getCodeWhispererConnectionStartUrl(project)
36-
return suspendedConnections.contains(startUrl)
37-
}
38-
3933
fun setSuspended(project: Project) {
4034
val startUrl = getCodeWhispererConnectionStartUrl(project)
4135
if (!suspendedConnections.add(startUrl)) {
@@ -70,42 +64,12 @@ class CodeWhispererExplorerActionManager : PersistentStateComponent<CodeWhispere
7064
actionState.value[CodeWhispererExploreStateType.HasShownNewOnboardingPage] = hasShownNewOnboardingPage
7165
}
7266

73-
fun setAccountlessNotificationWarnTimestamp() {
74-
actionState.accountlessWarnTimestamp = LocalDateTime.now().format(CodeWhispererConstants.TIMESTAMP_FORMATTER)
75-
}
76-
77-
fun setAccountlessNotificationErrorTimestamp() {
78-
actionState.accountlessErrorTimestamp = LocalDateTime.now().format(CodeWhispererConstants.TIMESTAMP_FORMATTER)
79-
}
80-
81-
fun getAccountlessWarnNotificationTimestamp(): String? = actionState.accountlessWarnTimestamp
82-
83-
fun getAccountlessErrorNotificationTimestamp(): String? = actionState.accountlessErrorTimestamp
84-
85-
fun getDoNotShowAgainWarn(): Boolean = actionState.value.getOrDefault(CodeWhispererExploreStateType.DoNotShowAgainWarn, false)
86-
87-
fun setDoNotShowAgainWarn(doNotShowAgain: Boolean) {
88-
actionState.value[CodeWhispererExploreStateType.DoNotShowAgainWarn] = doNotShowAgain
89-
}
90-
91-
fun getDoNotShowAgainError(): Boolean = actionState.value.getOrDefault(CodeWhispererExploreStateType.DoNotShowAgainError, false)
92-
93-
fun setDoNotShowAgainError(doNotShowAgain: Boolean) {
94-
actionState.value[CodeWhispererExploreStateType.DoNotShowAgainError] = doNotShowAgain
95-
}
96-
9767
fun getConnectionExpiredDoNotShowAgain(): Boolean = actionState.value.getOrDefault(CodeWhispererExploreStateType.ConnectionExpiredDoNotShowAgain, false)
9868

9969
fun setConnectionExpiredDoNotShowAgain(doNotShowAgain: Boolean) {
10070
actionState.value[CodeWhispererExploreStateType.ConnectionExpiredDoNotShowAgain] = doNotShowAgain
10171
}
10272

103-
fun getAccountlessNullified(): Boolean = actionState.value.getOrDefault(CodeWhispererExploreStateType.AccountlessNullified, false)
104-
105-
fun setAccountlessNullified(accountlessNullified: Boolean) {
106-
actionState.value[CodeWhispererExploreStateType.AccountlessNullified] = accountlessNullified
107-
}
108-
10973
fun setAutoSuggestion(project: Project, isAutoEnabled: Boolean) {
11074
setAutoEnabled(isAutoEnabled)
11175
val autoSuggestionState = if (isAutoEnabled) CodeWhispererConstants.AutoSuggestion.ACTIVATED else CodeWhispererConstants.AutoSuggestion.DEACTIVATED
@@ -160,13 +124,6 @@ class CodeWhispererExplorerActionManager : PersistentStateComponent<CodeWhispere
160124
} ?: CodeWhispererLoginType.Logout
161125
}
162126

163-
fun nullifyAccountlessCredentialIfNeeded() {
164-
if (actionState.token != null) {
165-
setAccountlessNullified(true)
166-
actionState.token = null
167-
}
168-
}
169-
170127
override fun getState(): CodeWhispererExploreActionState = CodeWhispererExploreActionState().apply {
171128
value.putAll(actionState.value)
172129
token = actionState.token

plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/services/codewhisperer/explorer/CodeWhispererExplorerActionManager.kt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,3 @@ fun isCodeWhispererEnabled(project: Project) = with(CodeWhispererExplorerActionM
5353
fun isUserBuilderId(project: Project) = with(CodeWhispererExplorerActionManager.getInstance()) {
5454
checkActiveCodeWhispererConnectionType(project) == CodeWhispererLoginType.Sono
5555
}
56-
57-
/**
58-
* Note: please use this util with extra caution, it will return "false" for a "logout" scenario,
59-
* the reasoning is we need handling specifically for a "Expired" condition thus excluding logout from here
60-
* If callers rather need a predicate "isInvalidConnection", please use the combination of the two (!isCodeWhispererEnabled() || isCodeWhispererExpired())
61-
*/
62-
@Deprecated("remove it, use isQExpired")
63-
fun isCodeWhispererExpired(project: Project) = with(CodeWhispererExplorerActionManager.getInstance()) {
64-
checkActiveCodeWhispererConnectionType(project) == CodeWhispererLoginType.Expired
65-
}

plugins/toolkit/jetbrains-core/tst/software/aws/toolkits/jetbrains/services/codewhisperer/CodeWhispererExplorerActionManagerTest.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import software.aws.toolkits.jetbrains.core.credentials.sso.bearer.InteractiveBe
3434
import software.aws.toolkits.jetbrains.services.codewhisperer.credentials.CodeWhispererLoginType
3535
import software.aws.toolkits.jetbrains.services.codewhisperer.explorer.CodeWhispererExplorerActionManager
3636
import software.aws.toolkits.jetbrains.services.codewhisperer.explorer.isCodeWhispererEnabled
37-
import software.aws.toolkits.jetbrains.services.codewhisperer.explorer.isCodeWhispererExpired
3837
import java.nio.file.Files
3938
import java.nio.file.Path
4039
import java.nio.file.Paths
@@ -97,7 +96,6 @@ class CodeWhispererExplorerActionManagerTest {
9796
val actual = mockManager.checkActiveCodeWhispererConnectionType(project)
9897
assertThat(actual).isEqualTo(CodeWhispererLoginType.Logout)
9998
assertThat(isCodeWhispererEnabled(project)).isFalse
100-
assertThat(isCodeWhispererExpired(project)).isFalse
10199
}
102100

103101
/**
@@ -174,6 +172,7 @@ class CodeWhispererExplorerActionManagerTest {
174172
assertThat(ConnectionPinningManager.getInstance().isFeaturePinned(CodeWhispererConnection.getInstance())).isFalse
175173
}
176174

175+
@SuppressWarnings("UnusedParameter")
177176
private fun assertConnectionState(
178177
startUrl: String,
179178
refreshToken: String?,
@@ -213,6 +212,5 @@ class CodeWhispererExplorerActionManagerTest {
213212
assertThat(myTokenProvider.state()).isEqualTo(expectedState)
214213
assertThat(CodeWhispererExplorerActionManager.getInstance().checkActiveCodeWhispererConnectionType(project)).isEqualTo(expectedLoginType)
215214
assertThat(isCodeWhispererEnabled(project)).isEqualTo(expectedIsCwEnabled)
216-
assertThat(isCodeWhispererExpired(project)).isEqualTo(expectedIsCwExpired)
217215
}
218216
}

0 commit comments

Comments
 (0)