Skip to content

Commit 5ff85e0

Browse files
committed
feat(go): add Go version and target version to chat context
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.
1 parent 8696ae8 commit 5ff85e0

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

goland/src/main/kotlin/cc/unitmesh/go/provider/GoVersionChatContextProvider.kt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ package cc.unitmesh.go.provider
33
import cc.unitmesh.devti.provider.context.ChatContextItem
44
import cc.unitmesh.devti.provider.context.ChatContextProvider
55
import cc.unitmesh.devti.provider.context.ChatCreationContext
6+
import com.goide.sdk.GoSdkService
7+
import com.goide.sdk.GoTargetSdkVersionProvider
8+
import com.goide.util.GoUtil
9+
import com.intellij.openapi.module.Module
610
import com.intellij.openapi.project.Project
711

812
class GoVersionChatContextProvider : ChatContextProvider {
@@ -11,6 +15,18 @@ class GoVersionChatContextProvider : ChatContextProvider {
1115
}
1216

1317
override suspend fun collect(project: Project, creationContext: ChatCreationContext): List<ChatContextItem> {
14-
TODO("Not yet implemented")
18+
val sourceFile = creationContext.sourceFile ?: return emptyList()
19+
20+
val goVersion = GoSdkService.getInstance(project).getSdk(GoUtil.module(sourceFile)).version
21+
val targetVersion = GoTargetSdkVersionProvider.getTargetGoSdkVersion(sourceFile).toString()
22+
23+
24+
return listOf(
25+
ChatContextItem(
26+
GoVersionChatContextProvider::class,
27+
"Go Version: $goVersion, Target Version: $targetVersion"
28+
)
29+
)
1530
}
1631
}
32+

0 commit comments

Comments
 (0)