Skip to content

Commit

Permalink
Fix verification plugin issues related to InlineCompletionProviderID
Browse files Browse the repository at this point in the history
  • Loading branch information
pkukielka committed Oct 15, 2024
1 parent 4776bcd commit fa6d1f1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,12 @@
// Apache 2.0 license.
package com.intellij.codeInsight.inline.completion.elements

/**
* InlineCompletionElement is located in the following packages:
* - 2023.2 - com.intellij.codeInsight.inline.completion
* - 2023.3+ - com.intellij.codeInsight.inline.completion.elements
*
* We need that class in CodyInlineCompletionProvider::getSuggestion which is an API from 2023.3+ so
* we need to provide our own stub to make compiler happy with IntelliJ platform 2023.2.
*/
interface InlineCompletionElement
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package com.sourcegraph.cody.autocomplete

import com.intellij.codeInsight.inline.completion.InlineCompletionElement
import com.intellij.codeInsight.inline.completion.InlineCompletionEvent
import com.intellij.codeInsight.inline.completion.InlineCompletionProvider
import com.intellij.codeInsight.inline.completion.InlineCompletionRequest
import com.intellij.codeInsight.inline.completion.InlineCompletionSuggestion
import com.intellij.codeInsight.inline.completion.*
import com.intellij.codeInsight.inline.completion.elements.InlineCompletionGrayTextElement
import com.intellij.openapi.application.ApplicationInfo
import com.intellij.openapi.application.ApplicationManager
Expand Down Expand Up @@ -32,8 +28,6 @@ import java.util.concurrent.CompletableFuture
import java.util.concurrent.TimeUnit
import java.util.concurrent.atomic.AtomicReference

@JvmInline value class InlineCompletionProviderID(val id: String)

class CodyInlineCompletionProvider : InlineCompletionProvider {
private val logger = Logger.getInstance(CodyInlineCompletionProvider::class.java)
private val currentJob = AtomicReference(CancellationToken())
Expand Down Expand Up @@ -145,6 +139,9 @@ class CodyInlineCompletionProvider : InlineCompletionProvider {
return isEnabled()
}

// Needed to compile with IntelliJ platform 2023.2, not used in 2024.2+.
// What follows InlineCompletionElement need to be in the same package as in 2023.2, not in
// 2024.2+ (it was moved).
override suspend fun getProposals(
request: InlineCompletionRequest
): List<InlineCompletionElement> {
Expand Down

0 comments on commit fa6d1f1

Please sign in to comment.