Skip to content

Commit 1e87cbc

Browse files
committed
inline completion API migration
1 parent 11d2e8a commit 1e87cbc

File tree

40 files changed

+815
-384
lines changed

40 files changed

+815
-384
lines changed

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/auth/AuthController.kt

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,34 +26,24 @@ class AuthController {
2626
*/
2727
fun getAuthNeededStates(project: Project): AuthNeededStates {
2828
val connectionState = checkBearerConnectionValidity(project, BearerTokenFeatureSet.Q)
29-
val codeWhispererState = checkBearerConnectionValidity(project, BearerTokenFeatureSet.CODEWHISPERER)
3029

3130
// CW chat is enabled for Builder and IDC users, same for Amazon Q
3231
return AuthNeededStates(
33-
chat = getAuthNeededState(connectionState, codeWhispererState),
34-
amazonQ = getAuthNeededState(connectionState, codeWhispererState)
32+
chat = getAuthNeededState(connectionState),
33+
amazonQ = getAuthNeededState(connectionState)
3534
)
3635
}
3736

3837
private fun getAuthNeededState(
3938
amazonqConnectionState: ActiveConnection,
40-
codeWhispererConnectionState: ActiveConnection,
4139
onlyIamIdcConnection: Boolean = false,
4240
): AuthNeededState? =
4341
when (amazonqConnectionState) {
4442
ActiveConnection.NotConnected -> {
45-
if (codeWhispererConnectionState == ActiveConnection.NotConnected) {
46-
AuthNeededState(
47-
message = message("q.connection.disconnected"),
48-
authType = AuthFollowUpType.FullAuth,
49-
)
50-
} else {
51-
// There is a connection for codewhisperer, but it's not valid for Q
52-
AuthNeededState(
53-
message = message("q.connection.need_scopes"),
54-
authType = AuthFollowUpType.MissingScopes,
55-
)
56-
}
43+
AuthNeededState(
44+
message = message("q.connection.disconnected"),
45+
authType = AuthFollowUpType.FullAuth,
46+
)
5747
}
5848

5949
is ActiveConnection.ValidBearer -> {

plugins/amazonq/codewhisperer/jetbrains-community/resources/META-INF/plugin-codewhisperer.xml

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@
6060
<typedHandler implementation="software.aws.toolkits.jetbrains.services.codewhisperer.editor.CodeWhispererTypedHandler"/>
6161
<editorActionHandler action="EditorEnter" implementationClass="software.aws.toolkits.jetbrains.services.codewhisperer.editor.CodeWhispererEnterHandler"
6262
order="first, before editorEnter"/>
63-
<actionPromoter order="last" implementation="software.aws.toolkits.jetbrains.services.codewhisperer.actions.CodeWhispererActionPromoter"/>
6463
<fileEditorProvider implementation="software.aws.toolkits.jetbrains.services.codewhisperer.learn.LearnCodeWhispererEditorProvider"/>
64+
65+
<!-- Inline Completion Provider -->
66+
<inline.completion.provider id="amazon.q" implementation="software.aws.toolkits.jetbrains.services.codewhisperer.popup.QInlineCompletionProvider"/>
6567
</extensions>
6668

6769
<extensions defaultExtensionNs="aws.toolkit.core">
@@ -90,29 +92,6 @@
9092
text="Invoke Amazon Q Inline Suggestions">
9193
<keyboard-shortcut keymap="$default" first-keystroke="alt C"/>
9294
</action>
93-
<action id="codewhisperer.inline.navigate.previous"
94-
class="software.aws.toolkits.jetbrains.services.codewhisperer.actions.CodeWhispererNavigatePrevAction"
95-
text="Navigate to Previous Inline Suggestion" description="Navigate to previous inline suggestion">
96-
<keyboard-shortcut keymap="$default" first-keystroke="alt OPEN_BRACKET"/>
97-
</action>
98-
<action id="codewhisperer.inline.navigate.next"
99-
class="software.aws.toolkits.jetbrains.services.codewhisperer.actions.CodeWhispererNavigateNextAction"
100-
text="Navigate to Next Inline Suggestion" description="Navigate to next inline suggestion">
101-
<keyboard-shortcut keymap="$default" first-keystroke="alt CLOSE_BRACKET"/>
102-
</action>
103-
<action id="codewhisperer.inline.accept"
104-
class="software.aws.toolkits.jetbrains.services.codewhisperer.actions.CodeWhispererAcceptAction"
105-
text="Accept the Current Inline Suggestion" description="Accept the current inline suggestions">
106-
<keyboard-shortcut keymap="$default" first-keystroke="TAB"/>
107-
</action>
108-
<action id="codewhisperer.inline.force.accept"
109-
class="software.aws.toolkits.jetbrains.services.codewhisperer.actions.CodeWhispererForceAcceptAction"
110-
text="Force Accept the Current Amazon Q Suggestion" description="Force accept the current Amazon Q suggestion">
111-
<keyboard-shortcut keymap="Mac OS X" first-keystroke="alt TAB"/>
112-
<keyboard-shortcut keymap="Mac OS X 10.5+" first-keystroke="alt TAB"/>
113-
<keyboard-shortcut keymap="$default" first-keystroke="alt ENTER"/>
114-
</action>
115-
11695

11796
<group id="aws.toolkit.codewhisperer.toolbar.security">
11897
<group id="codewhisperer.toolbar.security.group" icon="AllIcons.Actions.GroupBy" text="Group" popup="true">

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

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@ import com.intellij.openapi.components.State
88
import com.intellij.openapi.components.Storage
99
import com.intellij.openapi.components.service
1010
import com.intellij.openapi.project.Project
11-
import org.jetbrains.annotations.ApiStatus
12-
import software.aws.toolkits.core.utils.getLogger
13-
import software.aws.toolkits.core.utils.warn
1411
import software.aws.toolkits.jetbrains.core.credentials.AwsBearerTokenConnection
1512
import software.aws.toolkits.jetbrains.core.credentials.ToolkitConnectionManager
16-
import software.aws.toolkits.jetbrains.core.credentials.pinning.CodeWhispererConnection
13+
import software.aws.toolkits.jetbrains.core.credentials.pinning.QConnection
1714
import software.aws.toolkits.jetbrains.core.credentials.sono.isSono
1815
import software.aws.toolkits.jetbrains.core.credentials.sso.bearer.BearerTokenAuthState
1916
import software.aws.toolkits.jetbrains.core.credentials.sso.bearer.BearerTokenProvider
@@ -38,7 +35,7 @@ class CodeWhispererExplorerActionManager : PersistentStateComponent<CodeWhispere
3835
}
3936

4037
private fun getCodeWhispererConnectionStartUrl(project: Project): String {
41-
val connection = ToolkitConnectionManager.getInstance(project).activeConnectionForFeature(CodeWhispererConnection.getInstance())
38+
val connection = ToolkitConnectionManager.getInstance(project).activeConnectionForFeature(QConnection.getInstance())
4239
return getConnectionStartUrl(connection) ?: CodeWhispererConstants.ACCOUNTLESS_START_URL
4340
}
4441

@@ -95,22 +92,8 @@ class CodeWhispererExplorerActionManager : PersistentStateComponent<CodeWhispere
9592
actionState.value[CodeWhispererExploreStateType.IsFirstRestartAfterQInstall] = isFirstRestartAfterQInstall
9693
}
9794

98-
@Deprecated("Accountless credential will be removed soon")
99-
@ApiStatus.ScheduledForRemoval
100-
// Will keep it for existing accountless users
101-
/**
102-
* Will be called from CodeWhispererService.showRecommendationInPopup()
103-
* Caller (e.x. CodeWhispererService) should take care if null value returned, popup a notification/hint window or dialog etc.
104-
*/
105-
fun resolveAccessToken(): String? {
106-
if (actionState.token == null) {
107-
LOG.warn { "Logical Error: Try to get access token before token initialization" }
108-
}
109-
return actionState.token
110-
}
111-
11295
fun checkActiveCodeWhispererConnectionType(project: Project): CodeWhispererLoginType {
113-
val conn = ToolkitConnectionManager.getInstance(project).activeConnectionForFeature(CodeWhispererConnection.getInstance()) as? AwsBearerTokenConnection
96+
val conn = ToolkitConnectionManager.getInstance(project).activeConnectionForFeature(QConnection.getInstance()) as? AwsBearerTokenConnection
11497
return conn?.let {
11598
val provider = (it.getConnectionSettings().tokenProvider.delegate as? BearerTokenProvider) ?: return@let CodeWhispererLoginType.Logout
11699

@@ -148,7 +131,5 @@ class CodeWhispererExplorerActionManager : PersistentStateComponent<CodeWhispere
148131
companion object {
149132
@JvmStatic
150133
fun getInstance(): CodeWhispererExplorerActionManager = service()
151-
152-
private val LOG = getLogger<CodeWhispererExplorerActionManager>()
153134
}
154135
}

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

Lines changed: 0 additions & 34 deletions
This file was deleted.

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

Lines changed: 0 additions & 59 deletions
This file was deleted.

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

Lines changed: 0 additions & 32 deletions
This file was deleted.

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

Lines changed: 0 additions & 32 deletions
This file was deleted.

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

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ import com.intellij.openapi.util.Key
1212
import kotlinx.coroutines.Job
1313
import software.aws.toolkits.jetbrains.services.amazonq.CodeWhispererFeatureConfigService
1414
import software.aws.toolkits.jetbrains.services.amazonq.profile.QRegionProfileManager
15-
import software.aws.toolkits.jetbrains.services.codewhisperer.model.LatencyContext
16-
import software.aws.toolkits.jetbrains.services.codewhisperer.model.TriggerTypeInfo
17-
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererAutomatedTriggerType
15+
import software.aws.toolkits.jetbrains.services.codewhisperer.popup.QInlineCompletionProvider
1816
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererService
1917
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererServiceNew
2018
import software.aws.toolkits.resources.message
@@ -33,8 +31,6 @@ class CodeWhispererRecommendationAction : AnAction(message("codewhisperer.trigge
3331
if (QRegionProfileManager.getInstance().hasValidConnectionButNoActiveProfile(project)) {
3432
return
3533
}
36-
val latencyContext = LatencyContext()
37-
latencyContext.codewhispererEndToEndStart = System.nanoTime()
3834
val editor = e.getRequiredData(CommonDataKeys.EDITOR)
3935
if (!(
4036
if (CodeWhispererFeatureConfigService.getInstance().getNewAutoTriggerUX()) {
@@ -47,14 +43,7 @@ class CodeWhispererRecommendationAction : AnAction(message("codewhisperer.trigge
4743
return
4844
}
4945

50-
val triggerType = TriggerTypeInfo(CodewhispererTriggerType.OnDemand, CodeWhispererAutomatedTriggerType.Unknown())
51-
val job = if (CodeWhispererFeatureConfigService.getInstance().getNewAutoTriggerUX()) {
52-
CodeWhispererServiceNew.getInstance().showRecommendationsInPopup(editor, triggerType, latencyContext)
53-
} else {
54-
CodeWhispererService.getInstance().showRecommendationsInPopup(editor, triggerType, latencyContext)
55-
}
56-
57-
e.getData(CommonDataKeys.EDITOR)?.getUserData(ACTION_JOB_KEY)?.set(job)
46+
QInlineCompletionProvider.invokeCompletion(editor)
5847
}
5948

6049
companion object {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ import software.aws.toolkits.jetbrains.core.coroutines.EDT
6464
import software.aws.toolkits.jetbrains.core.coroutines.getCoroutineUiContext
6565
import software.aws.toolkits.jetbrains.core.coroutines.projectCoroutineScope
6666
import software.aws.toolkits.jetbrains.core.credentials.ToolkitConnectionManager
67-
import software.aws.toolkits.jetbrains.core.credentials.pinning.CodeWhispererConnection
67+
import software.aws.toolkits.jetbrains.core.credentials.pinning.QConnection
6868
import software.aws.toolkits.jetbrains.services.codewhisperer.codescan.listeners.CodeWhispererCodeScanDocumentListener
6969
import software.aws.toolkits.jetbrains.services.codewhisperer.codescan.listeners.CodeWhispererCodeScanEditorMouseMotionListener
7070
import software.aws.toolkits.jetbrains.services.codewhisperer.codescan.listeners.CodeWhispererCodeScanFileListener
@@ -397,7 +397,7 @@ class CodeWhispererCodeScanManager(val project: Project) {
397397
var codeScanStatus: Result = Result.Failed
398398
val startTime = Instant.now().toEpochMilli()
399399
var codeScanResponseContext = defaultCodeScanResponseContext()
400-
val connection = ToolkitConnectionManager.getInstance(project).activeConnectionForFeature(CodeWhispererConnection.getInstance())
400+
val connection = ToolkitConnectionManager.getInstance(project).activeConnectionForFeature(QConnection.getInstance())
401401
var language: CodeWhispererProgrammingLanguage = CodeWhispererUnknownLanguage.INSTANCE
402402
var skipTelemetry = false
403403
try {

0 commit comments

Comments
 (0)