Skip to content

Commit 1eeeb23

Browse files
committed
feat(provider): add HarmonyOS chat context provider
Add a new `HarmonyOSChatContextProvider` implementation to provide chat context items specific to HarmonyOS projects. The provider checks if the IDE platform prefix is "DevEcoStudio" and if so, returns a single chat context item indicating that the project is a HarmonyOS project. The implementation is added as an extension point in the plugin XML configuration file under the `<extensions>` section.
1 parent 1b7b91e commit 1eeeb23

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package cc.unitmesh.harmonyos.provider
2+
3+
import cc.unitmesh.devti.provider.context.ChatContextItem
4+
import cc.unitmesh.devti.provider.context.ChatContextProvider
5+
import cc.unitmesh.devti.provider.context.ChatCreationContext
6+
import com.intellij.openapi.project.Project
7+
8+
class HarmonyOSChatContextProvider : ChatContextProvider {
9+
override fun isApplicable(project: Project, creationContext: ChatCreationContext): Boolean {
10+
return System.getProperty("idea.platform.prefix", "idea") == "DevEcoStudio"
11+
}
12+
13+
override suspend fun collect(project: Project, creationContext: ChatCreationContext): List<ChatContextItem> {
14+
return listOf(ChatContextItem(HarmonyOSChatContextProvider::class, "This project is a HarmonyOS project."))
15+
}
16+
}

exts/ext-harmonyos/src/main/resources/cc.unitmesh.harmonyos.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@
55
<bundleName>messages.AutoDevBundle</bundleName>
66
<categoryKey>intention.category.llm</categoryKey>
77
</autoDevIntention>
8+
9+
<chatContextProvider implementation="cc.unitmesh.harmonyos.provider.HarmonyOSChatContextProvider"/>
810
</extensions>
911
</idea-plugin>

0 commit comments

Comments
 (0)