File tree Expand file tree Collapse file tree 6 files changed +31
-17
lines changed
exts/devins-lang/src/main
kotlin/cc/unitmesh/devti/language
src/main/kotlin/cc/unitmesh/devti/agent/configurable Expand file tree Collapse file tree 6 files changed +31
-17
lines changed Original file line number Diff line number Diff line change @@ -8,8 +8,5 @@ import com.intellij.openapi.vfs.VirtualFileManager
8
8
fun Project.lookupFile (path : String ): VirtualFile ? {
9
9
val projectPath = this .guessProjectDir()?.toNioPath()
10
10
val realpath = projectPath?.resolve(path)
11
-
12
- val virtualFile =
13
- VirtualFileManager .getInstance().findFileByUrl(" file://${realpath?.toAbsolutePath()} " )
14
- return virtualFile
11
+ return VirtualFileManager .getInstance().findFileByUrl(" file://${realpath?.toAbsolutePath()} " )
15
12
}
Original file line number Diff line number Diff line change 1
1
package cc.unitmesh.devti.language.completion
2
2
3
- import cc.unitmesh.devti.agent.configurable.customAgentSetting
3
+ import cc.unitmesh.devti.agent.configurable.loadAgentConfigs
4
4
import cc.unitmesh.devti.agent.model.CustomAgentConfig
5
5
import com.intellij.codeInsight.completion.CompletionParameters
6
6
import com.intellij.codeInsight.completion.CompletionProvider
7
7
import com.intellij.codeInsight.completion.CompletionResultSet
8
8
import com.intellij.codeInsight.lookup.LookupElementBuilder
9
9
import com.intellij.util.ProcessingContext
10
- import kotlinx.serialization.json.Json
11
- // DON'T CHANGE THIS IMPORT
12
- import kotlinx.serialization.decodeFromString
13
10
14
11
class CustomAgentCompletion : CompletionProvider <CompletionParameters >() {
15
12
override fun addCompletions (
16
13
parameters : CompletionParameters ,
17
14
context : ProcessingContext ,
18
15
result : CompletionResultSet ,
19
16
) {
20
- val project = parameters.originalFile.project
21
- val configs: List <CustomAgentConfig > = try {
22
- val ragsJsonConfig = project.customAgentSetting.ragsJsonConfig
23
- Json .decodeFromString(ragsJsonConfig)
24
- } catch (e: Exception ) {
25
- emptyList()
26
- }
17
+ val configs: List <CustomAgentConfig > = loadAgentConfigs(parameters.originalFile.project)
27
18
28
19
configs.forEach {
29
20
result.addElement(
Original file line number Diff line number Diff line change @@ -56,7 +56,6 @@ class FileReferenceLanguageProvider : CompletionProvider<CompletionParameters>()
56
56
57
57
fun canBeAdded (file : VirtualFile ): Boolean {
58
58
if (! file.isValid || file.isDirectory) return false
59
-
60
59
if (file.fileType.isBinary || FileUtilRt .isTooLarge(file.length)) return false
61
60
62
61
return true
Original file line number Diff line number Diff line change
1
+ package cc.unitmesh.devti.language.documentation
2
+
3
+ import com.intellij.lang.documentation.DocumentationProvider
4
+ import com.intellij.psi.PsiElement
5
+
6
+ class DevInsDocumentationProvider : DocumentationProvider {
7
+ override fun getQuickNavigateInfo (element : PsiElement ? , originalElement : PsiElement ? ): String? {
8
+ return super .getQuickNavigateInfo(element, originalElement)
9
+ }
10
+ }
Original file line number Diff line number Diff line change 37
37
<runLineMarkerContributor language =" DevIn"
38
38
implementationClass =" cc.unitmesh.devti.language.run.DevInsRunLineMarkersProvider" />
39
39
40
+ <lang .documentationProvider language =" DevIn"
41
+ id =" devinsDocumentationProvider"
42
+ implementationClass =" cc.unitmesh.devti.language.documentation.DevInsDocumentationProvider" />
40
43
</extensions >
41
44
42
45
<actions >
46
49
</actions >
47
50
48
51
<extensions defaultExtensionNs =" cc.unitmesh" >
49
- <customAgentResponse implementation =" cc.unitmesh.devti.language.provider.DevInsCustomAgentResponse" />
52
+ <customAgentResponse implementation =" cc.unitmesh.devti.language.provider.DevInsCustomAgentResponse" />
50
53
</extensions >
51
54
</idea-plugin >
Original file line number Diff line number Diff line change 1
1
package cc.unitmesh.devti.agent.configurable
2
2
3
+ import cc.unitmesh.devti.agent.model.CustomAgentConfig
3
4
import com.intellij.openapi.components.*
4
5
import com.intellij.openapi.project.Project
6
+ import kotlinx.serialization.json.Json
7
+ // DON'T CHANGE THIS IMPORT
8
+ import kotlinx.serialization.decodeFromString
5
9
6
10
val Project .customAgentSetting: CoUnitProjectSettingsService
7
11
get() = service<CoUnitProjectSettingsService >()
8
12
13
+ fun loadAgentConfigs (project : Project ): List <CustomAgentConfig > {
14
+ val configs: List <CustomAgentConfig > = try {
15
+ val ragsJsonConfig = project.customAgentSetting.ragsJsonConfig
16
+ Json .decodeFromString(ragsJsonConfig)
17
+ } catch (e: Exception ) {
18
+ emptyList()
19
+ }
20
+ return configs
21
+ }
22
+
9
23
@Service(Service .Level .PROJECT )
10
24
@State(name = " CoUnitProjectSettings" , storages = [Storage (StoragePathMacros .WORKSPACE_FILE )])
11
25
class CoUnitProjectSettingsService (
You can’t perform that action at this time.
0 commit comments