Skip to content

Commit e04fc64

Browse files
committed
api compatiblity fix
1 parent be03dd4 commit e04fc64

File tree

6 files changed

+40
-78
lines changed

6 files changed

+40
-78
lines changed

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@
5757
instance="software.aws.toolkits.jetbrains.services.codewhisperer.settings.CodeWhispererConfigurable"
5858
/>
5959

60-
<typedHandler implementation="software.aws.toolkits.jetbrains.services.codewhisperer.editor.CodeWhispererTypedHandler"/>
61-
<editorActionHandler action="EditorEnter" implementationClass="software.aws.toolkits.jetbrains.services.codewhisperer.editor.CodeWhispererEnterHandler"
62-
order="first, before editorEnter"/>
6360
<fileEditorProvider implementation="software.aws.toolkits.jetbrains.services.codewhisperer.learn.LearnCodeWhispererEditorProvider"/>
6461

6562
<!-- Inline Completion Provider -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package software.aws.toolkits.jetbrains.services.codewhisperer.popup
5+
import com.intellij.codeInsight.inline.completion.InlineCompletionEvent
6+
import com.intellij.openapi.actionSystem.DataContext
7+
import com.intellij.openapi.editor.Editor
8+
import software.aws.toolkits.jetbrains.services.codewhisperer.popup.QInlineCompletionProvider.Companion.DATA_KEY_Q_AUTO_TRIGGER_INTELLISENSE
9+
10+
fun InlineCompletionEvent.isManualCall(): Boolean =
11+
this is InlineCompletionEvent.DirectCall && this.context?.getData(DATA_KEY_Q_AUTO_TRIGGER_INTELLISENSE) == false
12+
13+
fun getManualCallEvent(editor: Editor, isIntelliSenseAccept: Boolean): InlineCompletionEvent {
14+
val dataContext = DataContext { dataId ->
15+
when (dataId) {
16+
DATA_KEY_Q_AUTO_TRIGGER_INTELLISENSE.name -> isIntelliSenseAccept
17+
else -> null
18+
}
19+
}
20+
return InlineCompletionEvent.DirectCall(editor, editor.caretModel.currentCaret, dataContext)
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package software.aws.toolkits.jetbrains.services.codewhisperer.popup
5+
import com.intellij.codeInsight.inline.completion.InlineCompletionEvent
6+
import com.intellij.openapi.editor.Editor
7+
import com.intellij.openapi.util.UserDataHolderBase
8+
import software.aws.toolkits.jetbrains.services.codewhisperer.popup.QInlineCompletionProvider.Companion.KEY_Q_AUTO_TRIGGER_INTELLISENSE
9+
import software.aws.toolkits.jetbrains.services.codewhisperer.popup.QInlineCompletionProvider.Companion.Q_INLINE_PROVIDER_ID
10+
11+
fun InlineCompletionEvent.isManualCall(): Boolean =
12+
this is InlineCompletionEvent.ManualCall && this.additionalData.getUserData(KEY_Q_AUTO_TRIGGER_INTELLISENSE) == false
13+
14+
fun getManualCallEvent(editor: Editor, isIntelliSenseAccept: Boolean): InlineCompletionEvent {
15+
val data = UserDataHolderBase().apply { this.putUserData(KEY_Q_AUTO_TRIGGER_INTELLISENSE, isIntelliSenseAccept) }
16+
return InlineCompletionEvent.ManualCall(editor, Q_INLINE_PROVIDER_ID, data)
17+
}

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/editor/CodeWhispererEnterHandler.kt

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

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/editor/CodeWhispererTypedHandler.kt

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

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/popup/QInlineCompletionProvider.kt

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,14 @@ import com.intellij.codeInsight.inline.completion.session.InlineCompletionSessio
1919
import com.intellij.codeInsight.inline.completion.suggestion.InlineCompletionSuggestion
2020
import com.intellij.codeInsight.inline.completion.suggestion.InlineCompletionSuggestionUpdateManager
2121
import com.intellij.codeInsight.inline.completion.suggestion.InlineCompletionVariant
22-
import com.intellij.openapi.actionSystem.DataContext
2322
import com.intellij.openapi.actionSystem.DataKey
24-
import com.intellij.openapi.application.ApplicationInfo
2523
import com.intellij.openapi.application.runInEdt
2624
import com.intellij.openapi.application.runReadAction
2725
import com.intellij.openapi.editor.Editor
2826
import com.intellij.openapi.fileEditor.FileEditorManager
2927
import com.intellij.openapi.project.Project
3028
import com.intellij.openapi.util.Disposer
3129
import com.intellij.openapi.util.Key
32-
import com.intellij.openapi.util.UserDataHolderBase
3330
import com.intellij.ui.dsl.builder.Cell
3431
import com.intellij.ui.dsl.builder.RightGap
3532
import com.intellij.ui.dsl.builder.panel
@@ -169,20 +166,7 @@ class QInlineCompletionProvider(private val cs: CoroutineScope) : InlineCompleti
169166
val KEY_Q_AUTO_TRIGGER_INTELLISENSE = Key<Boolean>("amazon.q.auto.trigger.intellisense")
170167

171168
fun invokeCompletion(editor: Editor, isIntelliSenseAccept: Boolean = false) {
172-
val currentBuild = ApplicationInfo.getInstance().build.withoutProductCode()
173-
val event =
174-
if (currentBuild.baselineVersion == 242) {
175-
val dataContext = DataContext { dataId ->
176-
when (dataId) {
177-
DATA_KEY_Q_AUTO_TRIGGER_INTELLISENSE.name -> isIntelliSenseAccept
178-
else -> null
179-
}
180-
}
181-
InlineCompletionEvent.DirectCall(editor, editor.caretModel.currentCaret, dataContext)
182-
} else {
183-
val data = UserDataHolderBase().apply { this.putUserData(KEY_Q_AUTO_TRIGGER_INTELLISENSE, isIntelliSenseAccept) }
184-
InlineCompletionEvent.ManualCall(editor, Q_INLINE_PROVIDER_ID, data)
185-
}
169+
val event = getManualCallEvent(editor, isIntelliSenseAccept)
186170
InlineCompletion.getHandlerOrNull(editor)?.invokeEvent(event)
187171
}
188172

@@ -369,7 +353,7 @@ class QInlineCompletionProvider(private val cs: CoroutineScope) : InlineCompleti
369353
CodeWhispererAutomatedTriggerType.Enter()
370354
} else if (CodeWhispererConstants.SPECIAL_CHARACTERS_LIST.contains(triggerString)) {
371355
CodeWhispererAutomatedTriggerType.SpecialChar(triggerString.single())
372-
} else if (event is InlineCompletionEvent.ManualCall || event is InlineCompletionEvent.DirectCall) {
356+
} else if (event.isManualCall()) {
373357
CodeWhispererAutomatedTriggerType.IntelliSense()
374358
} else {
375359
CodeWhispererAutomatedTriggerType.Classifier()
@@ -585,13 +569,3 @@ class QInlineCompletionProvider(private val cs: CoroutineScope) : InlineCompleti
585569
return true
586570
}
587571
}
588-
589-
// DirectCall is deprecated starting 243, replaced by ManualCall
590-
fun InlineCompletionEvent.isManualCall(): Boolean {
591-
val currentBuild = ApplicationInfo.getInstance().build.withoutProductCode()
592-
if (currentBuild.baselineVersion == 242) {
593-
return this is InlineCompletionEvent.DirectCall && this.context?.getData(QInlineCompletionProvider.DATA_KEY_Q_AUTO_TRIGGER_INTELLISENSE) == false
594-
} else {
595-
return this is InlineCompletionEvent.ManualCall && this.additionalData.getUserData(QInlineCompletionProvider.KEY_Q_AUTO_TRIGGER_INTELLISENSE) == false
596-
}
597-
}

0 commit comments

Comments
 (0)