Skip to content

Commit

Permalink
feat(go): add Go version and target version to chat context
Browse files Browse the repository at this point in the history
Add Go version and target version to the chat context in the GoVersionChatContextProvider class. This information is collected from the Go SDK service and the Go target SDK version provider. The versions are then included in the chat context item.
  • Loading branch information
phodal committed Jan 16, 2024
1 parent 8696ae8 commit 5ff85e0
Showing 1 changed file with 17 additions and 1 deletion.
Expand Up @@ -3,6 +3,10 @@ package cc.unitmesh.go.provider
import cc.unitmesh.devti.provider.context.ChatContextItem
import cc.unitmesh.devti.provider.context.ChatContextProvider
import cc.unitmesh.devti.provider.context.ChatCreationContext
import com.goide.sdk.GoSdkService
import com.goide.sdk.GoTargetSdkVersionProvider
import com.goide.util.GoUtil
import com.intellij.openapi.module.Module
import com.intellij.openapi.project.Project

class GoVersionChatContextProvider : ChatContextProvider {
Expand All @@ -11,6 +15,18 @@ class GoVersionChatContextProvider : ChatContextProvider {
}

override suspend fun collect(project: Project, creationContext: ChatCreationContext): List<ChatContextItem> {
TODO("Not yet implemented")
val sourceFile = creationContext.sourceFile ?: return emptyList()

val goVersion = GoSdkService.getInstance(project).getSdk(GoUtil.module(sourceFile)).version
val targetVersion = GoTargetSdkVersionProvider.getTargetGoSdkVersion(sourceFile).toString()


return listOf(
ChatContextItem(
GoVersionChatContextProvider::class,
"Go Version: $goVersion, Target Version: $targetVersion"
)
)
}
}

0 comments on commit 5ff85e0

Please sign in to comment.