-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
107 additions
and
13 deletions.
There are no files selected for viewing
45 changes: 43 additions & 2 deletions
45
...n/lib/src/main/kotlin/com/sourcegraph/cody/agent/protocol_generated/AutocompleteResult.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,49 @@ | ||
@file:Suppress("FunctionName", "ClassName", "unused", "EnumEntryName", "UnusedImport") | ||
package com.sourcegraph.cody.agent.protocol_generated; | ||
|
||
data class AutocompleteResult( | ||
import com.google.gson.annotations.SerializedName; | ||
import com.google.gson.Gson; | ||
import com.google.gson.JsonDeserializationContext; | ||
import com.google.gson.JsonDeserializer; | ||
import com.google.gson.JsonElement; | ||
import java.lang.reflect.Type; | ||
|
||
sealed class AutocompleteResult { | ||
companion object { | ||
val deserializer: JsonDeserializer<AutocompleteResult> = | ||
JsonDeserializer { element: JsonElement, _: Type, context: JsonDeserializationContext -> | ||
when (element.getAsJsonObject().get("type").getAsString()) { | ||
"completion" -> context.deserialize<AutocompleteCompletionResult>(element, AutocompleteCompletionResult::class.java) | ||
"edit" -> context.deserialize<AutocompleteEditResult>(element, AutocompleteEditResult::class.java) | ||
else -> throw Exception("Unknown discriminator ${element}") | ||
} | ||
} | ||
} | ||
} | ||
|
||
data class AutocompleteCompletionResult( | ||
val type: TypeEnum, // Oneof: completion | ||
val items: List<AutocompleteItem>, | ||
val completionEvent: CompletionBookkeepingEvent? = null, | ||
) | ||
) : AutocompleteResult() { | ||
|
||
enum class TypeEnum { | ||
@SerializedName("completion") Completion, | ||
} | ||
} | ||
|
||
data class AutocompleteEditResult( | ||
val type: TypeEnum, // Oneof: edit | ||
val range: Range, | ||
val originalText: String, | ||
val prediction: String, | ||
val decorations: DecorationsParams, | ||
val items: List<AutocompleteItem>, | ||
val completionEvent: CompletionBookkeepingEvent? = null, | ||
) : AutocompleteResult() { | ||
|
||
enum class TypeEnum { | ||
@SerializedName("edit") Edit, | ||
} | ||
} | ||
|
10 changes: 10 additions & 0 deletions
10
.../src/main/kotlin/com/sourcegraph/cody/agent/protocol_generated/AutoeditImageDecoration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
@file:Suppress("FunctionName", "ClassName", "unused", "EnumEntryName", "UnusedImport") | ||
package com.sourcegraph.cody.agent.protocol_generated; | ||
|
||
data class AutoeditImageDecoration( | ||
val dark: String, | ||
val light: String, | ||
val pixelRatio: Long, | ||
val position: PositionParams, | ||
) | ||
|
17 changes: 17 additions & 0 deletions
17
...b/src/main/kotlin/com/sourcegraph/cody/agent/protocol_generated/AutoeditTextDecoration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
@file:Suppress("FunctionName", "ClassName", "unused", "EnumEntryName", "UnusedImport") | ||
package com.sourcegraph.cody.agent.protocol_generated; | ||
|
||
import com.google.gson.annotations.SerializedName; | ||
|
||
data class AutoeditTextDecoration( | ||
val type: TypeEnum, // Oneof: insert, delete | ||
val range: Range, | ||
val text: String? = null, | ||
) { | ||
|
||
enum class TypeEnum { | ||
@SerializedName("insert") Insert, | ||
@SerializedName("delete") Delete, | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...in/lib/src/main/kotlin/com/sourcegraph/cody/agent/protocol_generated/DecorationsParams.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@file:Suppress("FunctionName", "ClassName", "unused", "EnumEntryName", "UnusedImport") | ||
package com.sourcegraph.cody.agent.protocol_generated; | ||
|
||
data class DecorationsParams( | ||
val text: List<AutoeditTextDecoration>? = null, | ||
val image: AutoeditImageDecoration? = null, | ||
) | ||
|
8 changes: 8 additions & 0 deletions
8
...otlin/lib/src/main/kotlin/com/sourcegraph/cody/agent/protocol_generated/PositionParams.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@file:Suppress("FunctionName", "ClassName", "unused", "EnumEntryName", "UnusedImport") | ||
package com.sourcegraph.cody.agent.protocol_generated; | ||
|
||
data class PositionParams( | ||
val line: Long, | ||
val column: Long, | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters