Skip to content

Commit

Permalink
Fix loading of CodyInlineCompletionProvider in IJ 2023 (#2510)
Browse files Browse the repository at this point in the history
## Changes

Fixes BUGS-577 

In IJ 2023 we want `CodyInlineCompletionProvider` to be disabled, but we
need to load the class to make the check.
`InlineCompletionProviderID` class does not exist in 2023.2 and younger,
so loading class was failing.

## Test plan

1. Open IJ 2023.2 and check if autocomplete works. No exception should
be thrown.
2. Open IJ 2024.2 in remote mode and check if autocomplete works. No
exception should be thrown.
  • Loading branch information
pkukielka authored Oct 24, 2024
1 parent e74204f commit 02f7f40
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ import java.util.concurrent.atomic.AtomicReference
class CodyInlineCompletionProvider : InlineCompletionProvider {
private val logger = Logger.getInstance(CodyInlineCompletionProvider::class.java)
private val currentJob = AtomicReference(CancellationToken())
val id = InlineCompletionProviderID("Cody")
val id
get() = InlineCompletionProviderID("Cody")

suspend fun getSuggestion(request: InlineCompletionRequest): InlineCompletionSuggestion {
ApplicationManager.getApplication().assertIsNonDispatchThread()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ import java.util.concurrent.atomic.AtomicReference
class CodyInlineCompletionProvider : InlineCompletionProvider {
private val logger = Logger.getInstance(CodyInlineCompletionProvider::class.java)
private val currentJob = AtomicReference(CancellationToken())
override val id = InlineCompletionProviderID("Cody")
override val id
get() = InlineCompletionProviderID("Cody")

override suspend fun getSuggestion(request: InlineCompletionRequest): InlineCompletionSuggestion {
ApplicationManager.getApplication().assertIsNonDispatchThread()
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@

<keymapExtension implementation="com.sourcegraph.cody.config.CodyKeymapExtension"/>

<inline.completion.provider implementation="com.sourcegraph.cody.autocomplete.CodyInlineCompletionProvider"/>
<inline.completion.provider id="Cody" implementation="com.sourcegraph.cody.autocomplete.CodyInlineCompletionProvider"/>
<!-- Web UI Sidebar Views
For each sourcegraph/cody/vscode/package.json "views" entry with type "webview",
add a toolWindow with factoryClass="com.sourcegraph.cody.sidebar.WebUIToolWindowFactory"
Expand Down

0 comments on commit 02f7f40

Please sign in to comment.